This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
The community reviewed whether to reopen this question 2 years ago and left it closed:
Not suitable for this site This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(18)
1. sudo nano /etc/shells
2. 将 /usr/local/bin/fish 添加到您的 shell 列表
3. chsh -s /usr/local/bin/fish
1. sudo nano /etc/shells
2. add /usr/local/bin/fish to your list of shells
3. chsh -s /usr/local/bin/fish
从终端:
将 Fish 添加到
/etc/shells
,这将需要管理密码:使用
chsh
将 Fish 设置为默认 shell:从系统偏好设置:
用户和组 → 按住 Ctrl 键单击当前用户 → 高级选项...
将登录 shell 更改为
/usr/local/bin/fish
按确定,注销并重新登录
From Terminal:
Add Fish to
/etc/shells
, which will require an administrative password:Make Fish your default shell with
chsh
:From System Preferences:
User and Groups → ctrl-click on Current User → Advanced Options...
Change Login shell to
/usr/local/bin/fish
Press OK, log out and in again
您可以使用 chsh 来更改用户的 shell。
例如,运行以下代码将您的 shell 更改为 Zsh
正如 Lorin 的联机帮助页中所述,如果操作系统不识别该 shell,则必须将其添加到其已知列表中:
/etc/外壳
。You can use chsh to change a user's shell.
Run the following code, for instance, to change your shell to 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
.这些适用于 macOS v10.12.5 (Sierra) (16F73) 以及可能其他一些最近和即将推出的 macOS 版本。
chsh
不足以更改默认 shell。 确保在终端打开时按 Command + ,,并将“Shells 打开方式”选项更改为“默认登录 shell”。如果是 Bash,请确保执行
echo $BASH_VERSION
以确认您正在运行所需版本的 Bash。bash --version
没有为您提供正确的信息。These are applicable to macOS v10.12.5 (Sierra) (16F73) and probably some other recent and upcoming versions of 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.'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.这是另一种方法:
假设您使用 MacPorts 安装它,这可以通过执行:
您的 shell 将位于
/opt/local/bin/fish
中。您需要告诉 OS X 这是一个有效的 shell。 为此,请将此路径添加到
/etc/shells
文件的末尾。完成此操作后,您可以通过转到“系统偏好设置”→“帐户”来更改 shell。 单击“锁定”以允许更改。 右键单击该帐户,然后选择“高级选项...”。。 在“Login shell”字段中,添加 Fish 的路径。
Here's another way to do it:
Assuming you installed it with MacPorts, which can be done by doing:
Your shell will be located in
/opt/local/bin/fish
.You need to tell OS X that this is a valid shell. To do that, add this path to the end of the
/etc/shells
file.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.
fish
检查是否安装正确,如果安装正确,输入exit
whichfish
,复制路径。chsh -s
fish
to check if it was installed correctly, if installed correctly, typeexit
which fish
, copy the path.sudo sh -c 'echo <your-fish-path-here> >> /etc/shells'
chsh -s <your-fish-path-here>
Terminal.app → 首选项 → 常规 → Shells open with → /bin/fish >
请参阅此屏幕截图,其中
zsh
被设置为默认值。我正在使用 macOS v10.12< /a>(塞拉利昂)。 它也适用于 macOS v10.14 (Mojave)。
Terminal.app → Preferences → General → Shells open with → /bin/fish
See this screenshot where
zsh
is being set as default.I am using macOS v10.12 (Sierra). It also works in macOS v10.14 (Mojave).
唯一对我有用的是所有这些方法的组合。
首先,我必须将 Fish 可执行文件的路径添加到
/etc/shells
文件然后我运行
chsh -s /usr/local/bin/fish
< /p>最后,我输入 Command + , 并添加
/usr/local/bin/fish
到默认路径只有在我完成所有三个操作之后Fish 开始作为新终端窗口的默认值弹出。
The only thing that worked for me was a combination of all these methods.
First I had to add the path to the Fish executable to the
/etc/shells
fileThen I ran
chsh -s /usr/local/bin/fish
Finally, I typed Command + , and added
/usr/local/bin/fish
to the default path thereOnly after I had done all three things did Fish start popping up as the default for new terminal windows.
在 macOS v10.14 (Mojave) 上,我必须执行以下操作(使用 Z shell (
zsh
) 为例):On macOS v10.14 (Mojave) I had to do the following (using Z shell (
zsh
) as an example):Homebrew 位于 M1 Mac 应使用
/opt/homebrew
而不是/usr/local
。您可以检查钓鱼位置
钓鱼
。 对我来说,Fish 位于/opt/homebrew/bin/fish
中,这是我添加到etc/shells
中的位置。Homebrew on M1 Macs should use
/opt/homebrew
instead of/usr/local
.You can check the Fish location
which fish
. For me, Fish was in/opt/homebrew/bin/fish
which was the location I have added toetc/shells
.如何在现代 macOS 上获取最新版本的 Bash(已在 macOS v10.14 (Mojave ))。
然后你就可以获得 Vim 风格的 Tab 补全,它仅在 Bash >= 4 上可用(当前版本在Homebrew 是 5.0.2):
How to get the latest version of Bash on modern macOS (tested on macOS v10.14 (Mojave)).
Then you are ready to get Vim-style tab completion which is only available on Bash >= 4 (the current version in Homebrew is 5.0.2):
这对我来说在全新安装 Mac OS X v10.12 (Sierra) 时有效:
定义当前用户为 shell 的所有者
将 Fish 添加到文件 /etc/shells
Make Fish< /a> 你的默认 shell chsh
重新定义 root 作为 shell 的所有者
This work for me on fresh install of Mac OS X v10.12 (Sierra):
Define the current user as the owner of shells
Add Fish to file /etc/shells
Make Fish your default shell with chsh
Redefine root as the owner of shells
chsh
程序可以让您更改默认 shell。 它需要可执行文件的完整路径,因此如果您的 shell 是 Fish,那么它会要求您提供输入whichfish
时给出的输出。您将看到一行以“
Shell:
”开头的行。 如果您从未编辑过它,它很可能会显示“Shell: /bin/bash
”。 将/bin/bash
路径替换为所需 shell 的路径。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 typewhich 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.要更改 Mac 上的默认 shell,请运行以下命令:
您可以选择的 shell 列表为:
因此,如果您想更改为 /bin/zsh shell,您的命令将如下所示:
您可以通过运行以下命令查看系统上所有可用的 shell:
To change your default shell on Mac, run the following:
The list of shells you can choose from are:
so if you want to change from to the /bin/zsh shell, your command will look like:
You can see all the available shells on your system by running:
在
终端
中时,使用Command+,打开终端首选项。在常规选项卡上,
Shells open with
:从默认登录 shell
更改为Command
:并使用
/bin/fish
When in the
Terminal
, open the terminal preferences using Command+,.On the General Tab,
Shells open with
: change fromDefault login shell
toCommand
:and using
/bin/fish
使用
dscl
:只需更改该值(使用 write 命令
dscl
)。Use
dscl
:Just change that value (with the write command in
dscl
).如果您在使用其他方法时遇到问题,以下方法适用于 macOS v10.14 ( Mojave),但通常应该可以工作。
将输出路径添加到系统偏好设置→用户和用户 组 → 右键单击用户,高级选项。 将
which
的结果粘贴到“Login shell:”字段中。In case you are having troubles with the other ways, the following worked on macOS v10.14 (Mojave), but it should generally work.
Add the output path to System Preferences → Users & Groups → right click user, Advanced Options. Paste the result from
which
into filed "Login shell:".编辑文件 .zshrc 并将其更改为
exec /bin/bash
或您可能喜欢的任何 shell。
额外奖励:这不需要 root 访问权限,并且适用于每个版本的 OS X。
唯一的问题是它不以这种方式读取文件.bash_profile; 仅当 Bash 作为交互式登录 shell 运行时才会读取它。 您必须从文件 .bashrc 中包含它,如下所示:
另外:osx 附带的 bash 版本有点过时,最好使用 <代码>brew安装bash; 在这种情况下,您的 .zshrc 文件应该运行正确的 bash 版本。 目前是
exec /usr/local/Cellar/bash/5.1.8/bin/bash
Edit file .zshrc and change it to
exec /bin/bash
Or to whatever shell you might prefer.
Bonus: this doesn't require root access and will work on every version of OS X.
The only problem is that it doesn't read file .bash_profile this way; it is only read if Bash is run as an interactive login shell. You would have to include it from file .bashrc with something like this:
Also: The bash version that comes with osx is a bit dated, it is preferrable to install an up to date version of bash with
brew install bash
; in this case your .zshrc file should run the correct bash version. Currently that isexec /usr/local/Cellar/bash/5.1.8/bin/bash