2024-01-27 19:10:46 +00:00
|
|
|
# Set the title bar to user@host: pwd
|
|
|
|
_TITLE_BAR="\u@\h: \w"
|
|
|
|
_SET_TITLE_BAR="\[\e]0;$_TITLE_BAR\a\]"
|
|
|
|
# Shorten $HOME to ~ in PWD
|
|
|
|
_pwd_home () {
|
|
|
|
if [[ "$PWD" =~ ^"$HOME"(/|$) ]]; then
|
|
|
|
echo "~${PWD#$HOME}"
|
|
|
|
else
|
|
|
|
echo $PWD
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
# Shorten path dir names
|
|
|
|
_pwd () {
|
|
|
|
DIR=$(_pwd_home)
|
2024-01-31 00:06:09 +00:00
|
|
|
[ "$DIR" != "/" ] && [ "$DIR" != "~" ] && printf '%s/' $(dirname "$DIR" | tr / '\n' | cut -c-1)
|
|
|
|
printf "$(basename "$DIR")"
|
2024-01-27 19:10:46 +00:00
|
|
|
}
|
|
|
|
_DIR='$(_pwd)'
|
|
|
|
# Color codes
|
|
|
|
_GREEN="\[\033[1;32m\]"
|
|
|
|
_DIM="\[\e[92;2m\]"
|
|
|
|
_RESET="\[\e[0m\]"
|
|
|
|
# Nested shell level
|
|
|
|
_SHLVL=$(printf '\$%.0s' $(seq 1 $SHLVL))
|
|
|
|
# Build prompt
|
|
|
|
export PS1="$_SET_TITLE_BAR$_DIM[\A \u@\h:$_RESET$_GREEN$_DIR$_RESET$_DIM]$_SHLVL$_RESET "
|