# vim: syntax=zsh function prompt_matir_setup { autoload -Uz add-zsh-hook autoload -Uz vcs_info autoload -Uz colors prompt_opts=(sp subst cr percent) colors add-zsh-hook precmd prompt_matir_precmd # Git related styles zstyle ':vcs_info:*' enable git zstyle ':vcs_info:*' check-for-changes true zstyle ':vcs_info:*' formats ' (%b%u%c)' zstyle ':vcs_info:*' stagedstr '*' zstyle ':vcs_info:*' unstagedstr '*' zstyle ':vcs_info:git*+set-message:*' hooks git-untracked PROMPT='%{$fg[black]%}[%{$fg[yellow]%}%h%{$fg[black]%}] ' # History # PROMPT+='%{%(!.$fg[red].$fg[green])%}%8>..>%n%>>%{$fg[white]%}@' # username@ PROMPT+='%{$fg[blue]%}%12>..>%m%>>%{$fg[white]%}:' # hostname PROMPT+='%{$fg[green]%}%32<...<%~%<<' # path PROMPT+='%{$fg[magenta]%}${VIRTUAL_ENV_SHORT}' # virtualenv PROMPT+='%{$fg[blue]%}${vcs_info_msg_0_}' # VCS info PROMPT+='%{$fg[white]%}%#%{$reset_color%} ' # prompt symbol # Rprompt setup local show_return='✘ ' RPROMPT='%(?:: %{$fg[red]%}' RPROMPT+=${show_return} RPROMPT+='%? ' RPROMPT+='%{$reset_color%})' RPROMPT+='${PROMPT_VIMODE}' } function zle-keymap-select { # Add prompt info PROMPT_VIMODE="${${KEYMAP/vicmd/ [VICMD]}/(main|viins)/}" zle reset-prompt } zle -N zle-keymap-select function prompt_matir_precmd { vcs_info if [ $VIRTUAL_ENV ] ; then VIRTUAL_ENV_SHORT=" (py:$(basename $VIRTUAL_ENV))" else VIRTUAL_ENV_SHORT="" fi } ### git: Show marker (*) if there are untracked files in repository # Make sure you have added staged to your 'formats': %c +vi-git-untracked(){ if [[ $(git rev-parse --is-inside-work-tree 2> /dev/null) == 'true' ]] && \ git status --porcelain | grep '??' &> /dev/null ; then hook_com[staged]+='*' fi } prompt_matir_setup "$@"