Skip to content

Instantly share code, notes, and snippets.

@triangletodd
Created December 13, 2018 19:16
Show Gist options
  • Select an option

  • Save triangletodd/8da9f9ff26b1163c225797f07e8ec8b8 to your computer and use it in GitHub Desktop.

Select an option

Save triangletodd/8da9f9ff26b1163c225797f07e8ec8b8 to your computer and use it in GitHub Desktop.
Bash Colors
#!/usr/bin/env bash
#░█ ██ ██
#░█ ░██ ░░
#░█ █████ ██████ ░██ ██████ ██████ ██ ██████ █████
#░█ ██░░░██ ██░░░░██ ░██ ██░░░░██░░██░░█░██░░░░██ ██░░░██
#░█ ░██ ░░ ░██ ░██ ░██░██ ░██ ░██ ░ ░██ ██ ░███████
#░█ ░██ ██░██ ░██ ░██░██ ░██ ░██ ░██ ██ ░██░░░░
#░█ ░░█████ ░░██████ ███░░██████ ░███ ░██ ██████░░██████
#░█ ░░░░░ ░░░░░░ ░░░ ░░░░░░ ░░░ ░░ ░░░░░░ ░░░░░░
if [[ $TERM != dumb ]]; then
LS_COLORS='no=00;38;5;244:rs=0:di=00;38;5;33:ln=00;38;5;37:mh=00:pi=48;5;230;38;5;136;01:so=48;5;230;38;5;136;01:do=48;5;230;38;5;136;01:bd=48;5;230;38;5;244;01:cd=48;5;230;38;5;244;01:or=48;5;235;38;5;160:su=48;5;160;38;5;230:sg=48;5;136;38;5;230:ca=30;41:tw=48;5;64;38;5;230:ow=48;5;235;38;5;33:st=48;5;33;38;5;230:ex=00;38;5;64:*.tar=00;38;5;61:*.tgz=00;38;5;61:*.arj=00;38;5;61:*.taz=00;38;5;61:*.lzh=00;38;5;61:*.lzma=00;38;5;61:*.tlz=00;38;5;61:*.txz=00;38;5;61:*.zip=00;38;5;61:*.z=00;38;5;61:*.Z=00;38;5;61:*.dz=00;38;5;61:*.gz=00;38;5;61:*.lz=00;38;5;61:*.xz=00;38;5;61:*.bz2=00;38;5;61:*.bz=00;38;5;61:*.tbz=00;38;5;61:*.tbz2=00;38;5;61:*.tz=00;38;5;61:*.deb=00;38;5;61:*.rpm=00;38;5;61:*.jar=00;38;5;61:*.rar=00;38;5;61:*.ace=00;38;5;61:*.zoo=00;38;5;61:*.cpio=00;38;5;61:*.7z=00;38;5;61:*.rz=00;38;5;61:*.apk=00;38;5;61:*.gem=00;38;5;61:*.jpg=00;38;5;136:*.JPG=00;38;5;136:*.jpeg=00;38;5;136:*.gif=00;38;5;136:*.bmp=00;38;5;136:*.pbm=00;38;5;136:*.pgm=00;38;5;136:*.ppm=00;38;5;136:*.tga=00;38;5;136:*.xbm=00;38;5;136:*.xpm=00;38;5;136:*.tif=00;38;5;136:*.tiff=00;38;5;136:*.png=00;38;5;136:*.PNG=00;38;5;136:*.svg=00;38;5;136:*.svgz=00;38;5;136:*.mng=00;38;5;136:*.pcx=00;38;5;136:*.dl=00;38;5;136:*.xcf=00;38;5;136:*.xwd=00;38;5;136:*.yuv=00;38;5;136:*.cgm=00;38;5;136:*.emf=00;38;5;136:*.eps=00;38;5;136:*.CR2=00;38;5;136:*.ico=00;38;5;136:*.tex=00;38;5;245:*.rdf=00;38;5;245:*.owl=00;38;5;245:*.n3=00;38;5;245:*.ttl=00;38;5;245:*.nt=00;38;5;245:*.torrent=00;38;5;245:*.xml=00;38;5;245:*Makefile=00;38;5;245:*Rakefile=00;38;5;245:*Dockerfile=00;38;5;245:*build.xml=00;38;5;245:*rc=00;38;5;245:*1=00;38;5;245:*.nfo=00;38;5;245:*README=00;38;5;245:*README.txt=00;38;5;245:*readme.txt=00;38;5;245:*.md=00;38;5;245:*README.markdown=00;38;5;245:*.ini=00;38;5;245:*.yml=00;38;5;245:*.cfg=00;38;5;245:*.conf=00;38;5;245:*.h=00;38;5;245:*.hpp=00;38;5;245:*.c=00;38;5;245:*.cpp=00;38;5;245:*.cxx=00;38;5;245:*.cc=00;38;5;245:*.objc=00;38;5;245:*.sqlite=00;38;5;245:*.go=00;38;5;245:*.sql=00;38;5;245:*.csv=00;38;5;245:*.log=00;38;5;240:*.bak=00;38;5;240:*.aux=00;38;5;240:*.lof=00;38;5;240:*.lol=00;38;5;240:*.lot=00;38;5;240:*.out=00;38;5;240:*.toc=00;38;5;240:*.bbl=00;38;5;240:*.blg=00;38;5;240:*~=00;38;5;240:*#=00;38;5;240:*.part=00;38;5;240:*.incomplete=00;38;5;240:*.swp=00;38;5;240:*.tmp=00;38;5;240:*.temp=00;38;5;240:*.o=00;38;5;240:*.pyc=00;38;5;240:*.class=00;38;5;240:*.cache=00;38;5;240:*.aac=00;38;5;166:*.au=00;38;5;166:*.flac=00;38;5;166:*.mid=00;38;5;166:*.midi=00;38;5;166:*.mka=00;38;5;166:*.mp3=00;38;5;166:*.mpc=00;38;5;166:*.ogg=00;38;5;166:*.opus=00;38;5;166:*.ra=00;38;5;166:*.wav=00;38;5;166:*.m4a=00;38;5;166:*.axa=00;38;5;166:*.oga=00;38;5;166:*.spx=00;38;5;166:*.xspf=00;38;5;166:*.mov=00;38;5;166:*.MOV=00;38;5;166:*.mpg=00;38;5;166:*.mpeg=00;38;5;166:*.m2v=00;38;5;166:*.mkv=00;38;5;166:*.ogm=00;38;5;166:*.mp4=00;38;5;166:*.m4v=00;38;5;166:*.mp4v=00;38;5;166:*.vob=00;38;5;166:*.qt=00;38;5;166:*.nuv=00;38;5;166:*.wmv=00;38;5;166:*.asf=00;38;5;166:*.rm=00;38;5;166:*.rmvb=00;38;5;166:*.flc=00;38;5;166:*.avi=00;38;5;166:*.fli=00;38;5;166:*.flv=00;38;5;166:*.gl=00;38;5;166:*.m2ts=00;38;5;166:*.divx=00;38;5;166:*.webm=00;38;5;166:*.axv=00;38;5;166:*.anx=00;38;5;166:*.ogv=00;38;5;166:*.ogx=00;38;5;166:'
export LS_COLORS
# Normal Colors
Black='\e[0;30m' # Black
Red='\e[0;31m' # Red
Green='\e[0;32m' # Green
Yellow='\e[0;33m' # Yellow
Blue='\e[0;34m' # Blue
Purple='\e[0;35m' # Purple
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
# 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
NC="\e[m" # Color Reset
fi
#!/usr/bin/env bash
#░█ ██
#░█ ██████ ██████ ░██
#░█ ░██░░░██ ██████ ██████ ██████████ ░██░░░██ ██████
#░█ ░██ ░██░░██░░█ ██░░░░██░░██░░██░░██░██ ░██░░░██░
#░█ ░██████ ░██ ░ ░██ ░██ ░██ ░██ ░██░██████ ░██
#░█ ░██░░░ ░██ ░██ ░██ ░██ ░██ ░██░██░░░ ░██
#░█ ░██ ░███ ░░██████ ███ ░██ ░██░██ ░░██
#░█ ░░ ░░░ ░░░░░░ ░░░ ░░ ░░ ░░ ░░
PROMPT_COMMAND='history -a; _ps1_set;'
_ps1_gke() {
local context project zone cluster conf
if ! hash kubectl 2> /dev/null; then return; fi
if [[ -n $KUBECONFIG ]]; then conf="$KUBECONFIG"; else conf="$HOME/.kube/config"; fi
if [[ ! -r $conf ]]; then return; fi
context="$(sed -e '/^[ \t]*current-context/!d' -e 's/[ \t]*current-context: *//' $conf)"
if [[ -z $context ]]; then return; fi
IFS=_ read _ project zone cluster <<< $context
if [[ -z $project ]] || [[ -z $cluster ]]; then return; fi
echo " k8s:(${Green}$project${NC}|${Green}$cluster${NC})"
}
_ps1_gcloud() {
local gdir aconf conf gc_project
if ! hash gcloud 2> /dev/null; then return; fi
gdir="$HOME/.config/gcloud"
aconf="$gdir/active_config"
if [[ ! -r $aconf ]]; then return; fi
conf="$gdir/configurations/config_$(<$aconf)"
if [[ ! -r $conf ]]; then return; fi
gc_project="$(sed -e '/^ *project/!d' -e 's/ *project *= *//' $conf)"
if [[ -z $gc_project ]]; then return; fi
echo " gcloud:(${Green}$gc_project${NC})"
}
_ps1_git() {
local branch
branch="$(git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/')"
if [[ -z $branch ]]; then return; fi
echo " git:(${Green}$branch${NC})"
}
_ps1_set() {
_ps1_prefix="${Green}\u${NC}@${Green}\h${NC}"
#PS1="$_ps1_prefix$(_ps1_gke)$(_ps1_gcloud)$(_ps1_git) \n ${Yellow}\w ${NC}$ "
PS1="$(_ps1_gke)$(_ps1_gcloud)$(_ps1_git) \n ${Yellow}\w ${NC}$ "
}
# Rapidly import our bash history into sqlite
if hash hist 2> /dev/null; then
PROMPT_COMMAND+=' hist import > /dev/null;'
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment