在 macOS 上安装 ZSH 作为默认 shell
最简单的方法是使用 brew
:
brew install zsh
安装后,你可能希望通过执行以下操作将其设置为默认 shell:
sudo echo '/usr/local/bin/zsh' >> /etc/shells
chsh -s /usr/local/bin/zsh
如果你安装了 git,并且安装了所需的命令行工具,则可以编译并安装最新版本(截至此编辑时为 5.2
),如下所示:
# clone the source
git clone git://git.code.sf.net/p/zsh/code zsh
# checkout the required version, say, zsh-5.2
cd zsh && git checkout zsh-5.2
# check the documentation for help on configuration options
./Util/preconfig
./configure --prefix=/usr/local \
--enable-fndir=/usr/local/share/zsh/functions \
--enable-scriptdir=/usr/local/share/zsh/scripts \
--enable-site-fndir=/usr/local/share/zsh/site-functions \
--enable-site-scriptdir=/usr/local/share/zsh/site-scripts \
--enable-runhelpdir=/usr/local/share/zsh/help \
--enable-etcdir=/etc \
--mandir=/usr/local/share/man \
--infodir=/usr/local/share/info \
--enable-cap \
--enable-maildir-support \
--enable-multibyte \
--enable-pcre \
--enable-zsh-secure-free \
--with-tcsetpgrp
# compile and check if compiled successfully
make -j5 && make check
# you should see results of successful test scripts
sudo make install
同样,你可以通过将 zsh
添加到/etc/shells
并使用如上所述的 chsh
将其作为默认 shell。