1
0
Fork 0
mirror of synced 2024-11-16 13:05:35 -05:00
zimfw/modules/prompt/themes/gitster.zsh-theme
Colin Jamison 4a373bca4a Implement config variable
This allows for an env variable of ZIM_PROMPT_INSERTMODE to be set
to determine if an indicator is shown.
2017-01-21 18:10:32 +01:00

45 lines
1.2 KiB
Bash

#
# Gitster theme
# https://github.com/shashankmehta/dotfiles/blob/master/thesetup/zsh/.oh-my-zsh/custom/themes/gitster.zsh-theme
#
prompt_gitster_get_status() {
print '%(?:%F{green}➜:%F{red}➜) '
}
prompt_gitster_get_pwd() {
prompt_short_dir=$(short_pwd)
git_root=$(command git rev-parse --show-toplevel 2> /dev/null) && prompt_short_dir=${prompt_short_dir#${$(short_pwd $git_root):h}/}
print ${prompt_short_dir}
}
prompt_gitster_precmd() {
[[ ${+functions[git-info]} ]] && git-info
PROMPT='$(prompt_gitster_get_status)%F{white}$(prompt_gitster_get_pwd)${(e)git_info[prompt]}%f '
RPROMPT="${ZIM_PROMPT_INSERTMODE:+${${KEYMAP/vicmd/[NORMAL]}/(main|viins)/}}"
}
zle-keymap-select() {
prompt_gitster_precmd
zle reset-prompt
}
prompt_gitster_setup() {
autoload -Uz colors && colors
autoload -Uz add-zsh-hook
prompt_opts=(cr percent subst)
add-zsh-hook precmd prompt_gitster_precmd
zle -N zle-keymap-select
zstyle ':zim:git-info:branch' format '%b'
zstyle ':zim:git-info:commit' format '%c'
zstyle ':zim:git-info:clean' format '%F{green}✓'
zstyle ':zim:git-info:dirty' format '%F{yellow}✗'
zstyle ':zim:git-info:keys' format \
'prompt' ' %F{cyan}%b%c %C%D'
}
prompt_gitster_setup "$@"