gdx 发表于 2017-7-6 14:44:27

Mac iTerm with Powerline

  1. 下载iTerm
  地址: http://www.iterm2.com/
  完全可以取代Mac自带的终端了。
  2. 之前我装过oh-my-zsh

git clone git://github.com/Lokaltog/powerline.git

  编辑我的~/.zshrc文件,
  ZSH_THEME="powerline"#改成这个,然后source ~/.zshrc
  3. 需要字体支持,否则那个尖角你要显示成乱码了
  git clone https://github.com/powerline/fonts.git ~/powerline-fonts
  需要Install。
  在iTerm里面选择你喜欢的字体。
  4. 为什么那个路径那么长?
  哦,得装powerline-shell,是一个Python写的,支持Python2和3。
  参考这里也可以:https://linux.cn/article-5249-1.html
  但是我是git clone的,流程as https://github.com/banga/powerline-shell
  5. 但是对于我个人来说,shell上面的username, 和host都是意义不大的
  我还不知道我是healer吗?那个时间就更没用了。
  所以,改配置吧:
  我在 ~/.ohmyzsh-powerlinecd/powerline.zsh-theme 里面加入
  POWERLINE_RIGHT_A="exit-status-on-fail" # 这个改动不是必要的。
  POWERLINE_DISABLE_RPROMPT="Hide" #我觉得右侧的时间显示没啥意思,而且当分屏的时候,没那么多地方。
  我本机的hostname太长了,想去掉,发现该这个文件是没用的。因为被powerline-shell处理了。
  改~/powerline-shell.py
  搜add_username_segment和add_hostname_segment,
  最后我选择只留着healer这个显示吧。
  6. 路径依然很长
  如果你cd的路径过长,也会很不爽,powerline-shell.py中的这里我也修改了:
  def split_path_into_names: ####



    # Healer added: only remain last 2 path parts
if len(names) > 3:
return ['..'] + names[-2:]
else:
return names
  此外:
  这个代码放到你的.zshrc里面:



function powerline_precmd() {
export PS1="$(~/powerline-shell.py $? --shell zsh 2> /dev/null)"
}
function install_powerline_precmd() {
for s in "${precmd_functions[@]}"; do
if [ "$s" = "powerline_precmd" ]; then
return
fi
done
precmd_functions+=(powerline_precmd)
}
install_powerline_precmd
  7. VIM也支持Solarized dark的Theme
  简单的做法就是:
  cd到~/.vim/bundle
  1. git clone git://github.com/altercation/vim-colors-solarized.git
  2. 然后把colors/solarized.vim copyTo ~/.vim/colors下面,
  修改~/.vimrc
  加入:
  syntax enable
set background=dark
colorscheme solarized
  OK了。
  最后的效果是这样的:
页: [1]
查看完整版本: Mac iTerm with Powerline