d49397a01d0cc704008d6f1089ef6a7270d17116

Author
Marc Cornellà <marc.cornella@live.com>
Committer
Marc Cornellà <marc.cornella@live.com>
Date

Message

af-magic: fix dashed separator sizing and refactor

Fixes #8081

Diff

 1diff --git a/themes/af-magic.zsh-theme b/themes/af-magic.zsh-theme
 2index 30e997f8c21ddedd3f876206cf4539767b813ef8..4d1a40947f308e142b45d7ee50fd5f30dde8582c 100644
 3--- a/themes/af-magic.zsh-theme
 4+++ b/themes/af-magic.zsh-theme
 5@@ -2,29 +2,28 @@
 6 # Repo: https://github.com/andyfleming/oh-my-zsh
 7 # Direct Link: https://github.com/andyfleming/oh-my-zsh/blob/master/themes/af-magic.zsh-theme
 8 
 9-if [ $UID -eq 0 ]; then NCOLOR="red"; else NCOLOR="green"; fi
10-local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
11 
12-# primary prompt
13-PROMPT='$FG[237]${(l.COLUMNS..-.)}%{$reset_color%}
14-$FG[032]%~\
15-$(git_prompt_info)$(hg_prompt_info) \
16-$FG[105]%(!.#.»)%{$reset_color%} '
17-PROMPT2='%{$fg[red]%}\ %{$reset_color%}'
18-RPS1='${return_code}'
19+# settings
20+typeset +H return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
21+typeset +H my_gray="$FG[237]"
22+typeset +H my_orange="$FG[214]"
23 
24+# separator dashes size
25+function afmagic_dashes {
26+	[[ -n "${VIRTUAL_ENV-}" && -z "${VIRTUAL_ENV_DISABLE_PROMPT-}" && "$PS1" = \(* ]] \
27+		&& echo $(( COLUMNS - ${#VIRTUAL_ENV} - 3 )) \
28+		|| echo $COLUMNS
29+}
30 
31-# color vars
32-eval my_gray='$FG[237]'
33-eval my_orange='$FG[214]'
34+# primary prompt
35+PS1='$FG[237]${(l.$(afmagic_dashes)..-.)}%{$reset_color%}
36+$FG[032]%~$(git_prompt_info)$(hg_prompt_info) $FG[105]%(!.#.»)%{$reset_color%} '
37+PS2='%{$fg[red]%}\ %{$reset_color%}'
38+RPS1='${return_code}'
39 
40 # right prompt
41-if type "virtualenv_prompt_info" > /dev/null
42-then
43-	RPROMPT="${RPROMPT}"'$FG[078]$(virtualenv_prompt_info)%{$reset_color%} $my_gray%n@%m%{$reset_color%}%'
44-else
45-	RPROMPT="${RPROMPT}"'$my_gray%n@%m%{$reset_color%}%'
46-fi
47+(( $+functions[virtualenv_prompt_info] )) && RPS1+='$(virtualenv_prompt_info)'
48+RPS1+=' $my_gray%n@%m%{$reset_color%}%'
49 
50 # git settings
51 ZSH_THEME_GIT_PROMPT_PREFIX="$FG[075]($FG[078]"
52@@ -37,3 +36,7 @@ ZSH_THEME_HG_PROMPT_PREFIX="$FG[075]($FG[078]"
53 ZSH_THEME_HG_PROMPT_CLEAN=""
54 ZSH_THEME_HG_PROMPT_DIRTY="$my_orange*%{$reset_color%}"
55 ZSH_THEME_HG_PROMPT_SUFFIX="$FG[075])%{$reset_color%}"
56+
57+# virtualenv settings
58+ZSH_THEME_VIRTUALENV_PREFIX=" $FG[075]["
59+ZSH_THEME_VIRTUALENV_PREFIX="]%{$reset_color%}"