Created
May 31, 2017 17:21
-
-
Save con-f-use/e7da6c52dde12f8324a49c5cd46463ca to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Wrapper to use liquidprompt with bashit | |
# The path to this file should read '$BASH_IT/themes/liquidprompt/liquidprompt.theme.bash' | |
targetdir="$BASH_IT/themes/liquidprompt/liquidprompt" | |
gray="\[\e[1;90m\]" | |
# Get liquidprompt if not yet installed | |
cwd="$PWD" | |
if cd "$targetdir" &>/dev/null && git rev-parse --is-inside-work-tree &>/dev/null; then | |
true | |
else | |
prompt() { : ; } # In case next command fails | |
git clone https://github.com/nojhan/liquidprompt.git "$targetdir" && \ | |
echo -e "Successfully cloned liquidprompt!\n More configuration in '$targetdir/liquid.theme'." || \ | |
{ >&2 echo -e "${red}Error: Could not download liquidpromt. Please use another theme!${normal}"; return; } | |
fi | |
cd "$cwd" | |
export LP_ENABLE_TIME=1 | |
source "$targetdir/liquidprompt" | |
prompt() { : ; } | |
export PS2=" ┃ " | |
export LP_PS1_PREFIX="┌─" | |
export LP_PS1_POSTFIX="\n└▪ " | |
export LP_ENABLE_RUNTIME=0 | |
_lp_git_branch() | |
{ | |
(( LP_ENABLE_GIT )) || return | |
\git rev-parse --is-inside-work-tree >/dev/null 2>&1 || return | |
local branch | |
# Recent versions of Git support the --short option for symbolic-ref, but | |
# not 1.7.9 (Ubuntu 12.04) | |
if branch="$(\git symbolic-ref -q HEAD)"; then | |
_lp_escape "$(\git rev-parse --short=5 -q HEAD):${branch#refs/heads/}" | |
else | |
# In detached head state, use commit instead | |
# No escape needed | |
\git rev-parse --short -q HEAD | |
fi | |
} | |
_lp_time() { | |
if (( LP_ENABLE_TIME )); then | |
if (( LP_TIME_ANALOG )); then | |
typeset -i _LP_CLOCK_PREV=-1 | |
_LP_CLOCK=(🕐 🕜 🕑 🕝 🕒 🕞 🕓 🕟 🕔 🕠 🕕 🕡 🕖 🕢 🕗 🕣 🕘 🕤 🕙 🕥 🕚 🕦 🕛 🕧 ) | |
_lp_time() | |
{ | |
local hhmm="$(date "+hh=%I mm=%M")" | |
local -i hh mm clock | |
eval ${hhmm//=0/=} | |
if (( ( clock=((hh*60+mm-45)/30)%24 ) != _LP_CLOCK_PREV )); then | |
LP_TIME="${LP_COLOR_TIME}${_LP_CLOCK[clock+_LP_FIRST_INDEX]} ${NO_COL} " | |
_LP_CLOCK_PREV=clock | |
fi | |
} | |
else | |
LP_TIME="${gray}$(date +%d-%H:%M)${normal}" | |
fi | |
else | |
LP_TIME="" | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment