1、安裝zsh
sudo apt-get install -y zsh
2、安裝 oh my zsh
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
3莽鸿、安裝插件
- 1)高亮插件 zsh-syntax-highlighting
下載
cd ~/.oh-my-zsh/custom/plugins
git clone git://github.com/zsh-users/zsh-syntax-highlighting.git
配置:
sudo vim .zshrc
添加 zsh-autosuggestions
plugins=(
git
zsh-syntax-highlighting
)
保存退出!
然后source ~/.zshrc
- 代碼提示 zsh-autosuggestions
下載(安裝) git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
配置:
sudo vim .zshrc
添加 zsh-autosuggestions
plugins=(
git
zsh-syntax-highlighting
zsh-autosuggestions
)
保存退出!
然后source ~/.zshrc
- 3) 命令檢查 the fuck
python (3.4+) pip python-dev
安裝:
sudo apt update
sudo apt install python3-dev python3-pip
sudo pip3 install thefuck
配置:
在/.zshrc和/.bashrc 文件中添加如下代碼:
eval $(thefuck --alias)
eval $(thefuck --alias FUCK)
刷新配置文件:
在bash中執(zhí)行
source ~/.bashrc
在zsh中執(zhí)行
source ~/.zshrc
- 給某個(gè)目錄指定全局名字 wd
安裝:
cd ~/.oh-my-zsh/custom/plugins
git clone https://github.com/mfaerevaag/wd.git
配置:
sudo vim .zshrc
添加 wd
plugins=(
git
zsh-syntax-highlighting
zsh-autosuggestions
wd
)
保存退出!
然后source ~/.zshrc
使用:
在某一個(gè)目錄下如: /dev/code/shell
執(zhí)行 /dev/code/shell 簡(jiǎn)化為 sh
wd add sh
然后 查看
wd ls sh
跳轉(zhuǎn) 到/dev/code/shell
wd sh
- 5)自動(dòng)跳轉(zhuǎn) autojump
這個(gè)插件會(huì)記錄你常去的那些目錄,然后做一下權(quán)重記錄岭接,你可以用這個(gè)命令看到你的習(xí)慣:j --stat富拗,如果這個(gè)里面有你的記錄臼予,那你就只要敲最后一個(gè)文件夾名字即可進(jìn)入鸣戴,比如我個(gè)人習(xí)慣的 program:j program,就可以直接到:/usr/program
安裝:
sudo apt-get install autojump
配置:
激活 autojump 應(yīng)用
為了暫時(shí)激活 autojump 應(yīng)用粘拾,即直到你關(guān)閉當(dāng)前會(huì)話或打開(kāi)一個(gè)新的會(huì)話之前讓 autojump 均有效窄锅,你需要以常規(guī)用戶身份運(yùn)行下面的命令:
source /usr/share/autojump/autojump.sh on startup
為了使得 autojump 在 BASH shell 和ZSH中永久有效,你需要運(yùn)行下面的命令缰雇。
echo '. /usr/share/autojump/autojump.sh'>>~/.bashrc
echo '. /usr/share/autojump/autojump.sh'>>~/.zshrc
刷新配置文件:
在bash中執(zhí)行
source ~/.bashrc
在zsh中執(zhí)行
source ~/.zshrc
查看autojump的版本:
j -v
使用:
j --stat
4入偷、 主題
官網(wǎng)所有主題 https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
安裝漂亮主題 Bullet Train for oh-my-zsh
前提條件:
fonts-powerline字體 Input Mono 或者 Monoid字體(推薦第一個(gè),因?yàn)楸容^簡(jiǎn)單) 確保Ubuntu的ttf-ancient-fonts字體沒(méi)有被上面的字體覆蓋,如果覆蓋可用嘗試重新安裝ttf-ancient-fonts字體 已安裝antigen, oh-my-zsh or zgen等zsh框架 確保終端支持256色
安裝字體:
下載字體,然后直接將其移動(dòng)到/usr/share/fonts目錄下即可械哟。
下載 https://github.com/powerline/fonts
clone
git clone https://github.com/powerline/fonts.git --depth=1
install
cd fonts
./install.sh
clean-up a bit
cd ..
rm -rf fonts
安裝主題:
下載主題文件: 把下載好的主題文件放到~/.oh-my-zsh/custom/themes目錄下
cd ~/.oh-my-zsh/themes
cp bullet-train.zsh-theme ..
git clone https://github.com/caiogondim/bullet-train.zsh.git
配置:
修改~/.zshrc的ZSH_THEME參數(shù),把原來(lái)的參數(shù)注釋或者刪掉,換成下面的
ZSH_THEME="bullet-train"
保存,然后刷新.zshrc文件
source ~/.zshrc
5疏之、設(shè)置zsh為系統(tǒng)默認(rèn)shell
為root用戶修改默認(rèn)shell為zsh
chsh -s /bin/zsh root
為當(dāng)前用戶修改默認(rèn)shell為zsh
chsh -s /bin/zsh
恢復(fù)命令
chsh -s /bin/bash
6、卸載 Oh My Zsh (我覺(jué)得你會(huì)喜歡上的暇咆,不會(huì)卸載的)
卸載:終端輸入 :
uninstall_oh_my_zsh
問(wèn)題:
備注:如果使用vim編輯文件按Tab想自動(dòng)補(bǔ)全文件名的時(shí)候出現(xiàn)了
_arguments:450: _vim_files: function definition file not found
_arguments:450: _vim_files: function definition file not found
_arguments:450: _vim_files: function definition file not found
嘗試執(zhí)行命令:rm $ZSH_COMPDUMP && exec zsh
然后關(guān)閉所有終端锋爪,再打開(kāi)試試丙曙,問(wèn)題就會(huì)解決!