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.
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 b…
PS1 generator
11–20 of 30 posts
If you're actually trying to rescue a server, you can just do "export PS1='#'" once to disable it for the current session.
Re: PS1 generator
#12Wow this is great, props for making the first drag-n-drop $PS1 generator
Re: PS1 generator
#13I kept dragging the elements into the terminal window thinking that was how I construct it.
Me, too. When I figured it out I felt silly. Maybe emphasize the construction area and deemphasize the preview? Could the preview be static, and to the right of the construction area and palettes?
Re: PS1 generator
#14There's a bug where if you drag everything out of your configuration, you can't drag anything back in again.
Neat though.
I'm on Firefox v22.
Re: PS1 generator
#15You might also be interested in this PS1 generator. Seems to have a few more options.
Re: PS1 generator
#16Nice!
I'd love to see support for the terminal window title here, too. Add an additional container for the titlebar contents, and prefix \[\e]0;$titlebar_contents\a\] to the prompt when TERM is xterm, rxvt, or screen*.
Also, colors should be draggable into the prompt, since they can change between different parts of the prompt.
"Last command error when not successful" is nice as well; just add this to your prompt (includes color and whitespace):
$(e="$?";[ "$e" -ne 0 ] && echo -n "\[\e[01;31m\]($e) ")
On my system, I also have some extra logic to only show the username and hostname if either $SSH_CONNECTION is set or the username is not my usual username (usually because it's either root, some user I've sudoed to, or an unusual username because I'm on a system with mandated username conventions). Thus, on my personal system, my initial prompt is "~$ ", taking up very little room. Unfortunately "not my usual username" isn't portable to different users (though you could check for the presence of SUDO_USER), but checking SSH_CONNECTION is.Re: PS1 generator
#17If anyone wanted a full list of available options, you can look at the man page for your shell, under PROMPTING (you can type /PROMPTING to search for it). Any other bash variable, or user defined variable will also work.
Re: PS1 generator
#18This just uses a literal dollar sign to mark the end of the prompt by default. That means if, like me, you don't put the username in your PS1 - instead relying on $ changing to a # when you run `sudo -s' nothing will happen.
I would suggest adding a "$/#" bubble which adds "\$" to the PS1 string.
Re: PS1 generator
#19Re: PS1 generator
#20[deleted]