Skip to content

Instantly share code, notes, and snippets.

@c0d3st0rm
Created December 12, 2015 15:03
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 c0d3st0rm/bbb6f2a5873de1adb035 to your computer and use it in GitHub Desktop.
Save c0d3st0rm/bbb6f2a5873de1adb035 to your computer and use it in GitHub Desktop.
PS1 prompt no. 1
# a nice bash prompt
# put this at the end of your .bashrc file
# these separate colors below allow you to change them easily (see https://wiki.archlinux.org/index.php/Color_Bash_Prompt#List_of_colors_for_prompt_and_Bash)
# these colors are designed to go with a dark terminal background (and it's probably best if you have colors enabled for the prompt too)
PS1_SEP="\[\033[00;36m\]" # separators
PS1_OK="\[\033[01;32m\]" # OK (return value wise)
PS1_ERR="\[\033[01;31m\]" # error (return value wise)
PS1_HNAME="\[\033[01;34m\]" # hostname
PS1_CWD="\[\033[01;36m\]" # current working directory
PS1_TIME="\[\033[00;36m\]" # time/date
PS1_UNORM="\[\033[01;34m\]" # normal user
PS1_UROOT="\[\033[01;31m\]" # root user
PS1_SHLVL="\[\033[01;32m\]" # shell level
PS1_PROMPT="\[\033[01;33m\]" # input text
PS1="$PS1_SEP[\$?]\$(if [[ \$? == 0 ]]; then echo '$PS1_OK OK '; else echo '$PS1_ERR ERR'; fi)$PS1_TIME \@ \d$PS1_SEP [ \$(if [[ ${EUID} != 0 ]]; then echo '$PS1_UNORM'; else echo '$PS1_UROOT'; fi)\u$PS1_SEP@$PS1_HNAME\h$PS1_SEP:$PS1_CWD\w$PS1_SHLVL +${SHLVL}$PS1_SEP ]\n\$(if [[ ${EUID} != 0 ]]; then echo '$PS1_UNORM$'; else echo '$PS1_UROOT#'; fi)$PS1_PROMPT "
# this trap resets the color of output after user input, which is set to PS1_PROMPT
trap 'printf "\033[0m" "$_"' DEBUG
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment