djl/vcprompt — pull request #30 by pjv (2012-10-26 00:40:30+00:00)
Title: conditional spaces

add a little tweak to the prompt allowing for the prompt string to include spaces around token elements that do not print if the token returns blank.

e.g. if you want to use the 'modified' symbol '+' and you want to put spaces around it in the prompt if it will print, but don't want those spaces to print if there are no modifications to the repo and the symbol won't print, then you would put it into the prompt format string like this: `< %m >`.

in this case, this little patch will print the spaces in the prompt if %m prints, but will strip out the spaces if %m does not print. the angle brackets are of course stripped out either way.

-------
this is really an incomplete feature and unfortunately i don't have time to take it all the way right now. it suits my needs as-is and i thought i'd just send you the pull in case you or someone else want to flesh it out before i have a chance to.

to make it 'right', one of two things should be done:
1. either there has to be a way to escape the angle brackets so that people can include literal angle brackets in their prompt string if they want them, or
2. instead of using hard-coded angle brackets as the delimiters for this feature, allow the user to put their own delimiters on the command line like the existing formatting options