我不喜欢每次启动终端时都重新输入鱼。我希望Fish默认开启。如何将Fish shell设置为Mac上的默认shell ?


当前回答

使用dscl:

heimdall:~ leeg$ dscl
Entering interactive mode... (type "help" for commands)
 > cd /Local/Default/Users/
/Local/Default/Users > read <<YOUR_USER>>
[...]
UserShell: /bin/bash
/Local/Default/Users >

只需更改该值(使用dscl中的write命令)。

其他回答

M1 mac上的Homebrew应该使用/opt/ Homebrew而不是/usr/local。

您可以检查鱼位置,鱼。对我来说,Fish在/opt/homebrew/bin/ Fish中,这是我添加到etc/shell的位置。

如何在现代macOS上获得最新版本的Bash(在macOS v10.14 (Mojave)上测试)。

brew install bash
which bash | sudo tee -a /etc/shells
chsh -s $(which bash)

然后你就可以得到vim风格的tab补全了,它只在Bash >= 4上可用(Homebrew的当前版本是5.0.2):

# If there are multiple matches for completion, Tab should cycle through them
bind 'TAB':menu-complete

# Display a list of the matching files
bind "set show-all-if-ambiguous on"

# Perform partial completion on the first Tab press,
# only start cycling full results on the second Tab press
bind "set menu-complete-display-prefix on"

这里有另一种方法:

假设你用MacPorts安装了它,可以这样做:

sudo port install fish

您的shell将位于/opt/local/bin/fish。

你需要告诉OS X这是一个有效的shell。为此,将此路径添加到/etc/shell文件的末尾。

一旦你完成了这些,你可以通过系统首选项→帐户来更改shell。单击Lock以允许更改。右键单击该帐户,并选择“高级选项…”。在“Login shell”字段中,将路径添加到Fish。

Terminal.app →首选项 → 一般→ 贝壳打开,→/垃圾箱/鱼

打开终端,按下命令+,(逗号)。这将打开一个首选项窗口。 第一个标签是“General”。 找到“shell open with”设置,并选择第二个需要shell完整路径的选项。 将链接粘贴到fish命令,通常是/usr/local/bin/fish。

请看这张截图,其中zsh被设置为默认值。

我使用的是macOS v10.12 (Sierra)。它也适用于macOS v10.14 (Mojave)。

使用dscl:

heimdall:~ leeg$ dscl
Entering interactive mode... (type "help" for commands)
 > cd /Local/Default/Users/
/Local/Default/Users > read <<YOUR_USER>>
[...]
UserShell: /bin/bash
/Local/Default/Users >

只需更改该值(使用dscl中的write命令)。