iTerm Color Schemes
iTerm2 自带的配色有限,iTerm Color Schemes 提供了大量的配色方案。
将 iTerm Color Schemes 代码下载好之后,在 iTerms 中键入 ⌘+i,调出配置窗口。然后进入 Colors 选项卡,点击 Color Presets 选择 Import:

然后进入下载好的 iTerm Color Schemes 代码文件夹的 schemes 目录,找到你想要的 ``.itermcolors 导入即可。
oh-my-zsh
oh-my-zsh 为 zsh 提供很多的插件和模板,使用起来会更舒服。
oh-my-zsh 的 官方仓库 有更详细的介绍。
官网给出了三种安装方法,如果因为网络原因安装不成功,可以下载 git 仓库,然后手动执行 tools/install.sh 安装。
CURL sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
WGET sh -c "$(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
FETCH sh -c "$(fetch -o - https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
安装成功:

agnoster
oh-my-zsh 默认的主题是 robbyrussell,我们可以替换成各种自己喜欢的主题。可以在 官方截图 预览这些主题,然后找到自己喜欢的设置。
如果主题设成 agnoster,只需修改 ~/.zshrc 中的配置即可:

执行 .zshrc 生效配置:
source ~/.zshrc
然后就遇到了问题,乱码了:
这是因为模板中使用了非 ascii 编码的文字,而终端的字体不能将其识别出来。那就安装一个支持非 ascii 编码的字体。这里选择的是 Powerline fonts,按照官网的方法一步一步执行即可:
# clone
git clone https://github.com/powerline/fonts.git --depth=1
# install
cd fonts
./install.sh
# clean-up a bit
cd ..
rm -rf fonts
安装字体为 Meslo LG L DZ for Powerline,L、M、S 分别对应字体的 大、 中、 小:

同样需要在 General 选项卡中点击 Copy Current Settings to Selected Profile 按钮全局生效:
新版本的iterm2,暂时没找到这个选项
现在已经基本正常显示了,美中不足的是主机名和路径过长,看起来不是很舒服:

编辑主题的配置文件 ~/.oh-my-zsh/themes/agnoster.zsh-theme:
vim ~/.oh-my-zsh/themes/agnoster.zsh-theme
将 prompt_dir 函数中的 prompt_segment blue $CURRENT_FG ‘%~’ 修改为 prompt_segment blue $CURRENT_FG '%c’,这样只会显示最外层的路径:

然后将 prompt_context 中的 prompt_segment black default "%(!.%{%F{yellow}%}.)%n@%m” 修改为 prompt_segment black default "%(!.%{%F{yellow}%}.)%n:

执行 .zshrc 生效配置:
source .zshrc
就配置完成了:

2411

被折叠的 条评论
为什么被折叠?



