I do not like to retype fish every time I start terminal. I want fish
on by default. How can I set fish shell as my default shell on a Mac?
我不喜欢每次开始终端时重新输入鱼。我想默认鱼。如何在Mac上将鱼壳设置为我的默认shell?
13 个解决方案
#1
These are applicable to MacOS Sierra 10.12.5 (16F73) and probably some other recent and upcoming versions of MacOS.
这些适用于MacOS Sierra 10.12.5(16F73)以及其他一些近期和即将推出的MacOS版本。
-
chsh
is not enough to change the default shell. Make sure you press Command+, while your terminal is open and change the 'Shells open with' option to 'Default login shell.'chsh不足以更改默认shell。确保在终端打开时按Command +,并将“打开的shell”选项更改为“默认登录shell”。
-
In case of bash, make sure that you execute
echo $BASH_VERSION
to confirm you are running the intended version of bash.bash --version
does not give you correct information.如果是bash,请确保执行echo $ BASH_VERSION以确认您运行的是预期版本的bash。 bash --version不会为您提供正确的信息。
#2
1. sudo nano /etc/shells
1. sudo nano / etc / shells
2. add /usr/local/bin/fish to your list of shells
2.将/ usr / local / bin / fish添加到shell列表中
3. chsh -s /usr/local/bin/fish
3. chsh -s / usr / local / bin / fish
#3
You can use chsh to change a user's shell.
您可以使用chsh来更改用户的shell。
Run the following code, for instance, to change your shell to Zsh
例如,运行以下代码将shell更改为Zsh
chsh -s /bin/zsh
As described in the manpage, and by Lorin, if the shell is not known by the OS, you have to add it to its known list: /etc/shells
.
如联机帮助页和Lorin所述,如果操作系统不知道shell,则必须将其添加到已知列表:/ etc / shells。
#4
From Terminal:
-
Add Fish to
/etc/shells
, which will require an administrative password:将Fish添加到/ etc / shells,这将需要管理密码:
sudo echo /usr/local/bin/fish >> /etc/shells
-
Make Fish your default shell with
chsh
:使用chsh将Fish设为默认shell:
chsh -s /usr/local/bin/fish
From System Preferences:
从系统偏好设置:
-
User and Groups → ctrl-click on Current User → Advanced Options...
用户和组→按住Ctrl键单击当前用户→高级选项...
-
Change Login shell to
/usr/local/bin/fish
将登录shell更改为/ usr / local / bin / fish
-
Press OK, log out and in again
按确定,再次注销
#5
Here's another way to do it:
这是另一种方法:
Assuming you installed it with MacPorts, which can be done by doing:
假设您使用MacPorts安装它,可以通过执行以下操作来完成:
sudo port install fish
Your shell will be located in /opt/local/bin/fish
.
你的shell将位于/ opt / local / bin / fish中。
You need to tell OSX that this is a valid shell. To do that, add this path to the end of the /etc/shells
file.
您需要告诉OSX这是一个有效的shell。为此,请将此路径添加到/ etc / shells文件的末尾。
Once you've done this, you can change the shell by going to System Preferences -> Accounts. Click on the Lock to allow changes. Right-click on the account, and choose "Advanced Options...". In the "Login shell" field, add the path to fish.
完成此操作后,您可以转到“系统偏好设置” - >“帐户”来更改shell。单击锁定以允许更改。右键单击该帐户,然后选择“高级选项...”。在“登录shell”字段中,添加fish的路径。
#6
The only thing that worked for me was a combination of all these methods.
唯一对我有用的是所有这些方法的组合。
-
First I had to add fish to the
/etc/shells
file首先,我必须将鱼添加到/ etc / shells文件中
-
Then I ran
chsh -s /usr/local/bin/fish
然后我运行chsh -s / usr / local / bin / fish
-
Finally, I typed Command+, and added
/usr/local/bin/fish
to the default path there最后,我输入了Command +,并将/ usr / local / bin / fish添加到那里的默认路径
Only after I had done all three things did fish start popping up as the default for new terminal windows.
只有在我完成了所有这三件事后,鱼才开始弹出作为新终端窗口的默认设置。
#8
the chsh
program will let you change your default shell. It will want the full path to the executable, so if your shell is fish
then it will want you to provide the output given when you type which fish
.
chsh程序将允许您更改默认shell。它将需要可执行文件的完整路径,因此如果你的shell是fish,那么它会要求你提供输入哪条鱼给出的输出。
You'll see a line starting with "Shell:
". If you've never edited it, it most likely says "Shell: /bin/bash
". Replace that /bin/bash
path with the path to your desired shell.
你会看到以“Shell:”开头的行。如果您从未编辑过它,很可能会说“Shell:/ bin / bash”。将/ bin / bash路径替换为所需shell的路径。
#9
When in the terminal, open the terminal preferences using Command+,.
在终端中时,使用Command +打开终端首选项。
On the Setting Tab, select one of the themes, and choose the shell tab on the right.
在“设置”选项卡上,选择其中一个主题,然后选择右侧的“外壳”选项卡。
You can set the autostart command fish
.
您可以设置autostart命令fish。
#10
- Open your terminal and press command+, (comma). This will open a preferences window.
- The first tab is 'General'.
- Find 'Shells open with' setting and choose 2nd option which needs complete path to the shell.
- Paste the link to your fish command, which generally is
/usr/local/bin/fish
.
打开终端并按下命令+,(逗号)。这将打开一个首选项窗口。
第一个选项卡是“常规”。
找到'shell打开'设置并选择第二个选项,它需要完整的shell路径。
将链接粘贴到fish命令,通常是/ usr / local / bin / fish。
I am using macOS Sierra.
我正在使用macOS Sierra。
#11
On macOS Mojave I had to do the following (using zsh as an example):
在macOS Mojave上我必须执行以下操作(使用zsh作为示例):
brew install zsh
sudo sh -c "echo $(which zsh) >> /etc/shells"
chsh -s $(which zsh)
#12
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 >
just change that value (with the write command in dscl
).
只需更改该值(使用dscl中的write命令)。
#13
In case you are having troubles with the other ways, worked on mac Mojave but should generally work.
如果您遇到其他方式的麻烦,在Mac Mojave上工作,但通常应该工作。
which fish
add the output path to "System Preferences > Users & Groups > right click user, Advanced Options" Paste the result from which into "Login shell:"
将输出路径添加到“系统首选项>用户和组>右键单击用户,高级选项”将结果粘贴到“登录shell:”
#1
These are applicable to MacOS Sierra 10.12.5 (16F73) and probably some other recent and upcoming versions of MacOS.
这些适用于MacOS Sierra 10.12.5(16F73)以及其他一些近期和即将推出的MacOS版本。
-
chsh
is not enough to change the default shell. Make sure you press Command+, while your terminal is open and change the 'Shells open with' option to 'Default login shell.'chsh不足以更改默认shell。确保在终端打开时按Command +,并将“打开的shell”选项更改为“默认登录shell”。
-
In case of bash, make sure that you execute
echo $BASH_VERSION
to confirm you are running the intended version of bash.bash --version
does not give you correct information.如果是bash,请确保执行echo $ BASH_VERSION以确认您运行的是预期版本的bash。 bash --version不会为您提供正确的信息。
#2
1. sudo nano /etc/shells
1. sudo nano / etc / shells
2. add /usr/local/bin/fish to your list of shells
2.将/ usr / local / bin / fish添加到shell列表中
3. chsh -s /usr/local/bin/fish
3. chsh -s / usr / local / bin / fish
#3
You can use chsh to change a user's shell.
您可以使用chsh来更改用户的shell。
Run the following code, for instance, to change your shell to Zsh
例如,运行以下代码将shell更改为Zsh
chsh -s /bin/zsh
As described in the manpage, and by Lorin, if the shell is not known by the OS, you have to add it to its known list: /etc/shells
.
如联机帮助页和Lorin所述,如果操作系统不知道shell,则必须将其添加到已知列表:/ etc / shells。
#4
From Terminal:
-
Add Fish to
/etc/shells
, which will require an administrative password:将Fish添加到/ etc / shells,这将需要管理密码:
sudo echo /usr/local/bin/fish >> /etc/shells
-
Make Fish your default shell with
chsh
:使用chsh将Fish设为默认shell:
chsh -s /usr/local/bin/fish
From System Preferences:
从系统偏好设置:
-
User and Groups → ctrl-click on Current User → Advanced Options...
用户和组→按住Ctrl键单击当前用户→高级选项...
-
Change Login shell to
/usr/local/bin/fish
将登录shell更改为/ usr / local / bin / fish
-
Press OK, log out and in again
按确定,再次注销
#5
Here's another way to do it:
这是另一种方法:
Assuming you installed it with MacPorts, which can be done by doing:
假设您使用MacPorts安装它,可以通过执行以下操作来完成:
sudo port install fish
Your shell will be located in /opt/local/bin/fish
.
你的shell将位于/ opt / local / bin / fish中。
You need to tell OSX that this is a valid shell. To do that, add this path to the end of the /etc/shells
file.
您需要告诉OSX这是一个有效的shell。为此,请将此路径添加到/ etc / shells文件的末尾。
Once you've done this, you can change the shell by going to System Preferences -> Accounts. Click on the Lock to allow changes. Right-click on the account, and choose "Advanced Options...". In the "Login shell" field, add the path to fish.
完成此操作后,您可以转到“系统偏好设置” - >“帐户”来更改shell。单击锁定以允许更改。右键单击该帐户,然后选择“高级选项...”。在“登录shell”字段中,添加fish的路径。
#6
The only thing that worked for me was a combination of all these methods.
唯一对我有用的是所有这些方法的组合。
-
First I had to add fish to the
/etc/shells
file首先,我必须将鱼添加到/ etc / shells文件中
-
Then I ran
chsh -s /usr/local/bin/fish
然后我运行chsh -s / usr / local / bin / fish
-
Finally, I typed Command+, and added
/usr/local/bin/fish
to the default path there最后,我输入了Command +,并将/ usr / local / bin / fish添加到那里的默认路径
Only after I had done all three things did fish start popping up as the default for new terminal windows.
只有在我完成了所有这三件事后,鱼才开始弹出作为新终端窗口的默认设置。
#7
Mac OS X: How to change the Terminal shell
Mac OS X:如何更改终端shell
#8
the chsh
program will let you change your default shell. It will want the full path to the executable, so if your shell is fish
then it will want you to provide the output given when you type which fish
.
chsh程序将允许您更改默认shell。它将需要可执行文件的完整路径,因此如果你的shell是fish,那么它会要求你提供输入哪条鱼给出的输出。
You'll see a line starting with "Shell:
". If you've never edited it, it most likely says "Shell: /bin/bash
". Replace that /bin/bash
path with the path to your desired shell.
你会看到以“Shell:”开头的行。如果您从未编辑过它,很可能会说“Shell:/ bin / bash”。将/ bin / bash路径替换为所需shell的路径。
#9
When in the terminal, open the terminal preferences using Command+,.
在终端中时,使用Command +打开终端首选项。
On the Setting Tab, select one of the themes, and choose the shell tab on the right.
在“设置”选项卡上,选择其中一个主题,然后选择右侧的“外壳”选项卡。
You can set the autostart command fish
.
您可以设置autostart命令fish。
#10
- Open your terminal and press command+, (comma). This will open a preferences window.
- The first tab is 'General'.
- Find 'Shells open with' setting and choose 2nd option which needs complete path to the shell.
- Paste the link to your fish command, which generally is
/usr/local/bin/fish
.
打开终端并按下命令+,(逗号)。这将打开一个首选项窗口。
第一个选项卡是“常规”。
找到'shell打开'设置并选择第二个选项,它需要完整的shell路径。
将链接粘贴到fish命令,通常是/ usr / local / bin / fish。
I am using macOS Sierra.
我正在使用macOS Sierra。
#11
On macOS Mojave I had to do the following (using zsh as an example):
在macOS Mojave上我必须执行以下操作(使用zsh作为示例):
brew install zsh
sudo sh -c "echo $(which zsh) >> /etc/shells"
chsh -s $(which zsh)
#12
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 >
just change that value (with the write command in dscl
).
只需更改该值(使用dscl中的write命令)。
#13
In case you are having troubles with the other ways, worked on mac Mojave but should generally work.
如果您遇到其他方式的麻烦,在Mac Mojave上工作,但通常应该工作。
which fish
add the output path to "System Preferences > Users & Groups > right click user, Advanced Options" Paste the result from which into "Login shell:"
将输出路径添加到“系统首选项>用户和组>右键单击用户,高级选项”将结果粘贴到“登录shell:”