Add my custom theme
This commit is contained in:
commit
c1e4943e23
83
prompt_fred_setup
Normal file
83
prompt_fred_setup
Normal file
@ -0,0 +1,83 @@
|
||||
# My mess of various themes
|
||||
|
||||
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}"
|
||||
}
|
||||
|
||||
rprompt_git() {
|
||||
ref=${vcs_info_msg_0_}
|
||||
if [[ -n ${ref} ]]; then
|
||||
if test -n "$(git status --porcelain --ignore-submodules)"; then
|
||||
print '%F{yellow}\u00b1%f'
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Git: branch/detached head, dirty status
|
||||
prompt_git() {
|
||||
local color ref
|
||||
is_dirty() {
|
||||
test -n "$(git status --porcelain --ignore-submodules)"
|
||||
}
|
||||
ref=${vcs_info_msg_0_}
|
||||
if [[ -n ${ref} ]]; then
|
||||
if is_dirty; then
|
||||
color=yellow
|
||||
else
|
||||
color=green
|
||||
fi
|
||||
print -n " %F{${color}}${ref}"
|
||||
fi
|
||||
}
|
||||
|
||||
prompt_prefix() {
|
||||
if [[ $(locale charmap) != UTF-8 || "$TERM" == linux ]]
|
||||
then
|
||||
PREFIX='$'
|
||||
LCOLOR=""
|
||||
else
|
||||
PREFIX="❱" # U+2771
|
||||
LCOLOR="$fg_bold[black]"
|
||||
fi
|
||||
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
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
# Define prompts.
|
||||
PROMPT='$(prompt_context)%F{cyan} %${PWDWIDTH}<..<%~%f$(prompt_git)$(prompt_prefix)'
|
||||
RPROMPT='${editor_info[overwrite]}%(?:: %F{red}%?⏎%f) $(rprompt_git)'
|
||||
SPROMPT='zsh: correct %F{red}%R%f to %F{green}%r%f [nyae]? '
|
||||
}
|
||||
|
||||
prompt_fred_setup "$@"
|
||||
|
Loading…
Reference in New Issue
Block a user