Mac 終端默認 shell 為 bash。
zsh 可能是目前最好的 shell 荞膘,至于好在哪里可自行百度贸弥。
本文主要介紹使用 zsh 以及 oh-my-zsh 的配置禁荒。
使用 zsh
查看當前使用的 shell
echo $SHELL
/bin/bash
查看安裝的 shell
cat /etc/shells
/bin/bash
/bin/csh
/bin/ksh
/bin/sh
/bin/tcsh
/bin/zsh
使用 brew 更新 zsh
brew install zsh
==> Downloading https://homebrew.bintray.com/bottles/zsh-5.5.1.high_sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring zsh-5.5.1.high_sierra.bottle.tar.gz
/usr/local/Cellar/zsh/5.5.1: 1,444 files, 12MB
切換為 zsh
chsh -s /bin/zsh
重啟終端即可使用 zsh
oh-my-zsh
安裝
執(zhí)行從 oh-my-zsh 的 GitHub 下載的安裝腳本
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
____ / /_ ____ ___ __ __ ____ _____/ /_
/ __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \
/ /_/ / / / / / / / / / / /_/ / / /_(__ ) / / /
\____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/
/____/ ....is now installed!
Please look over the ~/.zshrc file to select plugins, themes, and options.
p.s. Follow us at https://twitter.com/ohmyzsh.
p.p.s. Get stickers and t-shirts at http://shop.planetargon.com.
主題
打開 oh-my-zsh 配置文件
vim ~/.zshrc
配置項 ZSH_THEME
即為 oh-my-zsh 的主題配置,oh-my-zsh 的 GitHub Wiki 頁面提供了 主題列表
當設置為 ZSH_THEME=random
時尔崔,每次打開終端都會使用一種隨機的主題答毫。
更新配置
source ~/.zshrc
自動補全插件
下載 incr 自動補全插件 http://mimosa-pudica.net/src/incr-0.2.zsh
將插件放在 oh-my-zsh 自定義插件目錄中
打開 oh-my-zsh 配置文件
vim ~/.zshrc
在 plugins
中添加 incr
在配置文件結束添加:
source $ZSH/custom/plugins/incr/incr*.zsh
更新配置
source ~/.zshrc
最終效果如官網所示:
Homebrew:
https://brew.sh/index_zh-cn
https://github.com/Homebrew/brew
oh-my-zsh:
https://ohmyz.sh/
https://github.com/robbyrussell/oh-my-zsh
incr:
http://mimosa-pudica.net/zsh-incremental.html