# ======== Custom prompt # Define colors for readability # black="\[\033[0;30;49m\]" # blackgrey="\[\033[30;47m\]" _RED="\[\033[31;49m\]" _GREEN="\[\033[32;49m\]" # yellow="\[\033[33;49m\]" _BLUE="\[\033[34;49m\]" # magenta="\[\033[35;49m\]" # cyan="\[\033[36;49m\]" _WHITE="\[\033[37;49m\]" r_color="\[\033[0m\]" # Reset color # clr="\[\033[K\]" # Clear to the end of the line ## Returns short path (last two directories) ## replace \w with \$(spwd) to use it spwd() { ( IFS=/ set $PWD if test $# -le 3 ; then echo "$PWD" else eval echo "…€¦\${$(($#-1))}/\${$#}" fi ) } _HOST="@\h" if [ "${UID}" -eq 0 ]; then ## shouldnt allow root login in ssh anyway, so commented out # [[ $SSH_CONNECTION ]] && _HOST="${_HOST}" _USER="$_RED\u$_HOST" else [[ $SSH_CONNECTION ]] && _HOST="${_RED}${_HOST}" _USER="$_GREEN\u$_HOST" fi PS1="$_USER [\w]$r_color " unset _USER r_color _RED _BLUE _GREEN _HOST