]> git.rmz.io Git - dotfiles.git/blobdiff - zsh/lib/prompt.zsh
vim: reinstate K -> "git show" map in gitrebase
[dotfiles.git] / zsh / lib / prompt.zsh
index 5b22231800a31b83be9d9870014047b20e6250be..fa894be16eaf9dc3f86030567d4c5bb80f02a305 100644 (file)
@@ -2,15 +2,19 @@
 setopt prompt_subst
 autoload colors; colors;
 
 setopt prompt_subst
 autoload colors; colors;
 
-hostcolor=green
+hostcolor=cyan
 [[ $(hostname) == "tardis" ]]  && hostcolor=red
 
 precmd() {
 [[ $(hostname) == "tardis" ]]  && hostcolor=red
 
 precmd() {
-  PROMPT='%T $(virtualenv_prompt)%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$(jobs_prompt)%-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%}'
 }
 
+jobs_prompt() {
+  printf '%s' "%(1j. $fg_bold[white]↵%{$fg_bold[red]%}%j.)%{$reset_color%}"
+}
+
 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"
@@ -47,6 +51,7 @@ git_prompt_status() {
     if [[ "$line" == \#\ * ]]; then
       [[ "$line" =~ '# branch.oid ([0-9a-f]+)' ]]         && oid=$match[1]
       [[ "$line" =~ '# branch.head (.*)' ]]               && head=$match[1]
     if [[ "$line" == \#\ * ]]; then
       [[ "$line" =~ '# branch.oid ([0-9a-f]+)' ]]         && oid=$match[1]
       [[ "$line" =~ '# branch.head (.*)' ]]               && head=$match[1]
+      [[ "$line" =~ '# branch.upstream (.*)' ]]           && upstream=$match[1]
       [[ "$line" =~ '# branch.ab \+([0-9]+) -([0-9]+)' ]] && ahead=$match[1] && behind=$match[2]
     else
       # Count added, deleted, modified, renamed, unmerged, untracked, dirty.
       [[ "$line" =~ '# branch.ab \+([0-9]+) -([0-9]+)' ]] && ahead=$match[1] && behind=$match[2]
     else
       # Count added, deleted, modified, renamed, unmerged, untracked, dirty.
@@ -58,12 +63,15 @@ git_prompt_status() {
       [[ "$line" == 2\ R[.MTD]\ * ]]      && (( renamed++ ))
 
       # work tree
       [[ "$line" == 2\ R[.MTD]\ * ]]      && (( renamed++ ))
 
       # work tree
+      [[ "$line" == 1\ [.MARCT]A\ * ]]    && (( added++ , modified++ ))  # intend-to-add
       [[ "$line" == 1\ [.MARCT]M\ * ]]    && (( modified++ ))
       [[ "$line" == 1\ [.MARCT]D\ * ]]    && (( deleted_wt++ ))
       [[ "$line" == \?\ * ]]              && (( untracked++ ))
 
       # merge conflicts
       [[ "$line" == u\ (AA|DD|U?|?U)\ * ]] && (( unmerged++ ))
       [[ "$line" == 1\ [.MARCT]M\ * ]]    && (( modified++ ))
       [[ "$line" == 1\ [.MARCT]D\ * ]]    && (( deleted_wt++ ))
       [[ "$line" == \?\ * ]]              && (( untracked++ ))
 
       # merge conflicts
       [[ "$line" == u\ (AA|DD|U?|?U)\ * ]] && (( unmerged++ ))
+
+      #TODO more info for submodules?
     fi
   done < <(${(z)status_cmd} 2> /dev/null)
 
     fi
   done < <(${(z)status_cmd} 2> /dev/null)
 
@@ -74,6 +82,7 @@ git_prompt_status() {
 
   # Format upstream
   local upstream_str
 
   # Format upstream
   local upstream_str
+  [[ -z "$upstream" ]] && upstream_str+="%{$fg[blue]%} Ɇ"
   (( ahead  > 0 )) && upstream_str+="%{$fg[blue]%} >$ahead"
   (( behind > 0 )) && upstream_str+="%{$fg[blue]%} <$behind"
   git_status+="$upstream_str"
   (( ahead  > 0 )) && upstream_str+="%{$fg[blue]%} >$ahead"
   (( behind > 0 )) && upstream_str+="%{$fg[blue]%} <$behind"
   git_status+="$upstream_str"