分享一个自用的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)"

猜你喜欢

转载自blog.csdn.net/Mculover666/article/details/125623304