4954335b64e294923d64c4a9208e732bb9399268
- Author
- Robby Russell <robby@planetargon.com>
- Committer
- Robby Russell <robby@planetargon.com>
- Date
Message
Merge pull request #781 from pilif/two-lined-pygmalion
make pygmalion theme use two lines when needed
Diff
1diff --git a/themes/pygmalion.zsh-theme b/themes/pygmalion.zsh-theme
2index cf3bb908f217a9ed67228963609306da6aa8065d..654e0fc37666e21df2bcae24d8fe04417cd7d857 100644
3--- a/themes/pygmalion.zsh-theme
4+++ b/themes/pygmalion.zsh-theme
5@@ -1,9 +1,34 @@
6 # Yay! High voltage and arrows!
7
8-ZSH_THEME_GIT_PROMPT_PREFIX="%{$reset_color%}%{$fg[green]%}"
9-ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
10-ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[yellow]%}⚡%{$reset_color%}"
11-ZSH_THEME_GIT_PROMPT_CLEAN=""
12+prompt_setup_pygmalion(){
13+ ZSH_THEME_GIT_PROMPT_PREFIX="%{$reset_color%}%{$fg[green]%}"
14+ ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
15+ ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[yellow]%}⚡%{$reset_color%}"
16+ ZSH_THEME_GIT_PROMPT_CLEAN=""
17+
18+ base_prompt='%{$fg[magenta]%}%n%{$reset_color%}%{$fg[cyan]%}@%{$reset_color%}%{$fg[yellow]%}%m%{$reset_color%}%{$fg[red]%}:%{$reset_color%}%{$fg[cyan]%}%0~%{$reset_color%}%{$fg[red]%}|%{$reset_color%}'
19+ post_prompt='%{$fg[cyan]%}⇒%{$reset_color%} '
20+
21+ base_prompt_nocolor=$(echo "$base_prompt" | perl -pe "s/%\{[^}]+\}//g")
22+ post_prompt_nocolor=$(echo "$post_prompt" | perl -pe "s/%\{[^}]+\}//g")
23+
24+ add-zsh-hook precmd prompt_pygmalion_precmd
25+}
26+
27+prompt_pygmalion_precmd(){
28+ local gitinfo=$(git_prompt_info)
29+ local gitinfo_nocolor=$(echo "$gitinfo" | perl -pe "s/%\{[^}]+\}//g")
30+ local exp_nocolor="$(print -P \"$base_prompt_nocolor$gitinfo_nocolor$post_prompt_nocolor\")"
31+ local prompt_length=${#exp_nocolor}
32+
33+ local nl=""
34+
35+ if [[ $prompt_length -gt 40 ]]; then
36+ nl=$'\n%{\r%}';
37+ fi
38+ PROMPT="$base_prompt$gitinfo$nl$post_prompt"
39+}
40+
41+prompt_setup_pygmalion
42
43-PROMPT='%{$fg[magenta]%}%n%{$reset_color%}%{$fg[cyan]%}@%{$reset_color%}%{$fg[yellow]%}%m%{$reset_color%}%{$fg[red]%}:%{$reset_color%}%{$fg[cyan]%}%0~%{$reset_color%}%{$fg[red]%}|%{$reset_color%}$(git_prompt_info)%{$fg[cyan]%}⇒%{$reset_color%} '
44