source "$HOME/.zsh/lib/gitstatus/gitstatus.plugin.zsh" gitstatus_start MY export GIT_PROMPT="" update_git_prompt() { typeset -g GIT_PROMPT="" gitstatus_query -t 5 MY || return [[ $VCS_STATUS_RESULT == ok-sync ]] || return GIT_PROMPT+="%{$fg_bold[green]%}${VCS_STATUS_LOCAL_BRANCH}%{$reset_color%}" if [[ $VCS_STATUS_HAS_STAGED == 1 ]] || [[ $VCS_STATUS_HAS_UNSTAGED ]]; then GIT_PROMPT+="%{$fg_bold[red]%}✱%{$reset_color%}" fi [[ $VCS_STATUS_COMMITS_AHEAD -gt 0 ]] && GIT_PROMPT+=" ⇡${VCS_STATUS_COMMITS_AHEAD}" [[ $VCS_STATUS_COMMITS_BEHIND -gt 0 ]] && GIT_PROMPT+=" ⇣${VCS_STATUS_COMMITS_BEHIND}" GIT_PROMPT+=" " } autoload -Uz add-zsh-hook add-zsh-hook precmd update_git_prompt # makes color constants available autoload -U colors colors # enable colored output from ls, etc export CLICOLOR=1 # expand functions in the prompt setopt promptsubst # prompt export PROMPT='${GIT_PROMPT}${SSH_CONNECTION+"%{$fg[yellow]%}%n@%m%{$reset_color%}:"}%{$fg_bold[blue]%}%2c%{$reset_color%} %{$fg_bold[cyan]%}❯%{$reset_color%} ' export RPROMPT='%D{%K:%M:%S}' # update the prompt on carriage return # function _reset-prompt-and-accept-line() { # zle reset-prompt # zle .accept-line # } # zle -N accept-line _reset-prompt-and-accept-line