2016-12-02 12:35:12 -05:00
|
|
|
# -*-mode: sh-*-
|
2016-01-22 19:22:28 -05:00
|
|
|
# My mess of various themes
|
|
|
|
|
2016-12-02 12:35:19 -05:00
|
|
|
setopt PROMPT_SUBST #allows prompt substitutions
|
2016-07-19 00:14:41 -04:00
|
|
|
if [[ $(locale charmap) != UTF-8 || "$TERM" == linux ]]
|
|
|
|
then
|
|
|
|
ERROR_CHAR=''
|
2019-06-30 23:17:49 -04:00
|
|
|
GIT_DIRTY_CHAR="*"
|
2016-07-19 00:14:41 -04:00
|
|
|
PREFIX='$'
|
|
|
|
LCOLOR=""
|
|
|
|
else
|
|
|
|
ERROR_CHAR='⏎'
|
2019-06-30 23:17:49 -04:00
|
|
|
GIT_DIRTY_CHAR="∆" # U+2206
|
2016-07-19 00:14:41 -04:00
|
|
|
PREFIX="❱" # U+2771
|
|
|
|
LCOLOR="$fg_bold[black]"
|
|
|
|
fi
|
|
|
|
|
2016-01-22 19:22:28 -05:00
|
|
|
prompt_context() {
|
|
|
|
if [ -n "$SSH_CLIENT" ]
|
|
|
|
then
|
|
|
|
host=%B%F{blue}%m%f%b
|
|
|
|
else
|
|
|
|
host=%B%F{green}%m%f%b
|
|
|
|
fi
|
|
|
|
print "%B%(!.%F{red}.%F{green})%n@${host}"
|
|
|
|
}
|
|
|
|
|
2019-06-30 23:17:36 -04:00
|
|
|
prompt_git_dirty () {
|
|
|
|
[[ "$(git rev-parse --is-inside-work-tree)" == "true" && \
|
|
|
|
-n "$(git status --porcelain --ignore-submodules)" ]]
|
|
|
|
}
|
|
|
|
|
2016-01-22 19:22:28 -05:00
|
|
|
rprompt_git() {
|
|
|
|
ref=${vcs_info_msg_0_}
|
|
|
|
if [[ -n ${ref} ]]; then
|
2019-06-30 23:17:36 -04:00
|
|
|
if prompt_git_dirty; then
|
2016-07-19 00:14:41 -04:00
|
|
|
print '%F{yellow}'$GIT_DIRTY_CHAR'%f'
|
2016-01-22 19:22:28 -05:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# Git: branch/detached head, dirty status
|
|
|
|
prompt_git() {
|
|
|
|
local color ref
|
|
|
|
ref=${vcs_info_msg_0_}
|
|
|
|
if [[ -n ${ref} ]]; then
|
2019-06-30 23:17:36 -04:00
|
|
|
if prompt_git_dirty; then
|
2016-01-22 19:22:28 -05:00
|
|
|
color=yellow
|
|
|
|
else
|
|
|
|
color=green
|
|
|
|
fi
|
|
|
|
print -n " %F{${color}}${ref}"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
prompt_prefix() {
|
|
|
|
print "%(!. %B%F{red}#%f%b.)%B%F{cyan}${PREFIX}%f%b "
|
|
|
|
}
|
|
|
|
|
|
|
|
function prompt_fred_precmd {
|
|
|
|
setopt LOCAL_OPTIONS
|
|
|
|
unsetopt XTRACE KSH_ARRAYS
|
|
|
|
|
|
|
|
(( PWDWIDTH = ($COLUMNS-20) * 1/4 ))
|
|
|
|
vcs_info
|
2016-02-15 11:15:04 -05:00
|
|
|
|
|
|
|
#Terminal Title
|
|
|
|
print -Pn "\e]0;%~:zsh\a"
|
|
|
|
}
|
|
|
|
|
|
|
|
function prompt_fred_preexec {
|
|
|
|
#Terminal Title
|
|
|
|
print -Pn '\e]0;%~:${1}\a'
|
2016-01-22 19:22:28 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
function prompt_fred_setup {
|
|
|
|
setopt LOCAL_OPTIONS
|
|
|
|
unsetopt XTRACE KSH_ARRAYS
|
|
|
|
prompt_opts=(cr percent subst)
|
|
|
|
|
|
|
|
# Load required functions.
|
|
|
|
autoload -Uz add-zsh-hook
|
|
|
|
autoload -Uz vcs_info
|
|
|
|
|
|
|
|
zstyle ':vcs_info:*' enable git
|
|
|
|
zstyle ':vcs_info:*' check-for-changes false
|
|
|
|
zstyle ':vcs_info:git*' formats "%b%f"
|
|
|
|
zstyle ':vcs_info:git*' actionformats "%b%f:%F{yellow}%B%a"
|
|
|
|
|
|
|
|
# Add hook for calling precmd before each command.
|
|
|
|
add-zsh-hook precmd prompt_fred_precmd
|
2016-02-15 11:15:04 -05:00
|
|
|
add-zsh-hook preexec prompt_fred_preexec
|
2016-01-22 19:22:28 -05:00
|
|
|
|
|
|
|
# Define prompts.
|
|
|
|
PROMPT='$(prompt_context)%F{cyan} %${PWDWIDTH}<..<%~%f$(prompt_git)$(prompt_prefix)'
|
2016-07-19 00:14:41 -04:00
|
|
|
RPROMPT='${editor_info[overwrite]}%(?:: %F{red}%?'$ERROR_CHAR'%f) $(rprompt_git)'
|
2016-01-22 19:22:28 -05:00
|
|
|
SPROMPT='zsh: correct %F{red}%R%f to %F{green}%r%f [nyae]? '
|
|
|
|
}
|
|
|
|
|
|
|
|
prompt_fred_setup "$@"
|
|
|
|
|