adaf89caa812e38df6b27032cb03a1321498ef23

Author
Robby Russell <robby@planetargon.com>
Committer
Robby Russell <robby@planetargon.com>
Date

Message

Merge pull request #4113 from apjanke/gnzh-remove-eval

gnzh theme: fix "eval" and related scope problems.

Diff

 1diff --git a/themes/gnzh.zsh-theme b/themes/gnzh.zsh-theme
 2index ab154c1e5cbc8a5cdbd014a11c2967449d591530..04b0450a8c0f86ec09d379f58cfd904be5c3f101 100644
 3--- a/themes/gnzh.zsh-theme
 4+++ b/themes/gnzh.zsh-theme
 5@@ -1,53 +1,50 @@
 6 # ZSH Theme - Preview: http://dl.dropbox.com/u/4109351/pics/gnzh-zsh-theme.png
 7 # Based on bira theme
 8 
 9-# load some modules
10-autoload -U zsh/terminfo # Used in the colour alias below
11 setopt prompt_subst
12 
13-# make some aliases for the colours: (could use normal escape sequences too)
14-for color in RED GREEN YELLOW BLUE MAGENTA CYAN WHITE; do
15-  eval PR_$color='%{$fg[${(L)color}]%}'
16-done
17-eval PR_NO_COLOR="%{$terminfo[sgr0]%}"
18-eval PR_BOLD="%{$terminfo[bold]%}"
19+() {
20+
21+local PR_USER PR_USER_OP PR_PROMPT PR_HOST
22 
23 # Check the UID
24 if [[ $UID -ne 0 ]]; then # normal user
25-  eval PR_USER='${PR_GREEN}%n${PR_NO_COLOR}'
26-  eval PR_USER_OP='${PR_GREEN}%#${PR_NO_COLOR}'
27-  local PR_PROMPT='$PR_NO_COLOR➤ $PR_NO_COLOR'
28+  PR_USER='%F{green}%n%f'
29+  PR_USER_OP='%F{green}%#%f'
30+  PR_PROMPT='%f➤ %f'
31 else # root
32-  eval PR_USER='${PR_RED}%n${PR_NO_COLOR}'
33-  eval PR_USER_OP='${PR_RED}%#${PR_NO_COLOR}'
34-  local PR_PROMPT='$PR_RED➤ $PR_NO_COLOR'
35+  PR_USER='%F{red}%n%f'
36+  PR_USER_OP='%F{red}%#%f'
37+  PR_PROMPT='%F{red}➤ %f'
38 fi
39 
40 # Check if we are on SSH or not
41 if [[ -n "$SSH_CLIENT"  ||  -n "$SSH2_CLIENT" ]]; then
42-  eval PR_HOST='${PR_YELLOW}%M${PR_NO_COLOR}' #SSH
43+  PR_HOST='%F{red}%M%f' # SSH
44 else
45-  eval PR_HOST='${PR_GREEN}%M${PR_NO_COLOR}' # no SSH
46+  PR_HOST='%F{green}%M%f' # no SSH
47 fi
48 
49-local return_code="%(?..%{$PR_RED%}%? ↵%{$PR_NO_COLOR%})"
50 
51-local user_host='${PR_USER}${PR_CYAN}@${PR_HOST}'
52-local current_dir='%{$PR_BOLD$PR_BLUE%}%~%{$PR_NO_COLOR%}'
53+local return_code="%(?..%F{red}%? ↵%f)"
54+
55+local user_host="${PR_USER}%F{cyan}@${PR_HOST}"
56+local current_dir="%B%F{blue}%~%f%b"
57 local rvm_ruby=''
58-if ${HOME}/.rvm/bin/rvm-prompt &> /dev/null; then # detect local user rvm installation
59-  rvm_ruby='%{$PR_RED%}‹$(${HOME}/.rvm/bin/rvm-prompt i v g s)›%{$PR_NO_COLOR%}'
60-elif which rvm-prompt &> /dev/null; then # detect sysem-wide rvm installation
61-  rvm_ruby='%{$PR_RED%}‹$(rvm-prompt i v g s)›%{$PR_NO_COLOR%}'
62-elif which rbenv &> /dev/null; then # detect Simple Ruby Version management
63-  rvm_ruby='%{$PR_RED%}‹$(rbenv version | sed -e "s/ (set.*$//")›%{$PR_NO_COLOR%}'
64+if ${HOME}/.rvm/bin/rvm-prompt &> /dev/null; then # detect user-local rvm installation
65+  rvm_ruby='%F{red}‹$(${HOME}/.rvm/bin/rvm-prompt i v g s)›%f'
66+elif which rvm-prompt &> /dev/null; then # detect system-wide rvm installation
67+  rvm_ruby='%F{red}‹$(rvm-prompt i v g s)›%f'
68+elif which rbenv &> /dev/null; then # detect Simple Ruby Version Management
69+  rvm_ruby='%F{red}‹$(rbenv version | sed -e "s/ (set.*$//")›%f'
70 fi
71-local git_branch='$(git_prompt_info)%{$PR_NO_COLOR%}'
72+local git_branch='$(git_prompt_info)'
73 
74-#PROMPT="${user_host} ${current_dir} ${rvm_ruby} ${git_branch}$PR_PROMPT "
75 PROMPT="╭─${user_host} ${current_dir} ${rvm_ruby} ${git_branch}
76 ╰─$PR_PROMPT "
77-RPS1="${return_code}"
78+RPROMPT="${return_code}"
79+
80+ZSH_THEME_GIT_PROMPT_PREFIX="%F{yellow}‹"
81+ZSH_THEME_GIT_PROMPT_SUFFIX="› %f"
82 
83-ZSH_THEME_GIT_PROMPT_PREFIX="%{$PR_YELLOW%}‹"
84-ZSH_THEME_GIT_PROMPT_SUFFIX="› %{$PR_NO_COLOR%}"
85+}