]> git.rmz.io Git - dotfiles.git/commitdiff
zsh: add virtualenv prompt
authorSamir Benmendil <samir.benmendil@ultrahaptics.com>
Mon, 2 Sep 2019 11:59:34 +0000 (12:59 +0100)
committerSamir Benmendil <samir.benmendil@ultrahaptics.com>
Mon, 2 Sep 2019 11:59:34 +0000 (12:59 +0100)
zsh/lib/prompt.zsh

index 683fab499979d002a7e06f6b9b71b4a429e7deee..c8ca45b3ce1435c75de87ed83520c9cfa29dd0de 100644 (file)
@@ -6,7 +6,7 @@ hostcolor=green
 [[ $(hostname) == "tardis" ]]  && hostcolor=red
 
 precmd() {
-  PROMPT='%T %n@%{$fg[$hostcolor]%}%m%(1j. $fg_bold[white]↵%{$fg_bold[red]%}%j.)%{$reset_color%}%-0>..>$(git_prompt_status)%>>
+  PROMPT='%T $(virtualenv_prompt)%n@%{$fg[$hostcolor]%}%m%(1j. $fg_bold[white]↵%{$fg_bold[red]%}%j.)%{$reset_color%}%-0>..>$(git_prompt_status)%>>
 %(?..%{$fg_bold[white]%}%?)%{$reset_color%}$(vi_prompt_info)%{%(!.$fg[red]❰.$fg[green]❱)%1G%} '
   RPROMPT='%{$fg[green]%}%~%{$reset_color%}'
 }
@@ -108,6 +108,14 @@ git_prompt_status() {
   echo $git_status
 }
 
+function virtualenv_prompt() {
+  if [[ -z $VIRTUAL_ENV ]] then
+    echo ""
+  else
+    echo "(${VIRTUAL_ENV##*/}) "
+  fi
+}
+
 function print_if_fits() {
   local zero length