News for hackers. Stuff that matters.
Re:Bash PS1 Generator by nobody9999 on Thursday June 24, 2021 @10:26AM (#27617992)
I've been using this for years (output of 'echo $PS1' ):

  [\e[1;33m\u\e[1;32m@\e[1;31m\H \e[1;36m\t\e[0m]
  [\e[1;35m\w\e[0m](\e[1;32m\#\e[0m                                               
  )\n$
which presents as:

  [User@HOST 10:21:07][~](2)
  $
(Username, hostname, 24 hour local time, CWD, history count, newline, prompt)

More detail from my .bashrc:

  # Define some colors first:
  red='\e[0;31m'
  RED='\e[1;31m'
  blue='\e[0;34m'
  BLUE='\e[1;34m'
  cyan='\e[0;36m'
  CYAN='\e[1;36m'
  green='\e[0;32m'
  GREEN='\e[1;32m'
  NC='\e[0m' # No Color
  yellow='\e[0;33m'
  magenta='\e[0;35m'
  YELLOW='\e[1;33m'
  MAGENTA='\e[1;35m'
  export PS1="[${YELLOW}\u${GREEN}@${RED}\H ${CYAN} 
  \t$NC][${MAGENTA}\w$NC](${GREEN}\#$NC)\n\$ "
I define the colors as it makes it easier to modify PS1 when the spirit moves me.

I guess using a generator or toolkit could be useful, but I tweaked mine over the years and prefer it just this way.

Edit: I forgot to mention that I use different colors for user vs. root prompts, as that gives immediate visual confirmation of privilege level.

Re:Bash PS1 Generator by nine_k on Thursday June 24, 2021 @11:02AM (#27618630)
I usually place the time at the beginning. Another thing to place at the beginning is a (red) exit code of the last command, when that code is not 0.
Re:Bash PS1 Generator by BearOso on Thursday June 24, 2021 @10:00PM (#27626368)
You need to add some \[ and \] around the escape codes to tell the shell they’re non-printing characters. Otherwise, things like line-wrapping don’t work right. It’s not a problem because of your \n makes it irrelevant, but just a heads up for the future.
Re:Bash PS1 Generator by _eigenfoo on Thursday June 24, 2021 @10:58AM (#27618571)
What do you use the history count for?
Re:Bash PS1 Generator by compressedgas on Thursday June 24, 2021 @11:08AM (#27618725)
That tells one the index to use for !N to repeat that command

!! repeats the last command

!N repeats the command with that index in the history