Bash Prompts Collection
Key topics
The art of crafting the perfect Bash prompt is on full display in this lively discussion, sparked by a curated collection of prompts. Some commenters, like okasaki, argue that overly customized prompts can be a hindrance when working across multiple systems, while others, such as dpflan, counter that maintaining a personal repository of dot files can make it easy to bring a familiar setup to any machine. The conversation takes a fascinating turn when grepfru_it shares a tale of a "sentient" Bash prompt from 20 years ago, prompting others to geek out over their own prompt engineering exploits. As the discussion unfolds, it becomes clear that the quest for the ideal prompt is a timeless and universal pursuit among terminal enthusiasts.
Snapshot generated from the HN discussion
Discussion Activity
Active discussionFirst comment
4d
Peak period
18
96-108h
Avg / period
6
Based on 30 loaded comments
Key moments
- 01Story posted
Aug 28, 2025 at 11:38 AM EDT
4 months ago
Step 01 - 02First comment
Sep 1, 2025 at 9:51 AM EDT
4d after posting
Step 02 - 03Peak activity
18 comments in 96-108h
Hottest window of the conversation
Step 03 - 04Latest activity
Sep 3, 2025 at 11:50 AM EDT
4 months ago
Step 04
Generating AI Summary...
Analyzing up to 500 comments to identify key contributors and discussion patterns
Want the full context?
Jump to the original sources
Read the primary article or dive into the live Hacker News thread when you're ready.
Also I have a theory that it lowers chatbot performance if you're copy pasting terminal output.
One thing that comes to mind is it might make its output more aligned with data that includes the full terminal output, which could make it more copy-pastey?
It's just an idle thought though.
This also applies to say vimrc (choose your editor/tool of choice).
25 years later I have no clue where this guy went but I remember him because he was instrumental in moving me off zsh to bash
P.S. just fully noticed your handle, very shell discussion appropriate! :)
atuin in particular records the history of each command but also how long they took and is they were successful or not.
You never have to rerun a command with long output to know how long it took: just ctrl-r and see.
My own current setting is
Which looks like this: The :; has the advantage that, if you unintentionally include the prompt in your copy and paste, it usually has no effect. (Maybe I should change ($env) to [$env].) \W (the last segment of the directory name) is usually about the right amount of context for me, but if I were working on a project with a lot of directories named things like "views" I would probably reconsider that.BTW, since this prompt collection was written, Linux terminal emulators have mostly gained 24-bit color support, which potentially opens up more alternative colors. See http://canonical.org/~kragen/sw/dev3/gradient.c with sample results in http://canonical.org/~kragen/sw/dev3/gradient.png. The escape sequence is \033[38;2;rrr;ggg;bbbm, where \033 is ESC and rrr, ggg, and bbb are decimal numbers from 0 to 255.
(Probably I should switch from bash to zsh...)
If this is a concern to mitigate, consider adding the following alias to your preferred shell profile:
This will not conflict with scripts using PATH-relative 'rm' invocations, yet will provide the desired protection from erroneous interactive use of "rm -rf".See here[0] for details regarding the '-I' flag.
0 - https://linux.die.net/man/1/rm
Fortunately the computer center kept nightly backups.
rm /dir
Then go back and add the -rf.
Works on GNU and BSD. On GNU only you can
‘rm /dir -rf’
Another reason against using ">" in the definition of PS1 is that this is a typical character used in the definition of PS2[0].
> The :; has the advantage that, if you unintentionally include the prompt in your copy and paste, it usually has no effect.
This is because colon (':') has a specific definition in POSIX shells[1], which is:
Note that "performing redirections" can result in destructive file operations.0 - https://unix.stackexchange.com/questions/193659/in-which-sit...
1 - https://www.gnu.org/software/bash/manual/html_node/Bourne-Sh...
(My prompt is platform aware since codes for some ops differ between MacOS and Linux. The return is colour-coded (green, red, purple, depending on case), and multiline, with git status if in a repo, cwd, and a few other things....)
For bash users I can recommend looking into setting PS1 from a function and assigning that function to PROMPT_COMMAND as it makes it much easier to make it readable