Last active
September 23, 2018 17:54
-
-
Save bmatthewshea/773c2a26f81185d3ba3c8094417b3180 to your computer and use it in GitHub Desktop.
BASH prompt function / color prompt with time
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example. Last part ^ that is redacted is user@host in yellow.