Skip to content

Instantly share code, notes, and snippets.

@sreilly
Created June 4, 2015 08:51
Show Gist options
  • Save sreilly/bd9e7b19760163b3caa8 to your computer and use it in GitHub Desktop.
Save sreilly/bd9e7b19760163b3caa8 to your computer and use it in GitHub Desktop.
# add this to your ~/.profile for a wonderful prompt
function truncate_pwd
{
newPWD="${PWD/#$HOME/~}"
local pwdmaxlen=20
if [ ${#newPWD} -gt $pwdmaxlen ]
then
newPWD=".+${newPWD: -$pwdmaxlen}"
fi
# put "user@host:path" in the window title bar
echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"
}
PROMPT_COMMAND=truncate_pwd
PS1='\[$(tput bold)\]\u\[$(tput sgr0)\]@\[$(tput bold)\]\h\[$(tput sgr0)\] ${newPWD}\[$(tput bold)\]:\[$(tput sgr0)\] '
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment