From 714cfb1db2966ddfc0330a09e620164189233b49 Mon Sep 17 00:00:00 2001 From: Adam Lindberg Date: Tue, 31 May 2011 11:46:26 +0200 Subject: [PATCH 1/9] Add guru theme --- themes/guru.zsh-theme | 98 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 themes/guru.zsh-theme diff --git a/themes/guru.zsh-theme b/themes/guru.zsh-theme new file mode 100644 index 000000000..2a2223528 --- /dev/null +++ b/themes/guru.zsh-theme @@ -0,0 +1,98 @@ +#------------------------------------------------------------------------------- +# Guru theme for oh-my-zsh by Adam Lindberg +# (Needs Git plugin for current_branch method) +#------------------------------------------------------------------------------- + + +# Color shortcuts +R=$fg[red] +Y=$fg[yellow] +G=$fg[green] +M=$fg[magenta] +W=$fg[white] +B=$fg[black] +RB=$fg_bold[red] +YB=$fg_bold[yellow] +GB=$fg_bold[green] +MB=$fg_bold[magenta] +WB=$fg_bold[white] +BB=$fg_bold[black] +RESET=$reset_color + +if [ "$(whoami)" = "root" ]; then + PROMPTCOLOR="%{$RB%}" PREFIX="-!-"; +else + PROMPTCOLOR="%{$BB%}" PREFIX="---"; +fi + +local return_code="%(?..%{$R%}%? ↵%{$RESET%})" + +GIT_PREFIX="%{$YB%}‹" +GIT_SUFFIX="%{$YB%}›" + +# Get the status of the working tree (copied and modified from git.zsh) +custom_git_prompt_status() { + INDEX=$(git status --porcelain 2> /dev/null) + STATUS="" + # Non-staged + if $(echo "$INDEX" | grep '^?? ' &> /dev/null); then + STATUS="$ZSH_THEME_GIT_PROMPT_UNTRACKED$STATUS" + fi + if $(echo "$INDEX" | grep '^UU ' &> /dev/null); then + STATUS="$ZSH_THEME_GIT_PROMPT_UNMERGED$STATUS" + fi + if $(echo "$INDEX" | grep '^ D ' &> /dev/null); then + STATUS="$ZSH_THEME_GIT_PROMPT_DELETED$STATUS" + fi + if $(echo "$INDEX" | grep '^ M ' &> /dev/null); then + STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS" + elif $(echo "$INDEX" | grep '^AM ' &> /dev/null); then + STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS" + elif $(echo "$INDEX" | grep '^ T ' &> /dev/null); then + STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS" + fi + # Staged + if $(echo "$INDEX" | grep '^D ' &> /dev/null); then + STATUS="$ZSH_THEME_GIT_PROMPT_STAGED_DELETED$STATUS" + fi + if $(echo "$INDEX" | grep '^R ' &> /dev/null); then + STATUS="$ZSH_THEME_GIT_PROMPT_STAGED_RENAMED$STATUS" + fi + if $(echo "$INDEX" | grep '^M ' &> /dev/null); then + STATUS="$ZSH_THEME_GIT_PROMPT_STAGED_MODIFIED$STATUS" + fi + if $(echo "$INDEX" | grep '^A' &> /dev/null); then + STATUS="$ZSH_THEME_GIT_PROMPT_STAGED_ADDED$STATUS" + fi + echo $STATUS +} + +# get the name of the branch we are on (copied and modified from git.zsh) +function custom_git_prompt() { + ref=$(git symbolic-ref HEAD 2> /dev/null) || return + echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(git_prompt_ahead)$(parse_git_dirty)$(custom_git_prompt_status)$ZSH_THEME_GIT_PROMPT_SUFFIX" +} + +PROMPT='${PROMPTCOLOR}$PREFIX %2~ $(custom_git_prompt)%{$M%}%B»%b%{$RESET%} ' +RPS1="${return_code}" + +ZSH_THEME_GIT_PROMPT_PREFIX="%{$YB%}‹" +ZSH_THEME_GIT_PROMPT_SUFFIX="%{$YB%}›%{$RESET%} " + +ZSH_THEME_GIT_PROMPT_AHEAD="%{$BB%}➝" + +# Staged +ZSH_THEME_GIT_PROMPT_STAGED_ADDED="%{$G%}A" +ZSH_THEME_GIT_PROMPT_STAGED_MODIFIED="%{$G%}M" +ZSH_THEME_GIT_PROMPT_STAGED_RENAMED="%{$G%}R" +ZSH_THEME_GIT_PROMPT_STAGED_DELETED="%{$G%}D" + +# Not-staged +ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$R%}??" +ZSH_THEME_GIT_PROMPT_MODIFIED="%{$R%}M" +ZSH_THEME_GIT_PROMPT_DELETED="%{$R%}D" +ZSH_THEME_GIT_PROMPT_UNMERGED="%{$R%}UU" + +ZSH_THEME_GIT_PROMPT_DIRTY="%{$R%}* " + +ZSH_THEME_GIT_PROMPT_CLEAN="" From 9c306670a73ec3e313666fc497952153bdc16220 Mon Sep 17 00:00:00 2001 From: Adam Lindberg Date: Tue, 31 May 2011 14:07:38 +0200 Subject: [PATCH 2/9] Improve unicode characters and git status --- themes/guru.zsh-theme | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/themes/guru.zsh-theme b/themes/guru.zsh-theme index 2a2223528..c63f1082a 100644 --- a/themes/guru.zsh-theme +++ b/themes/guru.zsh-theme @@ -64,13 +64,18 @@ custom_git_prompt_status() { if $(echo "$INDEX" | grep '^A' &> /dev/null); then STATUS="$ZSH_THEME_GIT_PROMPT_STAGED_ADDED$STATUS" fi + + if $(echo "$STATUS" &> /dev/null); then + STATUS="$ZSH_THEME_GIT_STATUS_PREFIX$STATUS" + fi + echo $STATUS } # get the name of the branch we are on (copied and modified from git.zsh) function custom_git_prompt() { ref=$(git symbolic-ref HEAD 2> /dev/null) || return - echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(git_prompt_ahead)$(parse_git_dirty)$(custom_git_prompt_status)$ZSH_THEME_GIT_PROMPT_SUFFIX" + echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(parse_git_dirty)$(git_prompt_ahead)$(custom_git_prompt_status)$ZSH_THEME_GIT_PROMPT_SUFFIX" } PROMPT='${PROMPTCOLOR}$PREFIX %2~ $(custom_git_prompt)%{$M%}%B»%b%{$RESET%} ' @@ -79,7 +84,12 @@ RPS1="${return_code}" ZSH_THEME_GIT_PROMPT_PREFIX="%{$YB%}‹" ZSH_THEME_GIT_PROMPT_SUFFIX="%{$YB%}›%{$RESET%} " -ZSH_THEME_GIT_PROMPT_AHEAD="%{$BB%}➝" +ZSH_THEME_GIT_PROMPT_DIRTY="%{$R%}*" +ZSH_THEME_GIT_PROMPT_CLEAN="" + +ZSH_THEME_GIT_PROMPT_AHEAD="%{$BB%}➔" + +ZSH_THEME_GIT_STATUS_PREFIX=" " # Staged ZSH_THEME_GIT_PROMPT_STAGED_ADDED="%{$G%}A" @@ -88,11 +98,7 @@ ZSH_THEME_GIT_PROMPT_STAGED_RENAMED="%{$G%}R" ZSH_THEME_GIT_PROMPT_STAGED_DELETED="%{$G%}D" # Not-staged -ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$R%}??" +ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$R%}⁇" ZSH_THEME_GIT_PROMPT_MODIFIED="%{$R%}M" ZSH_THEME_GIT_PROMPT_DELETED="%{$R%}D" ZSH_THEME_GIT_PROMPT_UNMERGED="%{$R%}UU" - -ZSH_THEME_GIT_PROMPT_DIRTY="%{$R%}* " - -ZSH_THEME_GIT_PROMPT_CLEAN="" From a9b6f081b4a405dd1365df9c35aa3603196e3fc7 Mon Sep 17 00:00:00 2001 From: Adam Lindberg Date: Wed, 1 Jun 2011 10:11:06 +0200 Subject: [PATCH 3/9] Remove extra space when no status --- themes/guru.zsh-theme | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/themes/guru.zsh-theme b/themes/guru.zsh-theme index c63f1082a..aa7b28b34 100644 --- a/themes/guru.zsh-theme +++ b/themes/guru.zsh-theme @@ -27,9 +27,6 @@ fi local return_code="%(?..%{$R%}%? ↵%{$RESET%})" -GIT_PREFIX="%{$YB%}‹" -GIT_SUFFIX="%{$YB%}›" - # Get the status of the working tree (copied and modified from git.zsh) custom_git_prompt_status() { INDEX=$(git status --porcelain 2> /dev/null) @@ -65,7 +62,7 @@ custom_git_prompt_status() { STATUS="$ZSH_THEME_GIT_PROMPT_STAGED_ADDED$STATUS" fi - if $(echo "$STATUS" &> /dev/null); then + if $(echo -n "$STATUS" | grep '.*' &> /dev/null); then STATUS="$ZSH_THEME_GIT_STATUS_PREFIX$STATUS" fi From 70cb607b7bee04ceef74d6f7aa80589e009e4c78 Mon Sep 17 00:00:00 2001 From: Adam Lindberg Date: Tue, 7 Jun 2011 15:28:43 +0200 Subject: [PATCH 4/9] Remove unused colors and use original prompt color --- themes/guru.zsh-theme | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/themes/guru.zsh-theme b/themes/guru.zsh-theme index aa7b28b34..b99cd816e 100644 --- a/themes/guru.zsh-theme +++ b/themes/guru.zsh-theme @@ -6,23 +6,17 @@ # Color shortcuts R=$fg[red] -Y=$fg[yellow] G=$fg[green] M=$fg[magenta] -W=$fg[white] -B=$fg[black] RB=$fg_bold[red] YB=$fg_bold[yellow] -GB=$fg_bold[green] -MB=$fg_bold[magenta] -WB=$fg_bold[white] -BB=$fg_bold[black] +BB=$fg_bold[blue] RESET=$reset_color if [ "$(whoami)" = "root" ]; then PROMPTCOLOR="%{$RB%}" PREFIX="-!-"; else - PROMPTCOLOR="%{$BB%}" PREFIX="---"; + PROMPTCOLOR="" PREFIX="---"; fi local return_code="%(?..%{$R%}%? ↵%{$RESET%})" @@ -75,7 +69,8 @@ function custom_git_prompt() { echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(parse_git_dirty)$(git_prompt_ahead)$(custom_git_prompt_status)$ZSH_THEME_GIT_PROMPT_SUFFIX" } -PROMPT='${PROMPTCOLOR}$PREFIX %2~ $(custom_git_prompt)%{$M%}%B»%b%{$RESET%} ' +# %B sets bold text +PROMPT='%B$PREFIX %2~ $(custom_git_prompt)%{$M%}%B»%b%{$RESET%} ' RPS1="${return_code}" ZSH_THEME_GIT_PROMPT_PREFIX="%{$YB%}‹" From 915c28752eb8bfb9610e14f62161ab3bd573d218 Mon Sep 17 00:00:00 2001 From: Adam Lindberg Date: Tue, 7 Jun 2011 15:32:48 +0200 Subject: [PATCH 5/9] Add email address --- themes/guru.zsh-theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/guru.zsh-theme b/themes/guru.zsh-theme index b99cd816e..cbd56194f 100644 --- a/themes/guru.zsh-theme +++ b/themes/guru.zsh-theme @@ -1,5 +1,5 @@ #------------------------------------------------------------------------------- -# Guru theme for oh-my-zsh by Adam Lindberg +# Guru theme for oh-my-zsh by Adam Lindberg (eproxus@gmail.com) # (Needs Git plugin for current_branch method) #------------------------------------------------------------------------------- From 73946a6066fa8bf740b4765b7e204df9599f9689 Mon Sep 17 00:00:00 2001 From: Adam Lindberg Date: Tue, 7 Jun 2011 15:40:18 +0200 Subject: [PATCH 6/9] Add note about Solarized color theme --- themes/guru.zsh-theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/guru.zsh-theme b/themes/guru.zsh-theme index cbd56194f..a5ffdb722 100644 --- a/themes/guru.zsh-theme +++ b/themes/guru.zsh-theme @@ -1,9 +1,9 @@ #------------------------------------------------------------------------------- # Guru theme for oh-my-zsh by Adam Lindberg (eproxus@gmail.com) +# Intended to be used with Solarized: http://ethanschoonover.com/solarized # (Needs Git plugin for current_branch method) #------------------------------------------------------------------------------- - # Color shortcuts R=$fg[red] G=$fg[green] From 4a7392fdd0be8fafcaffccc206f23c7746129fb8 Mon Sep 17 00:00:00 2001 From: Adam Lindberg Date: Tue, 7 Jun 2011 15:40:32 +0200 Subject: [PATCH 7/9] Fix git R and M status when used together --- themes/guru.zsh-theme | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/themes/guru.zsh-theme b/themes/guru.zsh-theme index a5ffdb722..dfec3dfb5 100644 --- a/themes/guru.zsh-theme +++ b/themes/guru.zsh-theme @@ -35,7 +35,7 @@ custom_git_prompt_status() { if $(echo "$INDEX" | grep '^ D ' &> /dev/null); then STATUS="$ZSH_THEME_GIT_PROMPT_DELETED$STATUS" fi - if $(echo "$INDEX" | grep '^ M ' &> /dev/null); then + if $(echo "$INDEX" | grep '^.M ' &> /dev/null); then STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS" elif $(echo "$INDEX" | grep '^AM ' &> /dev/null); then STATUS="$ZSH_THEME_GIT_PROMPT_MODIFIED$STATUS" @@ -46,7 +46,7 @@ custom_git_prompt_status() { if $(echo "$INDEX" | grep '^D ' &> /dev/null); then STATUS="$ZSH_THEME_GIT_PROMPT_STAGED_DELETED$STATUS" fi - if $(echo "$INDEX" | grep '^R ' &> /dev/null); then + if $(echo "$INDEX" | grep '^R' &> /dev/null); then STATUS="$ZSH_THEME_GIT_PROMPT_STAGED_RENAMED$STATUS" fi if $(echo "$INDEX" | grep '^M ' &> /dev/null); then From d99284f6b569a0860ed14330c8c9eaf5f0441fe8 Mon Sep 17 00:00:00 2001 From: Adam Lindberg Date: Tue, 7 Jun 2011 15:42:55 +0200 Subject: [PATCH 8/9] Rename guru theme to sunrise --- themes/{guru.zsh-theme => sunrise.zsh-theme} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename themes/{guru.zsh-theme => sunrise.zsh-theme} (97%) diff --git a/themes/guru.zsh-theme b/themes/sunrise.zsh-theme similarity index 97% rename from themes/guru.zsh-theme rename to themes/sunrise.zsh-theme index dfec3dfb5..15004084d 100644 --- a/themes/guru.zsh-theme +++ b/themes/sunrise.zsh-theme @@ -1,5 +1,5 @@ #------------------------------------------------------------------------------- -# Guru theme for oh-my-zsh by Adam Lindberg (eproxus@gmail.com) +# Sunrise theme for oh-my-zsh by Adam Lindberg (eproxus@gmail.com) # Intended to be used with Solarized: http://ethanschoonover.com/solarized # (Needs Git plugin for current_branch method) #------------------------------------------------------------------------------- From 3eae652a6d4bc5f280bb7f9d33000f378becf13c Mon Sep 17 00:00:00 2001 From: Adam Lindberg Date: Wed, 8 Jun 2011 16:33:29 +0100 Subject: [PATCH 9/9] Fix MM lines being read correctly --- themes/sunrise.zsh-theme | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/sunrise.zsh-theme b/themes/sunrise.zsh-theme index 15004084d..88b371d79 100644 --- a/themes/sunrise.zsh-theme +++ b/themes/sunrise.zsh-theme @@ -49,7 +49,7 @@ custom_git_prompt_status() { if $(echo "$INDEX" | grep '^R' &> /dev/null); then STATUS="$ZSH_THEME_GIT_PROMPT_STAGED_RENAMED$STATUS" fi - if $(echo "$INDEX" | grep '^M ' &> /dev/null); then + if $(echo "$INDEX" | grep '^M' &> /dev/null); then STATUS="$ZSH_THEME_GIT_PROMPT_STAGED_MODIFIED$STATUS" fi if $(echo "$INDEX" | grep '^A' &> /dev/null); then