I implemented a prompt path shortener for bash to be included in the PS1 environment variable, which shortens the working directory into something more compact but still descriptive. I'm curious what other ideas may exist.

Here's the challenge:

Create a bash function _dir_chomp which can be included into PS1 like this (line breaks inserted for readability):

It's allowed to call external interpreters like awk, perl, ruby, python but not compiled C programs or similar. In other words: external source files are not allowed, code must be inline. Shortest version wins. The length of the bash function body (and called sub functions) counts, means:

Allowing awk, perl, ruby and python is not a good idea for this challenge: a prompt must not just be short in code, it should be light in external programs loaded (fork+exec) to stay fast.
–
dolmenSep 11 '12 at 21:52