分享一个自用的zsh主题

Posted Mculover666

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了分享一个自用的zsh主题相关的知识,希望对你有一定的参考价值。

intheloop主题

本主题基于已有主题 intheloop 主题修改,先设置使用intheloop主题。

vim ~/.zshrc

原有的 intheloop 主题挺符合我的风格,但是通过ssh登录后主机名和用户名是红色的,看着有点不爽:

索性修改一下主题,让它更符合我的审美一点。

修改主题

编辑主题文件:

vim ~/.oh-my-zsh/themes/intheloop.zsh-theme

修改ssh登录后用户名和主机名为绿色:

去掉主机名和用户名外层的中括号[ ],删除图中标记的这对中括号即可:

保存退出,主题生效:

source .zshrc

修改后的主题效果

修改后的主题文件源码

文件:~/.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)"

以上是关于分享一个自用的zsh主题的主要内容,如果未能解决你的问题,请参考以下文章

分享自用博客园主题样式

开发工具分享(2019新年快乐)

zsh主题推荐

IDEA好看的主题(自用)

博客主题自用主题备份 (SimpleMemory DIY)

oh-my-zsh