Added simple theme for report server.

Its largely based on jackharrisonsherlock's common prompt, but has some
different namespacing, a deterministic prompt color based on the
hostname, and a few other minor changes.

My plan is to add async git info to this, but this is the MVP for this.
This commit is contained in:
James Patrick 2019-12-20 10:09:45 -05:00
parent af4a00dd3e
commit 40d8b3fdf3
2 changed files with 69 additions and 4 deletions

58
zsh/modules/prompt/uncommon.zsh Executable file
View File

@ -0,0 +1,58 @@
autoload -U colors \
&& colors
_UNCOMMON_COLOR_CURRENT_DIR=blue
_UNCOMMON_COLOR_RETURN_TRUE=yellow
_UNCOMMON_COLOR_RETURN_FALSE=red
_UNCOMMON_COLOR_BG_JOBS=yellow
_UNCOMMON_PROMPT_SYMBOL=${_UNCOMMON_PROMPT_SYMBOL:-''}
if [ -z "$_UNCOMMON_HOSTNAME_COLOR" ] ; then
if [ -z "$_UNCOMMON_PROMPT_COLORS" ] ; then
_UNCOMMON_PROMPT_COLORS=(
$fg[blue]
$fg[cyan]
$fg[green]
$fg[magenta]
$fg[red]
$fg[white]
$fg[yellow]
)
fi
local DETERMINISTIC_INT=$(( $(hostname | cksum | sed 's/[^0-9]*//g') % ${#_UNCOMMON_PROMPT_COLORS[@]} ))
export _UNCOMMON_HOSTNAME_COLOR=${_UNCOMMON_PROMPT_COLORS[$DETERMINISTIC_INT]}
fi
PROMPT='$(_uncommon_host)$(_uncommon_current_dir)$(_uncommon_return_status)'
RPROMPT='$(_uncommon_time)'
_uncommon_host(){
if [[ -n $SSH_CONNECTION ]]; then
me="%n@%m"
elif [[ "$LOGNAME" != "$USER" ]]; then
me="%n"
fi
if [[ -n $me ]]; then
echo "%{${_UNCOMMON_HOSTNAME_COLOR}%}$me%{$reset_color%}:"
fi
}
_uncommon_current_dir(){
echo -n "%{$fg[$_UNCOMMON_COLOR_CURRENT_DIR]%}%c "
}
_uncommon_return_status() {
echo -n "%(?.%F{$_UNCOMMON_COLOR_RETURN_TRUE}.%F{$_UNCOMMON_COLOR_RETURN_FALSE})$_UNCOMMON_PROMPT_SYMBOL%f "
}
_uncommon_bg_jobs() {
bg_status="%{$fg[$_UNCOMMON_COLOR_BG_JOBS]%}%(1j.↓%j .)"
echo -n $bg_status
}
_uncommon_time(){
echo "%F{red} %D{%L:%M:%S}%r%f"
}

View File

@ -60,10 +60,17 @@ zplug "${ZDIR}/modules/alias/", \
from:local, \
as:plugin
zplug "denysdovhan/spaceship-prompt", \
use:spaceship.zsh, \
from:github, \
as:theme
if [ -z "$SSH_CONNECTION" ] ; then
zplug "${ZDIR}/modules/prompt/",\
from:local,\
use:uncommon.zsh, \
as:theme
else
zplug "denysdovhan/spaceship-prompt", \
use:spaceship.zsh, \
from:github, \
as:theme
fi
env_loader zplug