From 20eba4409f8addce968edbc63b40854cb61d7a57 Mon Sep 17 00:00:00 2001 From: James Laverack Date: Wed, 20 Jul 2016 00:30:18 +0100 Subject: [PATCH] Use different branch colour per branch Cyan is used for the `master` branch and yellow is used for all other branches. --- bernkastel.zsh-theme | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/bernkastel.zsh-theme b/bernkastel.zsh-theme index efc272d..e3390e9 100644 --- a/bernkastel.zsh-theme +++ b/bernkastel.zsh-theme @@ -7,18 +7,34 @@ # VCS YS_VCS_PROMPT_PREFIX1=" " -YS_VCS_PROMPT_PREFIX2=":%{$fg[cyan]%}" +YS_VCS_PROMPT_PREFIX2=":%{$fg[yellow]%}" +YS_VCS_PROMPT_PREFIX2_MASTER=":%{$fg[cyan]%}" YS_VCS_PROMPT_SUFFIX="%{$reset_color%}" YS_VCS_PROMPT_DIRTY=" %{$fg[red]%}x" YS_VCS_PROMPT_CLEAN=" %{$fg[green]%}o" # Git info -local git_info='$(git_prompt_info)' +local git_info='$(ys_git_prompt_info)' ZSH_THEME_GIT_PROMPT_PREFIX="${YS_VCS_PROMPT_PREFIX1}git${YS_VCS_PROMPT_PREFIX2}" +ZSH_THEME_GIT_PROMPT_PREFIX_MASTER="${YS_VCS_PROMPT_PREFIX1}git${YS_VCS_PROMPT_PREFIX2_MASTER}" ZSH_THEME_GIT_PROMPT_SUFFIX="$YS_VCS_PROMPT_SUFFIX" ZSH_THEME_GIT_PROMPT_DIRTY="$YS_VCS_PROMPT_DIRTY" ZSH_THEME_GIT_PROMPT_CLEAN="$YS_VCS_PROMPT_CLEAN" +# Git +ys_git_prompt_info() { + local ref + if [[ "$(command git config --get oh-my-zsh.hide-status 2>/dev/null)" != "1" ]]; then + ref=$(command git symbolic-ref HEAD 2> /dev/null) || \ + ref=$(command git rev-parse --short HEAD 2> /dev/null) || return 0 + if [ "${ref#refs/heads/}" = 'master' ]; then + echo "$ZSH_THEME_GIT_PROMPT_PREFIX_MASTER${ref#refs/heads/}$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_SUFFIX" + else + echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_SUFFIX" + fi + fi +} + # HG info local hg_info='$(ys_hg_prompt_info)' ys_hg_prompt_info() {