|
# vim: set ft=bash: |
|
# shellcheck shell=bash |
|
|
|
source "/usr/local/opt/zsh-git-prompt/zshrc.sh" |
|
|
|
# shellcheck source=cli.sh |
|
source "$HOME/share/cli.sh" |
|
|
|
# shellcheck source=colors.sh |
|
source "$HOME/share/colors.sh" |
|
|
|
BOLD='%B' # bold mode |
|
NORMAL='%b' # normal mode |
|
|
|
# In lieu of descriptive names, use mostly consistent naming convention. |
|
# Descriptive name, plus context as a character. The exception is actual |
|
# characters, which have the type first. Because short names are nicer when all |
|
# you're doing is string concatenation. |
|
cL='»' # Left prompt character |
|
cR='«' # Right prompt character |
|
cLT='❮' # "Less Than" parenthesis character |
|
cGT='❯' # "Greater Than" parenthesis character |
|
|
|
spbC='31' # super pretty blue Color |
|
|
|
branchC="$ORANGE" # branch Color |
|
branchM="$BOLD" # branch Mode |
|
cmdC="$spbC" # comand Color |
|
cmdM="$NORMAL" # comand Mode |
|
dirC="$BLUE" # directory Color |
|
dirC="$spbC" # directory Color |
|
dirM="$BOLD" # directory Mode |
|
promptC="$bWHITE" # prompt Color |
|
promptM="$BOLD" # prompt Mode |
|
|
|
prL="$promptM%F{$bWHITE}$cL " # Left prompt |
|
prR=" $promptM%F{$bWHITE}$cR" # Right prompt |
|
prF="%F{$YELLOW}$cLT%F{$RED}%?%F{$YELLOW}$cGT " # prompt, prev cmd Failed |
|
|
|
ZSH_THEME_GIT_PROMPT_PREFIX='' |
|
ZSH_THEME_GIT_PROMPT_SUFFIX='' |
|
ZSH_THEME_GIT_PROMPT_SEPARATOR=' ' |
|
ZSH_THEME_GIT_PROMPT_BRANCH="%{$branchM%F{$branchC}%}" |
|
|
|
function e0da_prompt() { |
|
if git rev-parse --is-inside-work-tree &>/dev/null; then |
|
git_status=$(git_super_status | tr -d "\n") |
|
git_ref=$(echo "$git_status" | awk '{ print $1 }') |
|
git_status=$(echo "$git_status" | awk '{ print $2 }') |
|
echo -en "$git_status$git_ref" |
|
fi |
|
echo -en "$prR%F{$dirC}%~" |
|
} |
|
|
|
# Print the index-th digit of digits, e.g. $(d 245 2) => 4 |
|
d() { |
|
local digits; digits="$1"; shift |
|
local index; index="$1"; shift |
|
echo "$digits" | awk "{print \$$index}" | tr -d "\n" |
|
} |
|
|
|
rainbow_timestamp() { |
|
local out |
|
local t; t=$(date +'%H%M%S' | sed -E 's/(.)/\1 /g') |
|
out="%F{ $RED }$(d "$t" 1)" |
|
out="$out%F{$ORANGE}$(d "$t" 2)" |
|
out="$out%F{$YELLOW}$(d "$t" 3)" |
|
out="$out%F{$GREEN }$(d "$t" 4)" |
|
out="$out%F{$BLUE }$(d "$t" 5)" |
|
out="$out%F{$VIOLET}$(d "$t" 6)" |
|
echo -en "$out" | tr -d "\n" |
|
} |
|
|
|
export PROMPT="%B\$(rainbow_timestamp)%(?.$prL.$prF)$cmdM%F{$cmdC}" |
|
|
|
export RPROMPT="\$(e0da_prompt)%b%f" |
|
|
|
# Restore text color before output begins |
|
# https://stackoverflow.com/questions/9268836/zsh-change-prompt-input-color |
|
preexec () { echo -ne "\e[0m" } |