首先安装好 zsh
apt install -y zsh git
然后把 oh my zsh 克隆到本地,因为我的国内服务器访问不到github,所以要改一下地址,改成cnpm的加速镜像地址
git clone https://github.com.cnpmjs.org/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh
复制 .zshrc 配置文件
cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
更改zsh 为默认 shell
chsh -s $(which zsh)
配置主题
更改 .zshrc 文件,ZSH_THEME=robbyrussell 处,主题列表:Themes · ohmyzsh/ohmyzsh Wiki
如果打不开网页,可以把 github.com 换成 hub.fastgit.org/
配置插件
oh my zsh 默认带了很多插件都在,~/.oh-my-zsh/plugins 目录下,但默认都没启用
在 .zshrc 文件中修改
plugins=(git debian)
字段来启用,比如上面就是启用了git 和 debian 插件
所有插件的列表和说明可以在 Plugins · ohmyzsh/ohmyzsh Wiki 看到
比如 debian 插件提供了一些 alias 。 在 ohmyzsh/plugins/debian at master · ohmyzsh/ohmyzsh · GitHub 可以看到
age | apt-get | Command line tool for handling packages |
api | aptitude | Same functionality as apt-get , provides extra options |
acs | apt-cache search | Command line tool for searching apt software package cache |
aps | aptitude search | Searches installed packages using aptitude |
as | aptitude -F '* %p -> %d \n(%v/%V)' --no-gui --disable-columns search | Print searched packages using a custom format |
afs | apt-file search --regexp | Search file in packages |
asrc | apt-get source | Fetch source packages through apt-get |
app | apt-cache policy | Displays priority of package sources |
无论是修改了主题还是插件,都要执行 source .zshrc 来让配置生效。