- 安裝 zsh
- Mac 自帶
- Ubuntu
sudo apt-get install zsh
- sudo chsh -s $(which zsh)設置zsh為默認shell
- 注銷后再進入終端可以看到效果
- 安裝 oh-my-zsh
自動安裝 wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | sh 手動安裝: 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 “ # 關鍵字加顏色
alias -s html=vi # 終端輸入 yy.html 自動 vim 打開,以下一樣
alias -s py=vi
alias -s js=vi
alias -s txt=vi
alias -s gz=’tar -xzvf’ # 終端輸入 yy.gz 自動解壓,以下一樣
alias -s tgz=’tar -xzvf’
alias -s zip=’unzip’
alias -s bz2=’tar -xjvf’
別名
zsh插件
- git 自帶
-
wd
plugins=(... wd) 比如我們有一個常用的目錄 /usr/nginx/www/html,我們首先進入到這個目錄中,然后輸入 wd add web 這個命令相當于給當前目錄做了一個標識,標識名叫做 web ,我們下次如果再想進入這個目錄,只需輸入: wd web 這樣就可以完成目錄切換了,非常方便。 它的原理并不復雜,它維護了一個標識和實際路徑的映射表,我們使用 wd add 命令可以添加新的映射,可以使用 wd rm 命令刪除已有的映射,還可以使用 wd show 命令查看現有的映射。 這個簡單的插件解決了一個很實際的問題,推薦使用。 wd 插件的更多內容可以查看它的 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
跳轉到文件夾 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)激活,高亮顯示命令,錯誤會顯示紅色git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
- Mac 安裝