zshrc: Load colors earlier, for vcs_info()
authorFrank Terbeck <ft@grml.org>
Tue, 26 Aug 2008 14:32:18 +0000 (16:32 +0200)
committerFrank Terbeck <ft@grml.org>
Tue, 26 Aug 2008 14:32:18 +0000 (16:32 +0200)
This also adds YELLOW and MAGENTA to the prompt color variables.

etc/zsh/zshrc

index 7a5f2f3..6de5c64 100644 (file)
@@ -1010,6 +1010,29 @@ if [[ -n "$BATTERY" ]] ; then
 fi
 # }}}
 
+# set colors for use in prompts {{{
+if zrcautoload colors && colors 2>/dev/null ; then
+    BLUE="%{${fg[blue]}%}"
+    RED="%{${fg_bold[red]}%}"
+    GREEN="%{${fg[green]}%}"
+    CYAN="%{${fg[cyan]}%}"
+    MAGENTA="%{${fg[magenta]}%}"
+    YELLOW="%{${fg[yellow]}%}"
+    WHITE="%{${fg[white]}%}"
+    NO_COLOUR="%{${reset_color}%}"
+else
+    BLUE=$'%{\e[1;34m%}'
+    RED=$'%{\e[1;31m%}'
+    GREEN=$'%{\e[1;32m%}'
+    CYAN=$'%{\e[1;36m%}'
+    WHITE=$'%{\e[1;37m%}'
+    MAGENTA='%{\e[1;35m%}'
+    YELLOW='%{\e[1;33m%}'
+    NO_COLOUR=$'%{\e[0m%}'
+fi
+
+# }}}
+
 # gather version control information for inclusion in a prompt {{{
 
 # vcs_info() documentation: {{{
@@ -1315,10 +1338,8 @@ if [[ "$TERM" == dumb ]] ; then
     zstyle ':vcs_info:*' promptformat       "(%s%)-[%b] "
 else
     # these are the same, just with a lot of colours:
-    zstyle ':vcs_info:*' promptactionformat \
-"%{${fg[magenta]}%}(%{${reset_color}%}%s%{${fg[magenta]}%})%{${fg[yellow]}%}-%{${fg[magenta]}%}[%{${fg[green]}%}%b%{${fg[yellow]}%}|%{${fg[red]}%}%a%{${fg[magenta]}%}]%{${reset_color}%} "
-    zstyle ':vcs_info:*' promptformat \
-"%{${fg[magenta]}%}(%{${reset_color}%}%s%{${fg[magenta]}%})%{${fg[yellow]}%}-%{${fg[magenta]}%}[%{${fg[green]}%}%b%{${fg[magenta]}%}]%{${reset_color}%} "
+    zstyle ':vcs_info:*' promptactionformat "${MAGENTA}(${NO_COLOUR}%s${MAGENTA})${YELLOW}-${MAGENTA}[${GREEN}%b${YELLOW}|${RED}%a${MAGENTA}]${NO_COLOUR} "
+    zstyle ':vcs_info:*' promptformat       "${MAGENTA}(${NO_COLOUR}%s${MAGENTA})${YELLOW}-${MAGENTA}[${GREEN}%b${MAGENTA}]${NO_COLOUR}%} "
 fi
 
 # }}}
@@ -1397,23 +1418,6 @@ preexec () {
     esac
 }
 
-# set colors
-if zrcautoload colors && colors 2>/dev/null ; then
-    BLUE="%{${fg[blue]}%}"
-    RED="%{${fg_bold[red]}%}"
-    GREEN="%{${fg[green]}%}"
-    CYAN="%{${fg[cyan]}%}"
-    WHITE="%{${fg[white]}%}"
-    NO_COLOUR="%{${reset_color}%}"
-else
-    BLUE=$'%{\e[1;34m%}'
-    RED=$'%{\e[1;31m%}'
-    GREEN=$'%{\e[1;32m%}'
-    CYAN=$'%{\e[1;36m%}'
-    WHITE=$'%{\e[1;37m%}'
-    NO_COLOUR=$'%{\e[0m%}'
-fi
-
 EXITCODE="%(?..%?%1v )"
 PS2='`%_> '       # secondary prompt, printed when the shell needs more information to complete a command.
 PS3='?# '         # selection prompt used within a select loop.