From e350ab74fc7a7bba79586f39b0182c5142edc9ca Mon Sep 17 00:00:00 2001 From: "Juan G. Hurtado" Date: Thu, 28 Apr 2011 14:10:22 +0200 Subject: [PATCH] Refactors custom git functions --- themes/juanghurtado.zsh-theme | 43 ++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/themes/juanghurtado.zsh-theme b/themes/juanghurtado.zsh-theme index 4cc4d48bb..bcfb5f504 100644 --- a/themes/juanghurtado.zsh-theme +++ b/themes/juanghurtado.zsh-theme @@ -3,25 +3,6 @@ # (Needs Git plugin) # ------------------------------------------------------------------------ -# Get current commit short SHA (formatted and coloured) -function git_prompt_sha() { - sha=$(git rev-parse --short HEAD 2> /dev/null) || return - echo "%{$fg[white]%}[%{$fg[yellow]%}"$sha"%{$fg[white]%}]" -} - -# Checks if there are commits ahead from remote -function git_parse_ahead() { - if $(echo "$(git log origin/master..HEAD 2> /dev/null)" | grep '^commit' &> /dev/null); then - echo " %{$fg[red]%}(!)" - fi -} - -# Prompts -PROMPT=' -%{$fg_bold[green]%}%n@%m%{$fg[white]%}:%{$fg[yellow]%}%~%u$(parse_git_dirty)$(git_parse_ahead)%{$reset_color%} -%{$fg[blue]%}>%{$reset_color%} ' -RPROMPT='%{$fg_bold[green]%}$(current_branch) $(git_prompt_sha) $(git_prompt_status)%{$reset_color%}' - ZSH_THEME_GIT_PROMPT_PREFIX="" ZSH_THEME_GIT_PROMPT_SUFFIX="" ZSH_THEME_GIT_PROMPT_UNMERGED=" %{$fg[red]%}unmerged " @@ -29,6 +10,26 @@ ZSH_THEME_GIT_PROMPT_DELETED=" %{$fg[red]%}deleted " ZSH_THEME_GIT_PROMPT_RENAMED=" %{$fg[yellow]%}renamed " ZSH_THEME_GIT_PROMPT_MODIFIED=" %{$fg[yellow]%}modified " ZSH_THEME_GIT_PROMPT_ADDED=" %{$fg[green]%}added " -ZSH_THEME_GIT_PROMPT_UNTRACKED="" +ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[white]%}untracked " ZSH_THEME_GIT_PROMPT_DIRTY=" %{$fg[red]%}(*)" -ZSH_THEME_GIT_PROMPT_CLEAN="" \ No newline at end of file +ZSH_THEME_GIT_PROMPT_AHEAD=" %{$fg[red]%}(!)" +ZSH_THEME_GIT_PROMPT_CLEAN="" + +# Get current commit short SHA (formatted and coloured) +function git_prompt_sha() { + sha=$(git rev-parse --short HEAD 2> /dev/null) || return + echo "$sha" +} + +# Checks if there are commits ahead from remote +function git_prompt_ahead() { + if $(echo "$(git log origin/master..HEAD 2> /dev/null)" | grep '^commit' &> /dev/null); then + echo "$ZSH_THEME_GIT_PROMPT_AHEAD" + fi +} + +# Prompts +PROMPT=' +%{$fg_bold[green]%}%n@%m%{$fg[white]%}:%{$fg[yellow]%}%~%u$(parse_git_dirty)$(git_prompt_ahead)%{$reset_color%} +%{$fg[blue]%}>%{$reset_color%} ' +RPROMPT='%{$fg_bold[green]%}$(current_branch) %{$fg[white]%}[%{$fg[yellow]%}$(git_prompt_sha)%{$fg[white]%}] $(git_prompt_status)%{$reset_color%}' \ No newline at end of file