Live data from Hacker News

PS1 generator

xta.github.io

1–10 of 30 posts

Re: PS1 generator

#3
Pretty awesome, just a couple of suggestions:

1. Items shouldn't disappear from the selection (I can only add one (space) for some reason).

2. Allow grouping of items. For example, if you want to have [time] you should be able to drag the "[", "time", and "]" as a group instead of individually.

Re: PS1 generator

#5
post #2

Very cool! Feature suggestion: It would be great to be able to change the colors of the individual components a la https://github.com/twolfson/sexy-bash-prompt

Agree. I colorize the hostname in my prompts so it's easy to tell which system/VM I'm on.

Re: PS1 generator

#6
Please add "cursor: default;" or "cursor: move;" to the draggable items. Draggable things should not use the text selection cursor. :)

Re: PS1 generator

#7
post #2

Very cool! Feature suggestion: It would be great to be able to change the colors of the individual components a la https://github.com/twolfson/sexy-bash-prompt

Seconded. The basic layout of $PS1 is straightforward enough, but it's the ugly colour escapes that always hurt maintainability of mine at least. :)

Re: PS1 generator

#8
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.

Re: PS1 generator

#9
post #8

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 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.
Post reply on HN