Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
8400af9b8b |
53
fred-prompt.zsh-theme
Normal file
53
fred-prompt.zsh-theme
Normal file
@ -0,0 +1,53 @@
|
||||
# -*-mode: sh-*-
|
||||
# My mess of various themes
|
||||
|
||||
# use extended color palette if available
|
||||
: ${USER_COLOR=magenta}
|
||||
: ${HOST_COLOR=yellow}
|
||||
: ${PWD_COLOR=green}
|
||||
: ${BRANCH_COLOR=yellow}
|
||||
: ${DIRTY_COLOR=yellow}
|
||||
|
||||
setopt nopromptbang promptcr promptpercent promptsp promptsubst
|
||||
|
||||
if [[ $(locale charmap) != UTF-8 || "$TERM" == linux ]]
|
||||
then
|
||||
ERROR_CHAR=''
|
||||
DIRTY_CHAR="*"
|
||||
PREFIX='$'
|
||||
else
|
||||
ERROR_CHAR='⏎'
|
||||
DIRTY_CHAR="∆" # U+2206
|
||||
PREFIX="❱" # U+2771
|
||||
fi
|
||||
|
||||
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}"
|
||||
}
|
||||
|
||||
typeset -gA git_info
|
||||
if (( ${+functions[git-info]} )); then
|
||||
zstyle ':zim:git-info' verbose yes
|
||||
zstyle ':zim:git-info:branch' format '%b'
|
||||
zstyle ':zim:git-info:commit' format '%c'
|
||||
zstyle ':zim:git-info:action' format '%b%f:%F{${INDEXED_COLOR}}%B%a'
|
||||
zstyle ':zim:git-info:dirty' format '%F{${INDEXED_COLOR}}${DIRTY_CHAR}%f'
|
||||
if [[ -n ${STASHED_IND} ]]; then
|
||||
zstyle ':zim:git-info:stashed' format '%F{${STASHED_COLOR}}${STASHED_IND}'
|
||||
fi
|
||||
zstyle ':zim:git-info:keys' format \
|
||||
'prompt' ' %F{${BRANCH_COLOR}}%b%c%f%S%f%s' \
|
||||
'rprompt' ' %D'
|
||||
|
||||
autoload -Uz add-zsh-hook && add-zsh-hook precmd git-info
|
||||
fi
|
||||
|
||||
# Define prompts.
|
||||
PS1='$(prompt_context)%F{cyan} %$((($COLUMNS-20) / 4 ))<..<%~%f${(e)git_info[prompt]}%(!. %B%F{red}#%f%b.)%B%F{cyan}${PREFIX}%f%b '
|
||||
RPS1='${editor_info[overwrite]}%(?:: %F{red}%?'$ERROR_CHAR'%f) ${(e)git_info[rprompt]}'
|
@ -1,101 +0,0 @@
|
||||
# -*-mode: sh-*-
|
||||
# My mess of various themes
|
||||
|
||||
setopt PROMPT_SUBST #allows prompt substitutions
|
||||
if [[ $(locale charmap) != UTF-8 || "$TERM" == linux ]]
|
||||
then
|
||||
ERROR_CHAR=''
|
||||
GIT_DIRTY_CHAR="*"
|
||||
PREFIX='$'
|
||||
LCOLOR=""
|
||||
else
|
||||
ERROR_CHAR='⏎'
|
||||
GIT_DIRTY_CHAR="∆" # U+2206
|
||||
PREFIX="❱" # U+2771
|
||||
LCOLOR="$fg_bold[black]"
|
||||
fi
|
||||
|
||||
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}"
|
||||
}
|
||||
|
||||
prompt_git_dirty () {
|
||||
[[ "$(git rev-parse --is-inside-work-tree)" == "true" && \
|
||||
-n "$(git status --porcelain --ignore-submodules)" ]]
|
||||
}
|
||||
|
||||
rprompt_git() {
|
||||
ref=${vcs_info_msg_0_}
|
||||
if [[ -n ${ref} ]]; then
|
||||
if prompt_git_dirty; then
|
||||
print '%F{yellow}'$GIT_DIRTY_CHAR'%f'
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Git: branch/detached head, dirty status
|
||||
prompt_git() {
|
||||
local color ref
|
||||
ref=${vcs_info_msg_0_}
|
||||
if [[ -n ${ref} ]]; then
|
||||
if prompt_git_dirty; then
|
||||
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
|
||||
|
||||
#Terminal Title
|
||||
print -Pn "\e]0;%~:zsh\a"
|
||||
}
|
||||
|
||||
function prompt_fred_preexec {
|
||||
#Terminal Title
|
||||
print -Pn '\e]0;%~:${1}\a'
|
||||
}
|
||||
|
||||
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
|
||||
add-zsh-hook preexec prompt_fred_preexec
|
||||
|
||||
# Define prompts.
|
||||
PROMPT='$(prompt_context)%F{cyan} %${PWDWIDTH}<..<%~%f$(prompt_git)$(prompt_prefix)'
|
||||
RPROMPT='${editor_info[overwrite]}%(?:: %F{red}%?'$ERROR_CHAR'%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