Skip to content

Instantly share code, notes, and snippets.

@bmatthewshea
Last active September 23, 2018 17:54
Show Gist options
  • Save bmatthewshea/773c2a26f81185d3ba3c8094417b3180 to your computer and use it in GitHub Desktop.
Save bmatthewshea/773c2a26f81185d3ba3c8094417b3180 to your computer and use it in GitHub Desktop.
BASH prompt function / color prompt with time
# add this to end of ~/.bashrc:
# if [ -f ~/.bash_prompt ]; then
# . ~/.bash_prompt
# fi
# prompt function
function myprompt {
local BLUE="\[\033[0;34m\]"
local LIGHT_BLUE="\[\033[1;34m\]"
local RED="\[\033[0;31m\]"
local LIGHT_RED="\[\033[1;31m\]"
local WHITE="\[\033[1;37m\]"
local YELLOW="\[\033[1;33m\]"
local NO_COLOUR="\[\033[0m\]"
case $TERM in
xterm*|rxvt*)
TITLEBAR='\[\033]0;\u@\h:\w\007\]'
;;
*)
TITLEBAR=""
;;
esac
PS1="${TITLEBAR}\
$BLUE[$RED\$(date +%I:%M%P)$BLUE]$YELLOW\u@\h:$LIGHT_BLUE\w$WHITE \$$NO_COLOUR "
PS2='> '
PS4='+ '
}
# and uncomment this to set it
myprompt
@bmatthewshea
Copy link
Author

shea99-2018-09-23_124923

Example. Last part ^ that is redacted is user@host in yellow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment