Skip to main content

myzsh 安装与配置

Check the env

cat /etc/shells 

Install zsh

sudo apt-get install zsh
## replace zsh as default shell manager
sudo chsh -s $(which zsh) $USER

Install oh-my-zsh

sudo apt-get install wget
sudo apt-get install git

wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | sh

Install plugin


git clone https://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions

git clone https://github.com/zsh-users/zsh-syntax-highlighting.git $ZSH_CUSTOM/plugins/zsh-syntax-highlighting

Edit myzsh theme

vim ~/.zshrc
##add plugin
plugins=(git zsh-autosuggestions zsh-syntax-highlighting)
### select a theme
ZSH_THEME="ys"
source ~/.zshrc 

Install autojump

sudo apt-get install autojump

# add autojump.zsh in .zshrc
. /usr/share/autojump/autojump.zsh




oh-my-zsh 在 git 目录下执行命令会卡顿明显,简单的 cdls 都会。

原因:

插件会读取 git 的配置信息,如果项目目录下有太多的文件,卡顿会非常明显。可以使用以下命令禁止 zsh 自动获取 git 信息,解决卡顿问题:

解决:
  1. 设置 oh-my-zsh 不读取文件变化信息
    git config --add oh-my-zsh.hide-dirty 1
  2. 设置 oh-my-zsh 不读取任何 git 信息
    git config --add oh-my-zsh.hide-status 1
  3. 全局设置 oh-my-zsh 不读取文件变化信息
    git config --global oh-my-zsh.hide-dirty 1
  4. 全局设置 oh-my-zsh 不读取任何 git 信息
    git config --global oh-my-zsh.hide-status 1