# 1.安装zsh和oh-my-zsh ## 安装zsh ``` sudo apt-get install -y zsh ``` ## 安装oh-my-zsh [oh-my-zsh](https://ohmyz.sh/) ``` sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" ``` # 2.将zsh设置为系统默认终端 执行这条语句: ``` chsh -s `which zsh` ``` 然后重新登录系统即可 # 3.设置主题 需要在配置文件~/.zshrc中设置 ``` ZSH_THEME="ys" ``` 重启zsh即可,或者直接更新源 ``` source ~/.zshrc ``` ## agnoster 该主题需要安装字体库 ``` sudo apt-get install fonts-powerline # 清理一下字体缓存 fc-cache -vf # 查一下字体是否生效了 fc-list ``` ## ys ## bira # 4.常见问题 ## 4.1复制卡顿 是插件autosuggest导致的,需要设置 ``` # 解决卡顿问题 # This speeds up pasting w/ autosuggest # https://github.com/zsh-users/zsh-autosuggestions/issues/238 pasteinit() { OLD_SELF_INSERT=${${(s.:.)widgets[self-insert]}[2,3]} zle -N self-insert url-quote-magic # I wonder if you'd need `.url-quote-magic`? } pastefinish() { zle -N self-insert $OLD_SELF_INSERT } zstyle :bracketed-paste-magic paste-init pasteinit zstyle :bracketed-paste-magic paste-finish pastefinish ``` 或者是git导致的需要设置 ``` git config --global oh-my-zsh.hide-status 1 ``` ## 4.2没有自动补全插件 1. 没有[incr](https://mimosa-pudica.net/zsh-incremental.html)插件该插件需要手动下载 2. 然后进入oh-my-zsh插件文件夹,路径为~/.oh-my-zsh/plugins/ 3. 然后在/.oh-my-zsh/plugins/incr路径下执行终端指令 ``` source incr*.zsh ``` 4. 末尾添加 ``` # 自动补全插件 source ~/.oh-my-zsh/plugins/incr/incr*.zsh ``` 5. 最后更新源 ``` source ~/.zshrc ``` ## 4.3没有自动建议插件 1. 该插件也需要手动下载[zsh-autosuggestions](https://github.com/zsh-users/zsh-autosuggestions) 注:该插件默认安装在/home/seamew/.oh-my-zsh/custom/plugins 目录下,需要将它移动到/home/seamew/.oh-my-zsh/plugins目录 2. 设置`~/.zshrc`,把`zsh-autosuggestions`添加到 Oh My Zsh 要加载的插件列表中 ``` # 这里也添加了mvn插件 plugins=(git zsh-autosuggestions mvn) ``` 3. 最后更新源 ``` source ~/.zshrc ``` ## 4.4代码高亮 插件地址[sh-syntax-highlighting](https://github.com/zsh-users/zsh-syntax-highlighting) 安装方法与4.3一样,不再赘述 ## 4.5自动补全功能 插件地址[zsh-completions](https://github.com/zsh-users/zsh-completions) ## 4.6环境变量不生效 需要在配置.zshrc中添加对应的设置