2015-12-18 16:51:58 +01:00
|
|
|
|
#
|
|
|
|
|
# Minimal theme
|
|
|
|
|
# https://github.com/S1cK94/minimal
|
|
|
|
|
#
|
2017-03-15 15:43:35 +01:00
|
|
|
|
# Requires the `git-info` zmodule to be included in the .zimrc file.
|
2015-12-18 16:51:58 +01:00
|
|
|
|
|
2017-03-15 15:43:35 +01:00
|
|
|
|
# Global variables
|
|
|
|
|
function {
|
|
|
|
|
PROMPT_CHAR='❯'
|
|
|
|
|
|
|
|
|
|
ON_COLOR='%F{green}'
|
|
|
|
|
OFF_COLOR='%f'
|
|
|
|
|
ERR_COLOR='%F{red}'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
prompt_minimal_user() {
|
|
|
|
|
print -n '%(!.${ON_COLOR}.${OFF_COLOR})${PROMPT_CHAR}'
|
2016-01-06 20:06:06 +01:00
|
|
|
|
}
|
2015-12-18 16:51:58 +01:00
|
|
|
|
|
2017-03-15 15:43:35 +01:00
|
|
|
|
prompt_minimal_jobs() {
|
|
|
|
|
print -n '%(1j.${ON_COLOR}.${OFF_COLOR})${PROMPT_CHAR}'
|
2016-01-06 20:06:06 +01:00
|
|
|
|
}
|
2015-12-18 16:51:58 +01:00
|
|
|
|
|
2017-03-15 15:43:35 +01:00
|
|
|
|
prompt_minimal_vimode() {
|
|
|
|
|
local color
|
2015-12-18 16:51:58 +01:00
|
|
|
|
|
2017-03-15 15:43:35 +01:00
|
|
|
|
case ${KEYMAP} in
|
2016-01-06 20:06:06 +01:00
|
|
|
|
main|viins)
|
2017-03-15 15:43:35 +01:00
|
|
|
|
color=${ON_COLOR}
|
2016-01-06 20:06:06 +01:00
|
|
|
|
;;
|
2017-03-15 15:43:35 +01:00
|
|
|
|
*)
|
|
|
|
|
color=${OFF_COLOR}
|
2016-01-06 20:06:06 +01:00
|
|
|
|
;;
|
|
|
|
|
esac
|
2015-12-18 16:51:58 +01:00
|
|
|
|
|
2017-03-15 15:43:35 +01:00
|
|
|
|
print -n "${color}${PROMPT_CHAR}"
|
2015-12-18 16:51:58 +01:00
|
|
|
|
}
|
|
|
|
|
|
2017-03-15 15:43:35 +01:00
|
|
|
|
prompt_minimal_status() {
|
|
|
|
|
print -n '%(0?.${ON_COLOR}.${ERR_COLOR})${PROMPT_CHAR}'
|
2015-12-18 16:51:58 +01:00
|
|
|
|
}
|
|
|
|
|
|
2017-03-15 15:43:35 +01:00
|
|
|
|
prompt_minimal_path() {
|
|
|
|
|
local path_color='%F{244}'
|
|
|
|
|
print -n "${path_color}${$(short_pwd)//\//%f\/${path_color}}%f"
|
2015-12-18 16:51:58 +01:00
|
|
|
|
}
|
|
|
|
|
|
2017-03-15 15:43:35 +01:00
|
|
|
|
prompt_minimal_git() {
|
|
|
|
|
if [[ -n ${git_info} ]]; then
|
|
|
|
|
print -n " ${(e)git_info[color]}${(e)git_info[prompt]}"
|
2015-12-18 16:51:58 +01:00
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-15 15:43:35 +01:00
|
|
|
|
function zle-line-init zle-keymap-select {
|
2015-12-18 16:51:58 +01:00
|
|
|
|
zle reset-prompt
|
|
|
|
|
zle -R
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-07 14:06:52 +01:00
|
|
|
|
prompt_minimal_precmd() {
|
2017-03-15 15:43:35 +01:00
|
|
|
|
(( ${+functions[git-info]} )) && git-info
|
2016-01-06 20:06:06 +01:00
|
|
|
|
}
|
2015-12-18 16:51:58 +01:00
|
|
|
|
|
2016-01-07 14:06:52 +01:00
|
|
|
|
prompt_minimal_setup() {
|
2017-03-15 15:43:35 +01:00
|
|
|
|
zle -N zle-line-init
|
|
|
|
|
zle -N zle-keymap-select
|
2016-01-06 20:06:06 +01:00
|
|
|
|
|
2017-03-15 15:43:35 +01:00
|
|
|
|
autoload -Uz colors && colors
|
2016-01-06 20:06:06 +01:00
|
|
|
|
autoload -Uz add-zsh-hook
|
|
|
|
|
|
2017-10-02 03:35:47 +02:00
|
|
|
|
prompt_opts=(cr percent sp subst)
|
2017-03-15 15:43:35 +01:00
|
|
|
|
|
2016-01-06 20:06:06 +01:00
|
|
|
|
add-zsh-hook precmd prompt_minimal_precmd
|
2017-03-15 15:43:35 +01:00
|
|
|
|
|
|
|
|
|
zstyle ':zim:git-info:branch' format '%b'
|
|
|
|
|
zstyle ':zim:git-info:commit' format '%c'
|
|
|
|
|
zstyle ':zim:git-info:dirty' format '${ERR_COLOR}'
|
|
|
|
|
zstyle ':zim:git-info:diverged' format '${ERR_COLOR}'
|
|
|
|
|
zstyle ':zim:git-info:behind' format '%F{11}'
|
|
|
|
|
zstyle ':zim:git-info:ahead' format '${OFF_COLOR}'
|
|
|
|
|
zstyle ':zim:git-info:keys' format \
|
|
|
|
|
'prompt' '%b%c' \
|
|
|
|
|
'color' '$(coalesce "%D" "%V" "%B" "%A" "${ON_COLOR}")'
|
|
|
|
|
|
|
|
|
|
PROMPT="$(prompt_minimal_user)$(prompt_minimal_jobs)\$(prompt_minimal_vimode)$(prompt_minimal_status)%f "
|
|
|
|
|
RPROMPT='$(prompt_minimal_path)$(prompt_minimal_git)'
|
2016-01-06 20:06:06 +01:00
|
|
|
|
}
|
2015-12-18 16:51:58 +01:00
|
|
|
|
|
2016-01-06 20:06:06 +01:00
|
|
|
|
prompt_minimal_setup "$@"
|