NHacker Next
  • new
  • past
  • show
  • ask
  • show
  • jobs
  • submit
Bash Prompts Collection (gilesorr.com)
kragen 54 minutes ago [-]
I strongly recommend against putting a ">" in your prompt on Unix if you're using any kind of system that supports copy and paste. (So, like, on a physical VT100 on a serial port it would be okay.) Sooner or later you're going to take a prompt-included command like

    > ls GN*
and accidentally paste it into a terminal window (or a web page that someone else pastes into a terminal window) and accidentally create an empty file named "ls". Or, in some cases, overwrite an existing file.

My own current setting is

    PS1=': ${env:+($env) }\W; '
Which looks like this:

    : ~; cd wak
    : wak; ls
    LICENSE   monosrc    scripts  toybox            toybox_awk_test
    Makefile  README.md  src      toybox_awk_parts
    : wak; 
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...)

oneshtein 21 minutes ago [-]
I use Linux for 30 years. Never had this problem. However, I saw newbies, which copy paste commands from tutorials to shell and then frustrated, because # is a comment.
grepfru_it 2 hours ago [-]
My buddy spike723 on EFnet built what I can only describe as a sentinent bash prompt. I recall it being massive and could show you everything about your system in a prompt.

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

dpflan 1 hours ago [-]
Right on, I've always enjoyed tinkering with my own `$PS1`. Why did you move from zsh to bash -- what bash features pulled you over?
3 hours ago [-]
latchkey 1 hours ago [-]
Adopted:

  https://atuin.sh/
  https://github.com/akinomyoga/ble.sh
  https://starship.rs/
These three have made my shell game so much more enjoyable.
okasaki 3 hours ago [-]
Like most customization and command replacements (like the fancy greps, ls's, etc), I've stopped using fancy prompts because I log in to lots of systems over the day and most of them won't have my prompt and this causes annoyance.

Also I have a theory that it lowers chatbot performance if you're copy pasting terminal output.

dpflan 1 hours ago [-]
I feel you, though this is why it's quite useful to have your own repo (or even just a dot file you can scp) with your dots files in them so you can "move in" to any machine and feel at home. Just clone/scp, then run your move in script.

This also applies to say vimrc (choose your editor/tool of choice).

r_lee 3 hours ago [-]
About that last part, what do you mean exactly?

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?

okasaki 3 hours ago [-]
I mean that chatbots might have an easier time working with terminal output with the standard prompt rather than one that has your battery, weather, git branch and aws account in it.

It's just an idle thought though.

actionfromafar 3 hours ago [-]
Seems perfectly reasonable. Everything unrelated is an opportunity to go off the rails.
phyzome 3 hours ago [-]
Now this is prompt engineering.
nailer 2 hours ago [-]
I find it’s very valuable to have a time Delta in the prompt. Knowing how long something normally takes can help you catch situations where your five second test run turns into a 30 second test run very easily.
sixthDot 3 hours ago [-]
ty giles
4 hours ago [-]
Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact
Rendered at 17:14:59 GMT+0000 (Coordinated Universal Time) with Vercel.