]> git.rmz.io Git - dotfiles.git/blobdiff - zsh/lib/prompt.zsh
mutt: fix F macro to not write message to home
[dotfiles.git] / zsh / lib / prompt.zsh
index 3fc1c242758929cad8afc61f46eec3877ec8f751..c8ca45b3ce1435c75de87ed83520c9cfa29dd0de 100644 (file)
@@ -6,7 +6,7 @@ hostcolor=green
 [[ $(hostname) == "tardis" ]]  && hostcolor=red
 
 precmd() {
 [[ $(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%}'
 }
 %(?..%{$fg_bold[white]%}%?)%{$reset_color%}$(vi_prompt_info)%{%(!.$fg[red]❰.$fg[green]❱)%1G%} '
   RPROMPT='%{$fg[green]%}%~%{$reset_color%}'
 }
@@ -14,7 +14,8 @@ precmd() {
 vi_prompt_info() {
   local vicmd="$fg_bold[green]❰$reset_color%1G"
   local viins="$fg_bold[blue]❱$reset_color%1G"
 vi_prompt_info() {
   local vicmd="$fg_bold[green]❰$reset_color%1G"
   local viins="$fg_bold[blue]❱$reset_color%1G"
-  printf '%s' "%{${${KEYMAP/vicmd/$vicmd}/(main|viins)/$viins}%}"
+  local map=${KEYMAP:-viins}
+  printf '%s' "%{${${map/vicmd/$vicmd}/(main|viins)/$viins}%}"
 }
 
 function zle-line-init zle-line-finish zle-keymap-select {
 }
 
 function zle-line-init zle-line-finish zle-keymap-select {
@@ -22,8 +23,8 @@ function zle-line-init zle-line-finish zle-keymap-select {
   zle -R
 }
 
   zle -R
 }
 
-zle -N zle-line-init
-zle -N zle-line-finish
+zle -N zle-line-init
+zle -N zle-line-finish
 zle -N zle-keymap-select
 
 # reset zle on resize
 zle -N zle-keymap-select
 
 # reset zle on resize
@@ -107,6 +108,14 @@ git_prompt_status() {
   echo $git_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
 
 function print_if_fits() {
   local zero length