nojhan/liquidprompt — pull request #235 by polyphemus (2013-11-30 23:29:50+00:00)
Title: fix promblematic shorten path function

I have a few problems with the current implementation of the shorten path function of liquidprompt:
* It does not produce the same results on for bash and zsh.
* It does not respect it's maximum length.
* For specific cases inserts the elipsis when it only lengths the path.
* For specific cases repeates part of the path.

The most egregious example I could find which covers the above points:

echo $((${COLUMNS:-80}*$LP_PATH_LENGTH/100))
30

This the calculated maximum length. In examples it uses 40 in bash and 42 in zsh.

bash:

1d [rolf:~/workspace/ … /arduino/abc_temperature] develop* ± pwd
/home/rolf/workspace/arduino/abc_temperature
1d [rolf:~/workspace/ … /abc_temperature/src] develop* ± pwd
/home/rolf/workspace/arduino/abc_temperature/src

zsh:

1d [rolf:~/workspace … ace/arduino/abc_temperature] develop* ± pwd
/home/rolf/workspace/arduino/abc_temperature
1d [rolf:~/workspace … arduino/abc_temperature/src] develop* ± pwd
/home/rolf/workspace/arduino/abc_temperature/src

This new implementation is portable across bash and zsh.
It respects maximum length strictly and only exceeds it when it has to
respect LP_PATH_KEEP leading dirs.
It adds support for only showing the current directory, without leading
ones. This fixes Issue #219.