2014-10-18 15:30:07 +00:00
|
|
|
|
#
|
|
|
|
|
# A two-line, Powerline-inspired theme that displays contextual information.
|
|
|
|
|
#
|
|
|
|
|
# This theme requires a patched Powerline font, get them from
|
|
|
|
|
# https://github.com/Lokaltog/powerline-fonts.
|
|
|
|
|
#
|
|
|
|
|
# Authors:
|
|
|
|
|
# Isaac Wolkerstorfer <i@agnoster.net>
|
|
|
|
|
# Jeff Sandberg <paradox460@gmail.com>
|
|
|
|
|
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
2017-04-15 23:44:05 +00:00
|
|
|
|
# Patrick Bos <egpbos@gmail.com>
|
2014-10-18 15:30:07 +00:00
|
|
|
|
#
|
|
|
|
|
# Screenshots:
|
|
|
|
|
# http://i.imgur.com/0XIWX.png
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
# Load dependencies.
|
|
|
|
|
pmodload 'helper'
|
|
|
|
|
|
|
|
|
|
# Define variables.
|
|
|
|
|
_prompt_paradox_current_bg='NONE'
|
2014-12-03 22:30:52 +00:00
|
|
|
|
_prompt_paradox_segment_separator=''
|
2014-10-18 15:30:07 +00:00
|
|
|
|
_prompt_paradox_start_time=$SECONDS
|
|
|
|
|
|
|
|
|
|
function prompt_paradox_start_segment {
|
|
|
|
|
local bg fg
|
|
|
|
|
[[ -n "$1" ]] && bg="%K{$1}" || bg="%k"
|
|
|
|
|
[[ -n "$2" ]] && fg="%F{$2}" || fg="%f"
|
|
|
|
|
if [[ "$_prompt_paradox_current_bg" != 'NONE' && "$1" != "$_prompt_paradox_current_bg" ]]; then
|
|
|
|
|
print -n " $bg%F{$_prompt_paradox_current_bg}$_prompt_paradox_segment_separator$fg "
|
|
|
|
|
else
|
|
|
|
|
print -n "$bg$fg "
|
|
|
|
|
fi
|
|
|
|
|
_prompt_paradox_current_bg="$1"
|
|
|
|
|
[[ -n "$3" ]] && print -n "$3"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function prompt_paradox_end_segment {
|
|
|
|
|
if [[ -n "$_prompt_paradox_current_bg" ]]; then
|
|
|
|
|
print -n " %k%F{$_prompt_paradox_current_bg}$_prompt_paradox_segment_separator"
|
|
|
|
|
else
|
|
|
|
|
print -n "%k"
|
|
|
|
|
fi
|
|
|
|
|
print -n "%f"
|
|
|
|
|
_prompt_paradox_current_bg=''
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function prompt_paradox_build_prompt {
|
|
|
|
|
prompt_paradox_start_segment black default '%(?::%F{red}✘ )%(!:%F{yellow}⚡ :)%(1j:%F{cyan}⚙ :)%F{blue}%n%F{red}@%F{green}%m%f'
|
|
|
|
|
prompt_paradox_start_segment blue black '$_prompt_paradox_pwd'
|
|
|
|
|
|
|
|
|
|
if [[ -n "$git_info" ]]; then
|
|
|
|
|
prompt_paradox_start_segment green black '${(e)git_info[ref]}${(e)git_info[status]}'
|
|
|
|
|
fi
|
|
|
|
|
|
2015-11-29 15:52:04 +00:00
|
|
|
|
if [[ -n "$python_info" ]]; then
|
|
|
|
|
prompt_paradox_start_segment white black '${(e)python_info[virtualenv]}'
|
|
|
|
|
fi
|
|
|
|
|
|
2014-10-18 15:30:07 +00:00
|
|
|
|
prompt_paradox_end_segment
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-29 15:42:55 +00:00
|
|
|
|
prompt_paradox_print_elapsed_time() {
|
2014-10-18 15:30:07 +00:00
|
|
|
|
local end_time=$(( SECONDS - _prompt_paradox_start_time ))
|
|
|
|
|
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 {
|
|
|
|
|
setopt LOCAL_OPTIONS
|
|
|
|
|
unsetopt XTRACE KSH_ARRAYS
|
|
|
|
|
|
|
|
|
|
# Format PWD.
|
2017-07-21 00:08:19 +00:00
|
|
|
|
_prompt_paradox_pwd=$(prompt-pwd)
|
2014-10-18 15:30:07 +00:00
|
|
|
|
|
|
|
|
|
# Get Git repository information.
|
|
|
|
|
if (( $+functions[git-info] )); then
|
|
|
|
|
git-info
|
|
|
|
|
fi
|
|
|
|
|
|
2017-04-15 23:44:05 +00:00
|
|
|
|
# Get Python environment information.
|
|
|
|
|
if (( $+functions[python-info] )); then
|
|
|
|
|
python-info
|
|
|
|
|
fi
|
|
|
|
|
|
2014-10-18 15:30:07 +00:00
|
|
|
|
# Calculate and print the elapsed time.
|
|
|
|
|
prompt_paradox_print_elapsed_time
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function prompt_paradox_preexec {
|
|
|
|
|
_prompt_paradox_start_time="$SECONDS"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function prompt_paradox_setup {
|
|
|
|
|
setopt LOCAL_OPTIONS
|
|
|
|
|
unsetopt XTRACE KSH_ARRAYS
|
2017-08-10 18:23:26 +00:00
|
|
|
|
prompt_opts=(cr percent sp subst)
|
2014-10-18 15:30:07 +00:00
|
|
|
|
|
|
|
|
|
# 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
|
|
|
|
|
|
2019-07-25 22:14:43 +00:00
|
|
|
|
# Tell prezto we can manage this prompt
|
|
|
|
|
zstyle ':prezto:module:prompt' managed 'yes'
|
|
|
|
|
|
2014-10-18 15:30:07 +00:00
|
|
|
|
# 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 ' ⬇'
|
2014-12-03 22:30:52 +00:00
|
|
|
|
zstyle ':prezto:module:git:info:branch' format ' %b'
|
2014-10-18 15:30:07 +00:00
|
|
|
|
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'
|
|
|
|
|
|
2015-11-29 15:52:04 +00:00
|
|
|
|
# %v - virtualenv name.
|
|
|
|
|
zstyle ':prezto:module:python:info:virtualenv' format 'virtualenv:%v'
|
|
|
|
|
|
2014-10-18 15:30:07 +00:00
|
|
|
|
# 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 "$@"
|
2019-07-25 22:14:43 +00:00
|
|
|
|
# vim: ft=zsh
|