Browse Source

Cleaned up colors and updated prompt

tags/original
Bryan Miller 6 years ago
parent
commit
c0fc259f9b
2 changed files with 92 additions and 33 deletions
  1. +56
    -20
      colors.rc.sh
  2. +36
    -13
      ps1.rc.sh

+ 56
- 20
colors.rc.sh View File

@@ -1,27 +1,63 @@

_CC() {
local c="0;00"
local f="39"
local b="49"
local s="0"
if [ "$1" ]; then
c="0;${1}"
f="${1}"
fi
echo -n "\[\033[${c}m\]"
if [ "$2" ]; then
b="${2}"
fi
if [ "$3" ]; then
s="${3}"
fi
echo -n "\[\e[${s};${f};${b}m\]"
}

NORMAL=$(_CC '00')
BLACK=$(_CC '30')
BLUE=$(_CC '34')
CYAN=$(_CC '36')
GREEN=$(_CC '32')
PURPLE=$(_CC '35')
RED=$(_CC '31')
WHITE=$(_CC '37')
YELLOW=$(_CC '33')
_CFG() {
local f="39"
if [ "$1" ]; then
f="${1}"
fi
echo -n "\[\e[${f}m\]"
}

DEFAULT='39'
BLACK='30'
RED='31'
GREEN='32'
YELLOW='33'
BLUE='34'
PURPLE='35'
CYAN='36'
GREY='37'
DGREY='90'
LRED='91'
LGREEN='92'
LYELLOW='93'
LBLUE='94'
LPURPLE='95'
LCYAN='96'
WHITE='97'

BG_DEFAULT='49'
BG_BLACK='40'
BG_RED='41'
BG_GREEN='42'
BG_YELLOW='43'
BG_BLUE='44'
BG_PURPLE='45'
BG_CYAN='46'
BG_GREY='47'
BG_DGREY='100'
BG_LRED='101'
BG_LGREEN='102'
BG_LYELLOW='103'
BG_LBLUE='104'
BG_LPURPLE='105'
BG_LCYAN='106'
BG_WHITE='107'

BG_BLACK=$(_CC '40')
BG_BLUE=$(_CC '44')
BG_CYAN=$(_CC '46')
BG_GREEN=$(_CC '42')
BG_PURPLE=$(_CC '45')
BG_RED=$(_CC '41')
BG_WHITE=$(_CC '47')
BG_YELLOW=$(_CC '43')
NORMAL="\[\033[0m\]"
CLEAR=$(_CFG $DEFAULT)

+ 36
- 13
ps1.rc.sh View File

@@ -1,16 +1,39 @@

# define symbols
declare -A symbols=(
[hard_separator]="▶"
[soft_separator]="|"
[git]=""
[lock]=""
[flag]="⚑"
[plus]="✚"
[tick]="✔"
[cross]="✘"
[enter]="⏎"
[python]="λ"
[battery_charging]="⚡"
[battery_discharging]="▮"
[untracked]="U"
[stash]="🐿"
[ahead]="+"
[behind]="-"
[smilie]="☺"
[frownie]="☹"
)


# This function was modified from one found @ https://www.reddit.com/r/linux/comments/2uf5uu/this_is_my_bash_prompt_which_is_your_favorite/?st=jikgswh4&sh=371ba8bf
function _git_status() {
local unknown untracked stash clean ahead behind staged dirty diverged
unknown=$BLUE
untracked=$GREEN
stash=$GREEN
clean=$GREEN
ahead=$YELLOW
behind=$YELLOW
staged=$CYAN
dirty=$RED
diverged=$RED
unknown=$(_CC $BLUE $BG_DGREY)
untracked=$(_CC $GREEN $BG_DGREY)
stash=$(_CC $GREEN $BG_DGREY)
clean=$(_CC $GREEN $BG_DGREY)
ahead=$(_CC $YELLOW $BG_DGREY)
behind=$(_CC $YELLOW $BG_DGREY)
staged=$(_CC $CYAN $BG_DGREY)
dirty=$(_CC $RED $BG_DGREY)
diverged=$(_CC $RED $BG_DGREY)


branch=$(git rev-parse --abbrev-ref HEAD 2>/dev/null)
@@ -49,7 +72,7 @@ function _git_status() {
color=$diverged
branch="${branch}!"
fi
echo -n "${color}${branch}${NORMAL}|"
echo -n "${color}${symbols[git]}${branch}"
fi
}

@@ -58,11 +81,11 @@ set_prompt() {
local lec="$?"
if [ $COLOR_PROMPT = yes ]; then
if [ $lec -ne 0 ]; then
smilie="${RED}:(${NORMAL}"
smilie="$(_CC $RED $BG_DGREY)${symbols[frownie]}"
else
smilie="${GREEN}:)${NORMAL}"
smilie="$(_CC $GREEN $BG_DGREY)${symbols[smilie]}"
fi
PS1="${debian_chroot:+($debian_chroot)}${BG_PURPLE}${GREEN}\u${NORMAL}${BG_PURPLE}|${BLUE}\w${NORMAL}${BG_PURPLE}|${smilie}${BG_PURPLE}|$(_git_status)${PURPLE}► "
PS1="${debian_chroot:+($debian_chroot)}$(_CC $GREEN $BG_DGREY)\u $(_CC $LBLUE $BG_DGREY)\w$(_CC $DEFAULT $BG_DGREY)|${smilie}$(_CC $DEFAULT $BG_DGREY)|$(_git_status)${NORMAL}$(_CFG $DGREY)${symbols[hard_separator]}${NORMAL} "
else
PS1="${debian_chroot:+($debian_chroot)}\u@\h:\w\$ "
fi

Loading…
Cancel
Save