|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
# Reset
|
|
|
|
color_off='\e[0m' # Text Reset
|
|
|
|
|
|
|
|
green='\e[0;32m' # Green
|
|
|
|
yellow='\e[0;33m' # Yellow
|
|
|
|
blue='\e[0;34m' # Blue
|
|
|
|
purple='\e[0;35m' # Purple
|
|
|
|
|
|
|
|
function _hostname-color {
|
|
|
|
case "$(whoami)" in
|
|
|
|
william) echo "$blue";;
|
|
|
|
buddy) echo "$blue";;
|
|
|
|
root) echo "$bred";;
|
|
|
|
*) echo "$purple";;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
|
|
|
# display hostname
|
|
|
|
PS1="\[$green\]"'\u'"\[$yellow\] "
|
|
|
|
PS1="$PS1\[$(_hostname-color)\]"'$(_hostname-show)'""
|
|
|
|
# display separator
|
|
|
|
PS1="$PS1\[$yellow\] "
|
|
|
|
# display current path
|
|
|
|
PS1="$PS1\[$green\]\w "
|
|
|
|
# display git branch
|
|
|
|
PS1="$PS1\[$bblack\]"'$(parse_git_branch)'
|
|
|
|
# display git status
|
|
|
|
PS1="$PS1\[$yellow\]"'$(parse_git_status) '
|
|
|
|
# display date
|
|
|
|
PS1="$PS1\[$purple\]\D{%F %I:%M%P} "
|
|
|
|
PS1="$PS1\[$color_off\]\nλ "
|
|
|
|
|
|
|
|
function parse_git_status {
|
|
|
|
if [[ $(git status 2> /dev/null | wc -l) -eq 0 ]]; then
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ $(git status 2> /dev/null | grep -c "working tree|directory clean") -eq 0 ]]; then
|
|
|
|
echo ' ∓'
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function _hostname-show {
|
|
|
|
hostname -s | tr ':A-Z:' ':a-z:'
|
|
|
|
}
|
|
|
|
|
|
|
|
function parse_git_branch {
|
|
|
|
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'
|
|
|
|
}
|
|
|
|
|
|
|
|
# Regular Colors
|
|
|
|
#black='\e[0;30m' # Black
|
|
|
|
#red='\e[0;31m' # Red
|
|
|
|
#cyan='\e[0;36m' # Cyan
|
|
|
|
#white='\e[0;37m' # White
|
|
|
|
|
|
|
|
# Bold
|
|
|
|
bblack='\e[1;30m' # Black
|
|
|
|
bred='\e[1;31m' # Red
|
|
|
|
#bgreen='\e[1;32m' # Green
|
|
|
|
#byellow='\e[1;33m' # Yellow
|
|
|
|
#bblue='\e[1;34m' # Blue
|
|
|
|
#bpurple='\e[1;35m' # Purple
|
|
|
|
#bcyan='\e[1;36m' # Cyan
|
|
|
|
#bwhite='\e[1;37m' # White
|
|
|
|
|
|
|
|
# Underline
|
|
|
|
#ublack='\e[4;30m' # Black
|
|
|
|
#ured='\e[4;31m' # Red
|
|
|
|
#ugreen='\e[4;32m' # Green
|
|
|
|
#uyellow='\e[4;33m' # Yellow
|
|
|
|
#ublue='\e[4;34m' # Blue
|
|
|
|
#upurple='\e[4;35m' # Purple
|
|
|
|
#ucyan='\e[4;36m' # Cyan
|
|
|
|
#uwhite='\e[4;37m' # White
|
|
|
|
|
|
|
|
# Background
|
|
|
|
#on_black='\e[40m' # Black
|
|
|
|
#on_red='\e[41m' # Red
|
|
|
|
#on_green='\e[42m' # Green
|
|
|
|
#on_yellow='\e[43m' # Yellow
|
|
|
|
#on_blue='\e[44m' # Blue
|
|
|
|
#on_purple='\e[45m' # Purple
|
|
|
|
#on_cyan='\e[46m' # Cyan
|
|
|
|
#on_white='\e[47m' # White
|
|
|
|
|
|
|
|
# High Intensty
|
|
|
|
#iblack='\e[0;90m' # Black
|
|
|
|
#ired='\e[0;91m' # Red
|
|
|
|
#igreen='\e[0;92m' # Green
|
|
|
|
#iyellow='\e[0;93m' # Yellow
|
|
|
|
#iblue='\e[0;94m' # Blue
|
|
|
|
#ipurple='\e[0;95m' # Purple
|
|
|
|
#icyan='\e[0;96m' # Cyan
|
|
|
|
#iwhite='\e[0;97m' # White
|
|
|
|
|
|
|
|
# Bold High Intensty
|
|
|
|
#biblack='\e[1;90m' # Black
|
|
|
|
#biRed='\e[1;91m' # Red
|
|
|
|
#biGreen='\e[1;92m' # Green
|
|
|
|
#biYellow='\e[1;93m' # Yellow
|
|
|
|
#biBlue='\e[1;94m' # Blue
|
|
|
|
#biPurple='\e[1;95m' # Purple
|
|
|
|
#biCyan='\e[1;96m' # Cyan
|
|
|
|
#biWhite='\e[1;97m' # White
|
|
|
|
|
|
|
|
# High Intensty backgrounds
|
|
|
|
#on_iblack='\e[0;100m' # Black
|
|
|
|
#on_ired='\e[0;101m' # Red
|
|
|
|
#on_igreen='\e[0;102m' # Green
|
|
|
|
#on_iyellow='\e[0;103m' # Yellow
|
|
|
|
#on_iblue='\e[0;104m' # Blue
|
|
|
|
#on_ipurple='\e[10;95m' # Purple
|
|
|
|
#on_icyan='\e[0;106m' # Cyan
|
|
|
|
#on_iwhite='\e[0;107m' # White
|
|
|
|
|