mac自帶zsh,zsh功能很強大但是太複雜,oh-my-zsh是zsh的一個簡化版,
zsh配置步驟如下:
1. 將bash切換爲zsh
chsh -s /bin/zsh 或者 chsh -s
which zsh
如果要切換回去:
chsh -s /bin/bash
2. 下載oh-my-zsh
git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh
3. 備份已有的zshrc(一般不需要)
cp ~/.zshrc ~/.zshrc.orig
4. 替換zshrc
cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
定製zsh別名
編輯.zshrc文件,在裏面定製常用命令的別名,例如:
alias ll=”ls -l”
alias cls=”clear”
alias -s html=mate # 在命令行直接輸入後綴爲 html 的文件名,會在 TextMate 中打開
alias -s rb=mate # 在命令行直接輸入 ruby 文件,會在 TextMate 中打開
alias -s py=vi # 在命令行直接輸入 python 文件,會用 vim 中打開,以下類似
alias -s js=vi
alias -s c=vi
alias -s java=vi
alias -s txt=vi