Skip to content

Instantly share code, notes, and snippets.

@wisnij
Last active January 5, 2024 21:17
Show Gist options
  • Save wisnij/4558404 to your computer and use it in GitHub Desktop.
Save wisnij/4558404 to your computer and use it in GitHub Desktop.
Bash $PS1
RED="\[\e[01;31m\]"
GREEN="\[\e[01;32m\]"
BLUE="\[\e[01;34m\]"
NORMAL="\[\e[00m\]"
JOBS='if [[ $(jobs) != "" ]]; then echo "(\j) "; fi'
STATUS="s=\$?; if [ \$s != 0 ]; then echo \"${RED}\$s${NORMAL} \"; fi"
HOST_COLOR="\[\e[1;38;5;$((22 + 10#$(hostname | cksum | cut -d' ' -f1) % 210))m\]"
case $USER in
root)
PROMPT_COLOR=$RED
;;
*)
PROMPT_COLOR=$GREEN
;;
esac
export PS1="${PROMPT_COLOR}[\t] \u${NORMAL}@${HOST_COLOR}\h ${BLUE}\w ${NORMAL}\$(${STATUS})\$(${JOBS})\\\$ "
unset PROMPT_COLOR HOST_COLOR STATUS JOBS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment