Hacker News new | ask | show | jobs
by egwynn 4687 days ago
It should probably emit the example PS1 with single quotes instead of double quotes.

This:

  export PS1="\h:\W\$(parse_git_branch) \u$ "
will execute parse_git_branch only once (at the time PS1 is set) but this:

  export PS1='\h:\W\$(parse_git_branch) \u$ '
will execute it every time the prompt every time.
1 comments

Also, I'd like to offer some words of caution to those who want lots of "external" (i.e. not bash-native) data in their PS1 string. Running outside programs can be expensive. For personal workstation use, things like the above are great. However, if you administer a remote (perhaps resource-constrained) server and you find yourself trying to rescue it from swap-death (or a partially busted HDD), you may not want to be 1) forking subprocesses, 2) allocating file descriptors, and 3) doing disk IO every time you hit the enter key. Build responsible prompt strings everyone.
If you're actually trying to rescue a server, you can just do "export PS1='#'" once to disable it for the current session.