# Bash shortener
_PS1 ()
{
local PRE= NAME="$1" LENGTH="$2";
[[ "$NAME" != "${NAME#$HOME/}" || -z "${NAME#$HOME}" ]] &&
PRE+='~' NAME="${NAME#$HOME}" LENGTH=$[LENGTH-1];
((${#NAME}>$LENGTH)) && NAME="/...${NAME:$[${#NAME}-LENGTH+4]}";
echo "$PRE$NAME"
}
PS1=' \[\e[0m\]\u\[\e[0;32m\]@\[\e[0m\]\h \[\e[0;32m\]$(_PS1 "$PWD" 30) \[\e[0m\]$ 'It will shorten the path in your bash prompt to 30 chars.