6 Sep
2009
6 Sep
'09
9:43 a.m.
Hi, I just finished writing a fancier prompt for bash, which showing directories in an abbreviated form just like the fish shell does. function _prompt { _dir_abbr=$(temp=$(echo "${PWD/$HOME/~}" |sed -r 's/(\/.)[^/]*/\1/g'); echo ${temp:0:$(( ${#temp} - 1 ))}) _ps1="$(basename "${PWD/$HOME/~}")" if [ ${#_ps1} -gt 25 ]; then _ps1="${_ps1:0:7}...${_ps1: -7}" fi echo -n "$_dir_abbr$_ps1" } just quote the function in the $PS1 like this (e.g.): PS1='$(_prompt)] ' enjoy!