X-Git-Url: https://git.rmz.io/dotfiles.git/blobdiff_plain/2bb3c600f31aa7e1af1fbef3656ab6947a7585e3..771eb3ba0503e3a2c34767b4ae8a42da9591a5ae:/zsh/lib/prompt.zsh diff --git a/zsh/lib/prompt.zsh b/zsh/lib/prompt.zsh index 4f31348..3fc1c24 100644 --- a/zsh/lib/prompt.zsh +++ b/zsh/lib/prompt.zsh @@ -1,9 +1,13 @@ +# Setup the prompt with pretty colors +setopt prompt_subst +autoload colors; colors; + hostcolor=green [[ $(hostname) == "tardis" ]] && hostcolor=red precmd() { - PROMPT='%T %n@%{$fg[$hostcolor]%}%m%{$reset_color%}%-0>..>$(git_prompt_status)%>> -%(?..%{$fg_bold[white]%}%?%{$reset_color%})$(vi_prompt_info)%{%(!.$fg[red]❰.$fg[green]❱)%1G%} ' + PROMPT='%T %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%}' } @@ -37,9 +41,9 @@ git_prompt_status() { # 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.