For example working in:
/home/stuart/src/project/com/example/package
/usr/lib/python2.6
would appear as:
~/s/p/c/e/package$
/u/l/python2.6$
Try this:
export PS1='$(echo $(dirname \w)|sed -e "s;\(/.\)[^/]*;\1;g")/$(basename \w) $ '
export PS1='$(echo $(dirname \w)|sed -e "s;\(/\.\?.\)[^/]*;\1;g" -e "s;/h/s;~;")/\W\$ '
So that dot dirs keep a "." and a character. I also replace "/h/s" (/home/stuart) with a "~".
export PS1='$(echo $(dirname $(echo \w | sed "s;$HOME;~;"))/ |sed -e "s;\(/\.\?.\)[^/]*;\1;g" -e "s;/h/s;~;" -e "s;\./;;")\W\$ '
Adds some more hacks so that it looks good in the home dir.
Here is my go at it, based on Mat's answer. Avoids problems in corner cases such as /
and ~
.
PS1='`echo "${PWD%/*}" | sed -e "s;\(/.\)[^/]*;\1;g"`/${PWD##*/} \$ '
Replace .
with ..
to display 2 letters.