安装 ZSH
首先使用 cat /etc/shells 查看是否有 ZSH
$ cat /etc/shells# /etc/shells: valid login shells/bin/sh/bin/bash/bin/rbash/bin/dash/usr/bin/tmux
可以看到并没有 ZSH ,可以通过 apt 来安装
$ apt install -y zsh
下载完成可以通过查看 /etc/shells 文件来确定 ZSH 是否安装上。
安装 oh-my-zsh
为了使 zsh 更方便使用,可以安装插件 oh-my-zsh :
$ wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | sh
因为是访问的 Github 网站,所以该命令可能会失败,多试几次就行了
安装 oh-my-zsh 插件
$ git clone https://github.com/zsh-users/zsh-completions ~/.oh-my-zsh/custom/plugins/zsh-completions$ git clone git://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions$ git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
使用 ZSH
查看当前使用的 SHELL
查看 $SHELL 变量来查看现在使用的 SHELL
$ echo $SHELL/bin/bash
可以看到我现在是 bash
切换 SHELL
chsh 可以切换登录环境的 SHELL
$ chsh -s /usr/bin/zsh
至此,重启 terminal shell 就切换到了 Zsh
oh-my-zsh
可以修改家目录下的 .zshrc 来配置你的 ZSH
修改 oh-my-zsh 中 agnoster 的主题样式
- 进入 oh-my-zsh 的主题文件:
$ cd ~/.oh-my-zsh/themes
- 修改
agnoster.zsh-theme文件
@@ -248,7 +248,7 @@ build_prompt() {prompt_statusprompt_virtualenvprompt_aws- prompt_context+ # prompt_contextprompt_dirprompt_gitprompt_bzr@@ -256,4 +256,5 @@ build_prompt() {prompt_end}-PROMPT='%{%f%b%k%}$(build_prompt) '+PROMPT='$(build_prompt) '+#PROMPT='%{%f%b%k%}$(build_prompt) '
