Skip to content

Instantly share code, notes, and snippets.

@Hashbrown777
Created February 9, 2020 07:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Hashbrown777/6960469f388ac4fdce54e0b26de44aba to your computer and use it in GitHub Desktop.
Save Hashbrown777/6960469f388ac4fdce54e0b26de44aba to your computer and use it in GitHub Desktop.
neat coloured prompt for bash that shows `user@pcname:pwd\n$?>` where $? changes between red and green if it was an error or no
prompt-color() { printf '\\[\e[38;5;%sm\\]%s\\[\e[m\\]' "$1" "$2"; }
PS1="$(printf '%s' \
'\n' \
`prompt-color 226 '\u'` \
'@' \
`prompt-color 208 '\h'` \
':' \
`prompt-color 207 '\w'` \
'\n' \
`prompt-color '$(( $?==0 ? 82 : 196 ))' '$?'` \
`prompt-color 240 '> '` \
)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment