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


当前回答

要更改Mac上的默认shell,运行以下命令:

chsh -s <name-of-shell>

你可以选择的shell列表有:

/bin/bash /bin/csh /bin/dash /bin/ksh /bin/sh /bin/tcsh /bin/zsh

因此,如果你想从/bin/zsh shell,你的命令将如下所示:

chsh -s /bin/zsh

您可以通过运行以下命令查看系统中所有可用的shell:

cat /etc/shells

其他回答

输入fish检查是否正确安装,如果安装正确,输入exit 键入哪条鱼,复制路径。 输入sudo sh -c 'echo <your-fish-path-here> >> /etc/shell ' 重新启动终端 输入CHSH -s <your-fish-path-here> 重新启动终端 现在应该可以了。

这些适用于macOS v10.12.5 (Sierra) (16F73),也可能适用于其他一些最新和即将推出的macOS版本。

CHSH不足以改变默认shell。确保你按Command +,当你的终端是打开的,并改变' shell open with'选项为'Default login shell '。 如果是Bash,请确保执行echo $BASH_VERSION以确认您正在运行预期的Bash版本。Bash—version没有提供正确的信息。

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"

在macOS v10.14 (Mojave)上,我必须做以下事情(以Z shell (zsh)为例):

brew install zsh
sudo sh -c "echo $(which zsh) >> /etc/shells"
chsh -s $(which zsh)