使用item2+oh my zsh优化终端体验

时间:2022-07-23
本文章向大家介绍使用item2+oh my zsh优化终端体验,主要内容包括其使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

不习惯使用terminal,于是使用了item2搭配oh my zsh ,下面是效果图

效果图

item2官网

oh my zsh官网

item2是干嘛的

item2是item的升级版,是terminal的替代品,支持mac os 10.12以上的版本

安装item2

brew cask install iterm2

oh-my-zsh的安装

sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

如下提示,我们修改默认shell为zsh,选择Y

出现下面的画面以后,就装好了哦

之后我们按照上面提示,修改.zshrc文件,使用如下命令

vim ~/.zshrc

编辑区进行主题和其他配置的设置。下面修改一下默认主题,这里有很多主题可以选择,下面我们修改主题为agnoster,替换robbyrussellagnoster

修改好了以后,重启item2发现出现乱码,是因为缺少Meslo LG M Regular for Powerline字体的原因,点击这里下载字体,下载完了以后,把这个文件放入到下面文件夹内就好了

/System/Library/Fonts

文件放入进去以后,我们打开item2,使用command+,进入设置界面,如下配置就好了

声明高亮插件

安装zsh-syntax-highlighting插件,当遇到特殊命令和错误命令时会有高亮,需要使用Homebrew安装:

brew install zsh-syntax-highlighting

安装成功之后,使用命令vim ~/.zshrc进入编辑,找到plugins增加zsh-syntax-highlighting,并在最后一行增加下面配置:

source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh

方法二

如果出现下面这种情况zsh-syntax-highlighting not found,我们使用git方法下载文件,重新启动item2就好了

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

自动建议填充

和高亮一样,将文件使用git克隆下来以后,添加plugins插件zsh-autosuggestions就好了,配置好了以后,终端会自动帮我补全路径,挺好用的

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

item2快捷命令

command + t          新建标签
command + w          关闭标签
command + 数字 command + 左右方向键    切换标签
command + enter      切换全屏
command + f          查找
command + d          垂直分屏
command + shift + d  水平分屏
command + option + 方向键 command + [ 或 command + ]    切换屏幕
command + ;          查看历史命令
command + shift + h  查看剪贴板历史
Control + u          清除当前行
Control + l          清屏
Control + a          到行首
Control + e          到行尾
Control + f/b            前进后退
Control + p          上一条命令
Control + r          搜索命令历史