我不喜欢每次启动终端时都重新输入鱼。我希望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命令)。

其他回答

这个工作为我在新安装的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

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

从终端:

将Fish添加到/etc/shell,这将需要一个管理密码: Sudo echo /usr/local/bin/fish >> /etc/shell 使用chsh将Fish设置为默认shell: CHSH -s /usr/local/bin/fish


从系统首选项:

用户和组→按下当前用户→高级选项… 修改Login shell为/usr/local/bin/fish 按OK,退出并再次登录

如果您在使用其他方法时遇到问题,下面的方法可以在macOS v10.14 (Mojave)上工作,但通常应该可以工作。

which fish

将输出路径添加到系统首选项→用户和组→右键单击用户,高级选项。将结果粘贴到“Login 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"