Just annotations of little "how to's", so I know I can find how to do something I've already done when I need to do it again, in case I don't remember anymore, which is not unlikely. Hopefully they can be useful to others, but I can't guarantee that it will work, or that it won't even make things worse.
A good $PS1 for displaying long paths in the bash prompt
Code:
PS1='${debian_chroot:+($debian_chroot)}\t \u $(if [ ${#PWD} -gt 30 ] ; then myPWD="${PWD:0:12}…/\W" ; myPWD="${myPWD:0:25}…" ; else myPWD=$PWD; fi ; echo $myPWD) $ '
The end result is something like:
HH:MM:SS tuxguy /home/tuxguy/mystuf.../xmas pics $
HH:MM:SS tuxguy /home/tuxguy/mystuf.../long folder nam... $
It's a combination of what I already had (everything up to "\u") and something I saw here, in the comment section:
http://www.cyberciti.biz/tips/howto-...up-prompt.html
It was using a somewhat different method that didn't work for me, perhaps because of different/wrong quote characters, environment variables, or whatever.. So I stuck it all into PS1, ditching the "PROMPT_COMMAND" part that I didn't get. And it worked.
I like having the first characters of the current folder better, they're often more informative than the last ones I guess.
Total Comments 0