分享一个自用的zsh主题
原创
©著作权归作者所有:来自51CTO博客作者MCUlover666的原创作品,请联系作者获取转载授权,否则将追究法律责任
intheloop主题
本主题基于已有主题 intheloop 主题修改,先设置使用intheloop主题。
原有的 intheloop 主题挺符合我的风格,但是通过ssh登录后主机名和用户名是红色的,看着有点不爽:
索性修改一下主题,让它更符合我的审美一点。
修改主题
编辑主题文件:
修改ssh登录后用户名和主机名为绿色:
去掉主机名和用户名外层的中括号[ ]
,删除图中标记的这对中括号即可:
保存退出,主题生效:
修改后的主题效果
修改后的主题文件源码
文件:~/.oh-my-zsh/themes/intheloop.zsh-theme。
内容:
# A multiline prompt with username, hostname, full path, return status, git branch, git dirty status, git remote status
local return_status="%{$fg[red]%}%(?..?)%{$reset_color%}"
local host_color="green"
if [ -n "$SSH_CLIENT" ]; then
local host_color="green"
fi
PROMPT='
%{$fg_bold[grey]%}%{$reset_color%}%{$fg_bold[${host_color}]%}%n@%m%{$reset_color%}%{$fg_bold[grey]%}%{$reset_color%} %{$fg_bold[blue]%}%10c%{$reset_color%} $(git_prompt_info) $(git_remote_status)
%{$fg_bold[cyan]%}?%{$reset_color%} '
RPROMPT='${return_status}%{$reset_color%}'
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[grey]%}(%{$fg[red]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[grey]%}) %{$fg[yellow]%}?%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[grey]%})"
ZSH_THEME_GIT_PROMPT_BEHIND_REMOTE="%{$fg_bold[magenta]%}↓%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE="%{$fg_bold[magenta]%}↑%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DIVERGED_REMOTE="%{$fg_bold[magenta]%}?%{$reset_color%}"
附:安装命令
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"