Hacker News new | past | comments | ask | show | jobs | submit login

Notes:

* As an idea, this is excellent. It's intuitive to use and provides full instructions on how to implement

* Putting an element in any other position than the end of the prompt is fiddly.

* I'd love for the option to to be able to colour elements.

* More advanced or exotic element types such as Git Branch would be excellent (Not sure if Bash supports this, but I've seen it in some shells)




For the manual approach, git provides a shell script to generate the env var __git_ps1 for this very purpose.[1]

[1]: https://git-scm.com/book/id/v2/Appendix-A%3A-Git-in-Other-En...


I think a manual approach is covered with vim ;)


Very cool, had no idea!


See also:

* LiquidPrompt [0] (I'm a former maintainer)

* angel-PS1 [1]: my pet project. Shell prompt code is generated at startup time from Perl code, and uses a Perl angel (not daemon) to get system information.

[0] https://github.com/nojhan/liquidprompt

[1] https://github.com/dolmen/angel-PS1


There's one prompt in ZSH, the adam2 prompt[1], that I completely fell in love with due to the automatic horizontal rule since it makes tracing histories so much easier when dealing with long-scrolling outputs. I've never been able to find a similar feature in another prompt/shell, nor have I had the inclination to try and replicate it, but I'd be much more inclined to switch shells/try new prompts if that were available.

[1]: https://imgur.com/1X9bY8X


The tide prompt for fish has an option to add a horizontal rule and spaces between each command


double click an element to change the color


Aha! Thank you!


I've shared it elsewhere too, but I made something similar a few years ago which provides what you were after:

https://dom111.github.io/bash-ps1/


Bash do support git branch name and whatnot. That what got me into PS1 customization.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: