yes, even more ksh prompt fun... #tags mail So the next thing that bothered me about my prompt was the fact that sometimes I'd have some crazy long directory filling up 90% of the line - this was a bad thing. So I set out along with my companion, sed, and together we squashed this beast.
[ -w "/" ] && Z="#" || Z=">"; export Z
PROMPT='$(A=$?; [ $A -ne 0 ] && A="!!{$A}!! " || A=""; SPWD=$(/bin/pwd | \
/usr/bin/sed -Ee "s,(/usr)?$HOME,~,; s!!(/[^/]+/).*(/.{20,})$!!1...2!!"); \
/bin/echo -n $HOST"("$SPWD") [!] ${A}${Z} " )'

case $TERM in
   aterm|xterm|dtterm)
      PROMPT=${PROMPT%)*}'; /bin/echo -n "^[]2;"$HOST"("$SPWD") [!] ${A}^G" 1>&2)'
      ;;
esac
PS1=$PROMPT
The part marked in bold is what actually shortens the path. This will take what was previously a terribly long prompt and shorten the directory... ie;
/usr/local/lib/perl5/site_perl/5.6.1/Curses/UI/Dialog
will become
/usr/.../5.6.1/Curses/UI/Dialog

Oh, and this new feature actually makes the overal content of $PS1 shorter by 3 characters! Instead of 257 characters, it's 254. This is due to a rewrite of part of the code - pwd and sed are only called one time now.