|
|
@ -54,114 +54,118 @@ function prompt_paradox_build_prompt {
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
if [[ -n "${python_info}" ]]; then
|
|
|
|
if [[ -n "${python_info}" ]]; then
|
|
|
|
prompt_paradox_start_segment yellow black '${python_info[ref]}${python_info[virtualenv]}'
|
|
|
|
prompt_paradox_start_segment yellow black '${python_info[ref]}${python_info[virtualenv]}'
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
prompt_paradox_end_segment
|
|
|
|
f [[ -n "${http_proxy}" ]]; then
|
|
|
|
}
|
|
|
|
prompt_paradox_start_segment blue black 'PROXY'
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
function prompt_paradox_pwd {
|
|
|
|
prompt_paradox_end_segment
|
|
|
|
local pwd="${PWD/#$HOME/~}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if [[ "$pwd" == (#m)[/~] ]]; then
|
|
|
|
|
|
|
|
_prompt_paradox_pwd="$MATCH"
|
|
|
|
|
|
|
|
unset MATCH
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
_prompt_paradox_pwd="${${${${(@j:/:M)${(@s:/:)pwd}##.#?}:h}%/}//\%/%%}/${${pwd:t}//\%/%%}"
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function prompt_paradox_print_elapsed_time {
|
|
|
|
unction prompt_paradox_pwd {
|
|
|
|
local end_time=$(( SECONDS - _prompt_paradox_start_time ))
|
|
|
|
local pwd="${PWD/#$HOME/~}"
|
|
|
|
local hours minutes seconds remainder
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (( end_time >= 3600 )); then
|
|
|
|
|
|
|
|
hours=$(( end_time / 3600 ))
|
|
|
|
|
|
|
|
remainder=$(( end_time % 3600 ))
|
|
|
|
|
|
|
|
minutes=$(( remainder / 60 ))
|
|
|
|
|
|
|
|
seconds=$(( remainder % 60 ))
|
|
|
|
|
|
|
|
print -P "%B%F{red}>>> elapsed time ${hours}h${minutes}m${seconds}s%b"
|
|
|
|
|
|
|
|
elif (( end_time >= 60 )); then
|
|
|
|
|
|
|
|
minutes=$(( end_time / 60 ))
|
|
|
|
|
|
|
|
seconds=$(( end_time % 60 ))
|
|
|
|
|
|
|
|
print -P "%B%F{yellow}>>> elapsed time ${minutes}m${seconds}s%b"
|
|
|
|
|
|
|
|
elif (( end_time > 10 )); then
|
|
|
|
|
|
|
|
print -P "%B%F{green}>>> elapsed time ${end_time}s%b"
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function prompt_paradox_precmd {
|
|
|
|
if [[ "$pwd" == (#m)[/~] ]]; then
|
|
|
|
setopt LOCAL_OPTIONS
|
|
|
|
_prompt_paradox_pwd="$MATCH"
|
|
|
|
unsetopt XTRACE KSH_ARRAYS
|
|
|
|
unset MATCH
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
_prompt_paradox_pwd="${${${${(@j:/:M)${(@s:/:)pwd}##.#?}:h}%/}//\%/%%}/${${pwd:t}//\%/%%}"
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
# Format PWD.
|
|
|
|
|
|
|
|
prompt_paradox_pwd
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Get Git repository information.
|
|
|
|
unction prompt_paradox_print_elapsed_time {
|
|
|
|
if (( $+functions[git-info] )); then
|
|
|
|
local end_time=$(( SECONDS - _prompt_paradox_start_time ))
|
|
|
|
git-info
|
|
|
|
local hours minutes seconds remainder
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Get Virtual env info
|
|
|
|
if (( end_time >= 3600 )); then
|
|
|
|
if (( $+functions[python-info] )); then
|
|
|
|
hours=$(( end_time / 3600 ))
|
|
|
|
python-info
|
|
|
|
remainder=$(( end_time % 3600 ))
|
|
|
|
fi
|
|
|
|
minutes=$(( remainder / 60 ))
|
|
|
|
|
|
|
|
seconds=$(( remainder % 60 ))
|
|
|
|
|
|
|
|
print -P "%B%F{red}>>> elapsed time ${hours}h${minutes}m${seconds}s%b"
|
|
|
|
|
|
|
|
elif (( end_time >= 60 )); then
|
|
|
|
|
|
|
|
minutes=$(( end_time / 60 ))
|
|
|
|
|
|
|
|
seconds=$(( end_time % 60 ))
|
|
|
|
|
|
|
|
print -P "%B%F{yellow}>>> elapsed time ${minutes}m${seconds}s%b"
|
|
|
|
|
|
|
|
elif (( end_time > 10 )); then
|
|
|
|
|
|
|
|
print -P "%B%F{green}>>> elapsed time ${end_time}s%b"
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
# Calculate and print the elapsed time.
|
|
|
|
|
|
|
|
prompt_paradox_print_elapsed_time
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function prompt_paradox_preexec {
|
|
|
|
unction prompt_paradox_precmd {
|
|
|
|
_prompt_paradox_start_time="$SECONDS"
|
|
|
|
setopt LOCAL_OPTIONS
|
|
|
|
}
|
|
|
|
unsetopt XTRACE KSH_ARRAYS
|
|
|
|
|
|
|
|
|
|
|
|
function prompt_paradox_setup {
|
|
|
|
# Format PWD.
|
|
|
|
setopt LOCAL_OPTIONS
|
|
|
|
prompt_paradox_pwd
|
|
|
|
unsetopt XTRACE KSH_ARRAYS
|
|
|
|
|
|
|
|
prompt_opts=(cr percent subst)
|
|
|
|
# Get Git repository information.
|
|
|
|
|
|
|
|
if (( $+functions[git-info] )); then
|
|
|
|
# Load required functions.
|
|
|
|
git-info
|
|
|
|
autoload -Uz add-zsh-hook
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
# Add hook for calling git-info before each command.
|
|
|
|
|
|
|
|
add-zsh-hook preexec prompt_paradox_preexec
|
|
|
|
|
|
|
|
add-zsh-hook precmd prompt_paradox_precmd
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Set editor-info parameters.
|
|
|
|
|
|
|
|
zstyle ':prezto:module:editor:info:completing' format '%B%F{red}...%f%b'
|
|
|
|
|
|
|
|
zstyle ':prezto:module:editor:info:keymap:primary' format '%B%F{blue}❯%f%b'
|
|
|
|
|
|
|
|
zstyle ':prezto:module:editor:info:keymap:primary:overwrite' format '%F{red}♺%f'
|
|
|
|
|
|
|
|
zstyle ':prezto:module:editor:info:keymap:alternate' format '%B%F{red}❮%f%b'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Set git-info parameters.
|
|
|
|
|
|
|
|
zstyle ':prezto:module:git:info' verbose 'yes'
|
|
|
|
|
|
|
|
zstyle ':prezto:module:git:info:action' format ' ⁝ %s'
|
|
|
|
|
|
|
|
zstyle ':prezto:module:git:info:added' format ' ✚'
|
|
|
|
|
|
|
|
zstyle ':prezto:module:git:info:ahead' format ' ⬆'
|
|
|
|
|
|
|
|
zstyle ':prezto:module:git:info:behind' format ' ⬇'
|
|
|
|
|
|
|
|
zstyle ':prezto:module:git:info:branch' format ' %b'
|
|
|
|
|
|
|
|
zstyle ':prezto:module:git:info:commit' format '➦ %.7c'
|
|
|
|
|
|
|
|
zstyle ':prezto:module:git:info:deleted' format ' ✖'
|
|
|
|
|
|
|
|
zstyle ':prezto:module:git:info:dirty' format ' ⁝'
|
|
|
|
|
|
|
|
zstyle ':prezto:module:git:info:modified' format ' ✱'
|
|
|
|
|
|
|
|
zstyle ':prezto:module:git:info:position' format '%p'
|
|
|
|
|
|
|
|
zstyle ':prezto:module:git:info:renamed' format ' ➙'
|
|
|
|
|
|
|
|
zstyle ':prezto:module:git:info:stashed' format ' S'
|
|
|
|
|
|
|
|
zstyle ':prezto:module:git:info:unmerged' format ' ═'
|
|
|
|
|
|
|
|
zstyle ':prezto:module:git:info:untracked' format ' ?'
|
|
|
|
|
|
|
|
zstyle ':prezto:module:git:info:keys' format \
|
|
|
|
|
|
|
|
'ref' '$(coalesce "%b" "%p" "%c")' \
|
|
|
|
|
|
|
|
'status' '%s%D%A%B%S%a%d%m%r%U%u'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Set python-info parameters.
|
|
|
|
|
|
|
|
zstyle ':prezto:module:python:info:virtualenv' format '%F{black}py:%v%f'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Define prompts.
|
|
|
|
|
|
|
|
PROMPT='
|
|
|
|
|
|
|
|
${(e)$(prompt_paradox_build_prompt)}
|
|
|
|
|
|
|
|
${editor_info[keymap]} '
|
|
|
|
|
|
|
|
RPROMPT='%F{blue}[%F{green}%D{%H:%M:%S}%F{blue}]%f'
|
|
|
|
|
|
|
|
SPROMPT='zsh: correct %F{red}%R%f to %F{green}%r%f [nyae]? '
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
prompt_paradox_setup "$@"
|
|
|
|
# Get Virtual env info
|
|
|
|
|
|
|
|
if (( $+functions[python-info] )); then
|
|
|
|
|
|
|
|
python-info
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Calculate and print the elapsed time.
|
|
|
|
|
|
|
|
prompt_paradox_print_elapsed_time
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
unction prompt_paradox_preexec {
|
|
|
|
|
|
|
|
_prompt_paradox_start_time="$SECONDS"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
unction prompt_paradox_setup {
|
|
|
|
|
|
|
|
setopt LOCAL_OPTIONS
|
|
|
|
|
|
|
|
unsetopt XTRACE KSH_ARRAYS
|
|
|
|
|
|
|
|
prompt_opts=(cr percent subst)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Load required functions.
|
|
|
|
|
|
|
|
autoload -Uz add-zsh-hook
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Add hook for calling git-info before each command.
|
|
|
|
|
|
|
|
add-zsh-hook preexec prompt_paradox_preexec
|
|
|
|
|
|
|
|
add-zsh-hook precmd prompt_paradox_precmd
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Set editor-info parameters.
|
|
|
|
|
|
|
|
zstyle ':prezto:module:editor:info:completing' format '%B%F{red}...%f%b'
|
|
|
|
|
|
|
|
zstyle ':prezto:module:editor:info:keymap:primary' format '%B%F{blue}❯%f%b'
|
|
|
|
|
|
|
|
zstyle ':prezto:module:editor:info:keymap:primary:overwrite' format '%F{red}♺%f'
|
|
|
|
|
|
|
|
zstyle ':prezto:module:editor:info:keymap:alternate' format '%B%F{red}❮%f%b'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Set git-info parameters.
|
|
|
|
|
|
|
|
zstyle ':prezto:module:git:info' verbose 'yes'
|
|
|
|
|
|
|
|
zstyle ':prezto:module:git:info:action' format ' ⁝ %s'
|
|
|
|
|
|
|
|
zstyle ':prezto:module:git:info:added' format ' ✚'
|
|
|
|
|
|
|
|
zstyle ':prezto:module:git:info:ahead' format ' ⬆'
|
|
|
|
|
|
|
|
zstyle ':prezto:module:git:info:behind' format ' ⬇'
|
|
|
|
|
|
|
|
zstyle ':prezto:module:git:info:branch' format ' %b'
|
|
|
|
|
|
|
|
zstyle ':prezto:module:git:info:commit' format '➦ %.7c'
|
|
|
|
|
|
|
|
zstyle ':prezto:module:git:info:deleted' format ' ✖'
|
|
|
|
|
|
|
|
zstyle ':prezto:module:git:info:dirty' format ' ⁝'
|
|
|
|
|
|
|
|
zstyle ':prezto:module:git:info:modified' format ' ✱'
|
|
|
|
|
|
|
|
zstyle ':prezto:module:git:info:position' format '%p'
|
|
|
|
|
|
|
|
zstyle ':prezto:module:git:info:renamed' format ' ➙'
|
|
|
|
|
|
|
|
zstyle ':prezto:module:git:info:stashed' format ' S'
|
|
|
|
|
|
|
|
zstyle ':prezto:module:git:info:unmerged' format ' ═'
|
|
|
|
|
|
|
|
zstyle ':prezto:module:git:info:untracked' format ' ?'
|
|
|
|
|
|
|
|
zstyle ':prezto:module:git:info:keys' format \
|
|
|
|
|
|
|
|
'ref' '$(coalesce "%b" "%p" "%c")' \
|
|
|
|
|
|
|
|
'status' '%s%D%A%B%S%a%d%m%r%U%u'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Set python-info parameters.
|
|
|
|
|
|
|
|
zstyle ':prezto:module:python:info:virtualenv' format '%F{black}py:%v%f'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Define prompts.
|
|
|
|
|
|
|
|
PROMPT='
|
|
|
|
|
|
|
|
${(e)$(prompt_paradox_build_prompt)}
|
|
|
|
|
|
|
|
${editor_info[keymap]} '
|
|
|
|
|
|
|
|
RPROMPT='%F{blue}[%F{green}%D{%H:%M:%S}%F{blue}]%f'
|
|
|
|
|
|
|
|
SPROMPT='zsh: correct %F{red}%R%f to %F{green}%r%f [nyae]? '
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
prompt_paradox_setup "$@"
|
|
|
|