# 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 and shorten other path dir names to one letter _pwd() { if [[ "$PWD" =~ ^"$HOME"($) ]]; then printf "~" elif [[ "$PWD" = "/" ]]; then printf "/" else if [[ "$PWD" =~ ^"$HOME"/ ]]; then printf "~" DIR="${PWD#$HOME}" else DIR="$PWD" fi for path_elem in $(dirname "$DIR" | tr / '\n' | grep . | cut -c-1); do printf '/%s' $path_elem done printf "/$(basename "$DIR")" fi } _DIR='$(_pwd)' # Color codes _GREEN="\[\033[32;1m\]" _DIM="\[\e[32;2m\]" _OLIVE="\[\e[33;2m\]" _RESET="\[\e[0m\]" _HOST=$(if [ -z "$SSH_CLIENT" ]; then echo $_DIM; else echo $_OLIVE; fi) # Nested shell level _SHLVL=$(printf '\$%.0s' $(seq 1 $SHLVL)) # SSH detection _SSH='$([ ! -z "$SSH_CLIENT" ] && echo "=>")' # Build prompt export PS1="$_SET_TITLE_BAR$_DIM[\A \u@$_RESET$_HOST\h$_DIM:$_RESET$_GREEN$_DIR$_RESET$_DIM]$_SHLVL$_RESET " export HISTCONTROL=ignoreboth # Suppress ssh completion from /etc/hosts # This used to be COMP_KNOWN_HOSTS_WITH_HOSTFILE so most search results refer to it under that name # This is necessary to avoid StevenBlack blocks appearing in ssh tab completions export BASH_COMPLETION_KNOWN_HOSTS_WITH_HOSTFILE=