X-Git-Url: https://git.rmz.io/dotfiles.git/blobdiff_plain/bfb270cf83a87659a726c74c30dd6d3d696d2dd6..8323e8ce778e413d2cca20ea442717c78e1e0939:/zsh/lib/prompt.zsh diff --git a/zsh/lib/prompt.zsh b/zsh/lib/prompt.zsh index 2cea031..3ca62a4 100644 --- a/zsh/lib/prompt.zsh +++ b/zsh/lib/prompt.zsh @@ -2,12 +2,12 @@ setopt prompt_subst autoload colors; colors; -hostcolor=green +hostcolor=cyan [[ $(hostname) == "tardis" ]] && hostcolor=red precmd() { - 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%} ' + PROMPT=$'%T $(task_today_list)%n@%{$fg[$hostcolor]%}%m$(jobs_prompt)%-0>..>$(git_prompt_status)%>>\n' + PROMPT+=$'$(virtualenv_prompt)%(?..%{$fg_bold[white]%}%?)%{$reset_color%}$(vi_prompt_info)%{%(!.$fg[red]❰.$fg[green]❱)%1G%} ' RPROMPT='%{$fg[green]%}%~%{$reset_color%}' } @@ -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,55 +63,57 @@ 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) - local git_status=" %{$fg_bold[green]%}" + local git_status=" " # Format branch and commit - git_status+="$head%{$fg_no_bold[yellow]%}(${oid[1,8]})" + git_status+="%{$fg_bold[green]%}$head" + git_status+="%{$fg_no_bold[yellow]%}(${oid[1,8]})" # Format upstream - local upstream_str - (( ahead > 0 )) && upstream_str+="%{$fg[blue]%} >$ahead" - (( behind > 0 )) && upstream_str+="%{$fg[blue]%} <$behind" - git_status+="$upstream_str" + git_status+="%{$fg[blue]%}" + [[ -z "$upstream" ]] && git_status+=" Ɇ" + (( ahead > 0 )) && git_status+=" >$ahead" + (( behind > 0 )) && git_status+=" <$behind" # Format push + git_status+="%{$fg_bold[blue]%}" push_ab=( $(git rev-list --left-right --count @...@{push} 2>/dev/null) ) if (( $? == 0 )); then - (( push_ab[1] > 0 )) && git_status+="%{$fg_bold[blue]%} ⮝$push_ab[1]" - (( push_ab[2] > 0 )) && git_status+="%{$fg_bold[blue]%} ⮟$push_ab[2]" + (( push_ab[1] > 0 )) && git_status+=" ⮝$push_ab[1]" + (( push_ab[2] > 0 )) && git_status+=" ⮟$push_ab[2]" fi # Format stashed + git_status+="%{$fg_bold[cyan]%}" stashed=$(git stash list | wc -l) - if (( stashed > 0 )) then - stashed_str+="%{$fg_bold[cyan]%} ⋎$stashed%{$reset_color%}" - fi - git_status+="$stashed_str" + (( stashed > 0 )) && git_status+=" ⋎$stashed" # Format index - local index_str - (( updated > 0 )) && index_str+="%{$fg[green]%} *$updated" - (( added > 0 )) && index_str+="%{$fg[green]%} +$added" - (( deleted > 0 )) && index_str+="%{$fg[green]%} -$deleted" - (( renamed > 0 )) && index_str+="%{$fg[green]%} ≈$renamed" - git_status+="$index_str" + git_status+="%{$fg_no_bold[green]%}" + (( updated > 0 )) && git_status+=" *$updated" + (( added > 0 )) && git_status+=" +$added" + (( deleted > 0 )) && git_status+=" -$deleted" + (( renamed > 0 )) && git_status+=" ≈$renamed" # Format working tree - local wt_str - (( modified > 0 )) && wt_str+="%{$fg[red]%} *$modified" - (( deleted_wt > 0 )) && wt_str+="%{$fg[red]%} -$deleted_wt" - (( untracked > 0 )) && wt_str+="%{$fg[red]%} +$untracked" - (( unmerged > 0 )) && wt_str+="%{$fg[magenta]%} ♒$unmerged" - git_status+="$wt_str" + git_status+="%{$fg_no_bold[red]%}" + (( modified > 0 )) && git_status+=" *$modified" + (( deleted_wt > 0 )) && git_status+=" -$deleted_wt" + (( untracked > 0 )) && git_status+=" +$untracked" + git_status+="%{$fg_no_bold[magenta]%}" + (( unmerged > 0 )) && git_status+=" ♒$unmerged" git_status+="%{$reset_color%}" @@ -132,3 +135,13 @@ function print_if_fits() { length=${#${(S%%)1//$~zero/}} echo "%-$length(l.$1.)" } + +function task_today_list() { + local task_cmd=(task rc.verbose:nothing) + local task_count=$($task_cmd $($task_cmd _get rc.report.today.filter) count) + + local task_status="" + task_status+="%{$fg_bold[red]%} $task_count " + task_status+="%{$reset_color%}" + echo $task_status +}