zsh配置

原本用WindTerm+bash,WindTerm提供了高亮、自动记忆补全等功能,基本上也够用。WindTerm还是比较早期阶段,功能细节上还有待完善,稳定性方面也有些小问题。比如用vi或者一些文本操作界面的程序时界面可能会显示乱掉;查看日志等文本文件,有些不能正常显示的字符会导致界面显示乱码,需要重新进入才能恢复。仍然非常推荐WindTerm。

Terminator供强大,也很稳定,只是界面上不如WindTerm好看、好用(文本高亮在开发中有助于提高效率)。期待WindTerm尽快完善,WindTerm+zsh让shell使用体验更上一个台阶。

zsh的可扩展性好很多,有很多现成的配置插件,也可以把bash上原有的自定义配置直接平移过来,在.zshrc中source原有的自定义设置,source ~/.bash_aliases(如果是source ~/.bashrc,需要注意避免可能冲突。在bash中我把所有自定义变量都放到.bash_aliases中,这个文件会被.bashrc自动加载。把.bash_aliases保存下来,每次重装系统直接复制过来就可以了。)

安装zsh

sudo apt-get install zsh

安装几个常用插件

git clone https://github.com/zsh-users/zsh-autosuggestions.git ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions

git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ~/.oh-my-zsh/custom/plugins/zsh-syntax-highlighting\n

git clone https://github.com/joelthelion/autojump.git $ZSH_CUSTOM/plugins/autojump\n
cd .oh-my-zsh/custom/plugins/autojump/install.py
./install.py 
Installing autojump to /home/dev/.autojump ...
creating directory: /home/dev/.autojump/bin
creating directory: /home/dev/.autojump/share/man/man1
creating directory: /home/dev/.autojump/etc/profile.d
creating directory: /home/dev/.autojump/share/autojump
copying file: ./bin/autojump -> /home/dev/.autojump/bin
copying file: ./bin/autojump_argparse.py -> /home/dev/.autojump/bin
copying file: ./bin/autojump_data.py -> /home/dev/.autojump/bin
copying file: ./bin/autojump_match.py -> /home/dev/.autojump/bin
copying file: ./bin/autojump_utils.py -> /home/dev/.autojump/bin
copying file: ./bin/icon.png -> /home/dev/.autojump/share/autojump
copying file: ./docs/autojump.1 -> /home/dev/.autojump/share/man/man1
creating directory: /home/dev/.autojump/etc/profile.d
creating directory: /home/dev/.autojump/share/autojump
creating directory: /home/dev/.autojump/functions
copying file: ./bin/autojump.sh -> /home/dev/.autojump/etc/profile.d
copying file: ./bin/autojump.bash -> /home/dev/.autojump/share/autojump
copying file: ./bin/autojump.fish -> /home/dev/.autojump/share/autojump
copying file: ./bin/autojump.zsh -> /home/dev/.autojump/share/autojump
copying file: ./bin/_j -> /home/dev/.autojump/functions

Please manually add the following line(s) to ~/.bashrc:

        [[ -s /home/dev/.autojump/etc/profile.d/autojump.sh ]] && source /home/dev/.autojump/etc/profile.d/autojump.sh

Please restart terminal(s) before running autojump.

编辑.zshrc文件
plugins中默认只有git,增加zsh-autosuggestions和autojump

 73 plugins=(
 74   git
 75   zsh-autosuggestions
 76   autojump
 77 )

在.zshrc最后添加autojump插件的设置脚本
下面这一项上上面autojump插件,执行install.py后最后的输出,可以参见上面的输出结果,提示添加到.zshrc最后

109 [[ -s /home/dev/.autojump/etc/profile.d/autojump.sh ]] && source /home/dev/.autojump/etc/profile.d/autojump.sh

如果需要,还可以添加自定义的shell配置

108 source ~/.bash_aliases

完成后退出编辑器。在当前zsh中执行:

source ~/.zshrc

或者重启当前shell终端,上述设置就可以生效了。
一起和zsh愉快的玩耍吧。

猜你喜欢

转载自blog.csdn.net/yinminsumeng/article/details/129141098
zsh
今日推荐