]> git.rmz.io Git - dotfiles.git/blobdiff - zsh/lib/prompt.zsh
vim: add choice snippet for sh
[dotfiles.git] / zsh / lib / prompt.zsh
index 61f5db8f64a3b387df4d0a1a11ee1104927c0903..683fab499979d002a7e06f6b9b71b4a429e7deee 100644 (file)
@@ -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
@@ -41,9 +42,9 @@ git_prompt_status() {
   # Get current status.
   while IFS=$'\n' read line; do
     if [[ "$line" == \#\#\ * ]]; then
   # Get current status.
   while IFS=$'\n' read line; do
     if [[ "$line" == \#\#\ * ]]; then
-      [[ "$line" =~ '## ([^.]*)\.\.\.(.*)' ]] && branch=$match[1]
-      [[ "$line" =~ 'ahead ([0-9]+)'  ]]      && ahead=$match[1]
-      [[ "$line" =~ 'behind ([0-9]+)'  ]]     && behind=$match[1]
+      [[ "$line" =~ '## (.*?)(\.\.\.|$)' ]] && branch=$match[1]
+      [[ "$line" =~ 'ahead ([0-9]+)'  ]]  && ahead=$match[1]
+      [[ "$line" =~ 'behind ([0-9]+)'  ]] && behind=$match[1]
     else
       # Count added, deleted, modified, renamed, unmerged, untracked, dirty.
       # T (type change) is undocumented, see http://git.io/FnpMGw.
     else
       # Count added, deleted, modified, renamed, unmerged, untracked, dirty.
       # T (type change) is undocumented, see http://git.io/FnpMGw.