- 安裝 zsh
- Mac 自帶
- Ubuntu
sudo apt-get install zsh
- sudo chsh -s $(which zsh)設(shè)置zsh為默認(rèn)shell
- 注銷后再進(jìn)入終端可以看到效果
- 安裝 oh-my-zsh
自動(dòng)安裝 wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | sh 手動(dòng)安裝: git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
- 主題和別名
- 主題在 ~/.oh-my-zsh/themes下
- 主題文件中的 PROMPT 改成如下
PROMPT='%{$fg_bold[red]%}? %{$fg_bold[green]%}%p%{$fg[cyan]%}%d %{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%}% %{$reset_color%}>'
樣式 - 別名
alias zshconfig=”vim ~/.zshrc”
alias cls=’clear’
alias ll=’ls -l’
alias la=’ls -a’
alias vi=’vim’
alias grep=”grep –color=auto “ # 關(guān)鍵字加顏色
alias -s html=vi # 終端輸入 yy.html 自動(dòng) vim 打開,以下一樣
alias -s py=vi
alias -s js=vi
alias -s txt=vi
alias -s gz=’tar -xzvf’ # 終端輸入 yy.gz 自動(dòng)解壓,以下一樣
alias -s tgz=’tar -xzvf’
alias -s zip=’unzip’
alias -s bz2=’tar -xjvf’
別名
zsh插件
- git 自帶
-
wd
plugins=(... wd) 比如我們有一個(gè)常用的目錄 /usr/nginx/www/html,我們首先進(jìn)入到這個(gè)目錄中,然后輸入 wd add web 這個(gè)命令相當(dāng)于給當(dāng)前目錄做了一個(gè)標(biāo)識,標(biāo)識名叫做 web ,我們下次如果再想進(jìn)入這個(gè)目錄,只需輸入: wd web 這樣就可以完成目錄切換了,非常方便。 它的原理并不復(fù)雜,它維護(hù)了一個(gè)標(biāo)識和實(shí)際路徑的映射表,我們使用 wd add 命令可以添加新的映射,可以使用 wd rm 命令刪除已有的映射,還可以使用 wd show 命令查看現(xiàn)有的映射。 這個(gè)簡單的插件解決了一個(gè)很實(shí)際的問題,推薦使用。 wd 插件的更多內(nèi)容可以查看它的 github 主頁: https://github.com/mfaerevaag/wd
-
autojump
- Mac 安裝
brew install autojump
plugins=(... autojump) - 其他平臺
plugins=(... autojump)git clone git://github.com/joelthelion/autojump.git cd autojump ./install.py or ./uninstall.py
- usage
跳轉(zhuǎn)到文件夾 j foo
- Mac 安裝
-
zsh-syntax-highlighting
- Mac 安裝
brew install zsh-syntax-highlighting 把 source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh 加入. zshrc
- 其他平臺
然后在 plugins=(... zsh-syntax-highlighting)激活,高亮顯示命令,錯(cuò)誤會顯示紅色git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
- Mac 安裝