X-Git-Url: https://git.rmz.io/dotfiles.git/blobdiff_plain/bfb270cf83a87659a726c74c30dd6d3d696d2dd6..bccff5a0e15cd16d28cfb5e0d9fc2b0c4687e55d:/zsh/lib/prompt.zsh diff --git a/zsh/lib/prompt.zsh b/zsh/lib/prompt.zsh index 2cea031..fa894be 100644 --- a/zsh/lib/prompt.zsh +++ b/zsh/lib/prompt.zsh @@ -2,7 +2,7 @@ setopt prompt_subst autoload colors; colors; -hostcolor=green +hostcolor=cyan [[ $(hostname) == "tardis" ]] && hostcolor=red precmd() { @@ -51,6 +51,7 @@ git_prompt_status() { 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. @@ -62,12 +63,15 @@ git_prompt_status() { [[ "$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++ )) + + #TODO more info for submodules? fi done < <(${(z)status_cmd} 2> /dev/null) @@ -78,6 +82,7 @@ git_prompt_status() { # 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"