by nobody9999 · 5y ago · 0 comments
[\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.
!! repeats the last command
!N repeats the command with that index in the history