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


当前回答

chsh程序将允许您更改默认shell。它需要可执行文件的完整路径,所以如果你的shell是Fish,那么当你输入哪个Fish时,它会希望你提供给定的输出。

您将看到以“Shell:”开头的一行。如果你从未编辑过它,它很可能会显示“Shell: /bin/bash”。将/bin/bash路径替换为所需shell的路径。

其他回答

这个工作为我在新安装的Mac OS X v10.12 (Sierra):

将当前用户定义为shell的所有者 Sudo chown $(whoami) /etc/shell 将Fish添加到文件/etc/shell Sudo echo /usr/local/bin/fish >> /etc/shell 使用chsh将Fish设置为默认shell CHSH -s /usr/local/bin/fish 将root重新定义为shell的所有者 Sudo chown root /etc/shell

可以使用chsh更改用户的shell。

例如,运行以下代码将shell更改为Zsh

chsh -s /bin/zsh

正如Lorin在手册中所描述的,如果操作系统不知道shell,您必须将其添加到其已知列表:/etc/shell .

1. Sudo nano /etc/shell

2. 将/usr/local/bin/fish添加到shell列表中

3.CHSH -s /usr/local/bin/fish

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"