mac配置iTerm2

https://www.cnblogs.com/diyxiaoshitou/p/9017413.html

1、安装iTerm2

下载地址:https://www.iterm2.com/downloads.html

下载的是压缩文件,解压后是执行程序文件,你可以直接双击,或者直接将它拖到 Applications 目录下。

或者你可以直接使用 Homebrew 进行安装:

$ brew cask install iterm2

2. 配置 iTerm2 主题

iTerm2 最常用的主题是 Solarized Dark theme,下载地址:http://ethanschoonover.com/solarized

下载的是压缩文件,你先解压一下,然后打开 iTerm2,按Command + ,键,打开 Preferences 配置界面,然后Profiles -> Colors -> Color Presets -> Import,选择刚才解压的solarized->iterm2-colors-solarized->Solarized Dark.itermcolors文件,导入成功,最后选择 Solarized Dark 主题,就可以了。

3. 配置 Oh My Zsh

Oh My Zsh 是对主题的进一步扩展,地址:https://github.com/robbyrussell/oh-my-zsh

一键安装:

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

我在一键安装时遇到点问题,就直接前往https://github.com/robbyrussell/oh-my-zshgithub网站下载了压缩包ohmyzsh-master.zip,解压后cd ohmyzsh-master/tools/手动运行install.sh,这会创建~/.oh-my-zsh文件夹并在其中安装一些文件并生成~/.zshrc配置文件。

安装好之后,需要把 zsh 设置为当前用户的默认 Shell(这样新建标签的时候才会使用 zsh):

$ chsh -s /bin/zsh

然后,我们编辑vim ~/.zshrc文件,将主题配置修改为ZSH_THEME="agnoster",这个主题在安装oh-my-zsh时就自动创建在了~/.oh-my-zsh/themes/agnoster.zsh-theme,所以不必自己手动下载。

4. 配置 Meslo 字体

使用上面的主题,需要 Meslo 字体支持,要不然会出现乱码的情况,字体下载地址:[https://github.com/powerline/fonts/blob/master/Meslo Slashed/Meslo LG M Regular for Powerline.ttf]

字体Meslo LG M Regular for Powerline.ttf在Github上的地址[https://github.com/powerline/fonts/blob/master/Meslo Slashed/Meslo LG M Regular for Powerline.ttf]不提供了,我百度到https://en.m.fontke.com/font/24475517/download/可以下载,

下载好之后,直接在 Mac OS 中安装即可。

然后打开 iTerm2,按Command + ,键,打开 Preferences 配置界面,然后Profiles -> Text -> Font -> Chanage Font,选择 Meslo LG M Regular for Powerline字体。

5、声明高亮和自动建议填充

在~/.oh-my-zsh/custom/plugins克隆声明高亮插件zsh-syntax-highlighting.git与自动建议填充插件zsh-autosuggestions

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

确定一下克隆的插件名称:

然后激活这个插件,通过在

vi ~/.zshrc 

中找到plugins加入声明高亮与自动建议填充插件的名字:

plugins=(git zsh-autosuggestions zsh-syntax-highlighting)

最后当然是source一下,让改变生效

source ~/.zshrc

6、其他

上述配置下,在iTerm2选择的文本的颜色和背景色太像了不好区分,换个颜色:

前景色(文本的颜色):Preferences > Basic Colors > Foreground

选择文本的颜色:Preferences > BasicColors > Selection

背景色:Preferences > BasicColors > Background

或者我觉得Solarized Dark的配色还不如自带的Dark Background呢:

另外,~/.zshrc在agnoster主题(以及所需Meslo字体)、声明高亮和自动建议填充的指定是对zsh这个Shell作出的改动,所以也会导致Catalina10.15.6自带的zsh也使用了agnoster主题,从而也要修改自带zsh的字体,否则会有乱码显示:

系统自带zsh的背景色还可以调整透明度,还是挺美观的:

猜你喜欢

转载自blog.csdn.net/HayPinF/article/details/108337194