laughing-hipster/.shell_colors

83 lines
2.0 KiB
Plaintext

# Prompt Customizations
# downside of using MSYS
# LS_COLORS="di=01;36:"
# export LS_COLORS
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
RED="\033[0;31m"
YELLOW="\033[0;33m"
GREEN="\033[0;32m"
GRAY="\033[1;30m"
EMPTY="\033[0;37m"
LIGHTBLUE="\033[38;5;111m"
LIGHTORANGE="\033[38;5;172m"
LIGHTGREEN="\033[38;5;70m"
LIGHTRED="\033[38;5;161m"
LIGHTYELLOW="\033[38;5;229m"
CONTINUE="\033[38;5;242m"
DARKGRAY="\033[38;5;247m"
colorize() {
# $1 is foreground
# $2 is background
if [ $OSTYPE = 'msys' ]; then
echo "\033[$2;$1m"
else
echo "\033[$BG;5;$FGm"
fi
}
parse_git_branch () {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
parse_git_tag () {
git describe --tags 2> /dev/null
}
parse_git_branch_or_tag() {
local OUT=" $(parse_git_branch)"
if [ "$OUT" == " ((no branch))" ]; then
OUT=" ($(parse_git_tag))";
else [ "$OUT" == "" ];
OUT="";
fi
echo $OUT
}
# [hh:mm] username@host (git branch || svn revision) ~/working/directory
# $
# [hh:mm] username@host (git branch || svn revision) ~/working/directory
# $
# Pretty ugly hack for msys... need to figure out how to determine if my
# console is 256 color capable
if [ $OSTYPE = 'msys' ]; then
PROMPT_COMMAND='PS1="$(colorize 39 46)[$(date +%H:%M)] $(colorize 39 42) \u@\h $(colorize 39 41)$(parse_git_branch)$(colorize 33 49) \w \n$EMPTY\$ $GRAY"
PS2="$CONTINUE> "'
else
PROMPT_COMMAND='PS1="$LIGHTBLUE[\$(date +%H:%M)] $LIGHTGREEN\u@\h $LIGHTRED$(parse_git_branch_or_tag) $LIGHTYELLOW\w \n$EMPTY\$ $DARKGRAY"
PS2="$CONTINUE> "'
fi
print_map(){
if [ $OSTYPE = 'msys' ]; then
for i in {0..87} ; do echo -en "\033[38;5;${i}m#" ; done ; echo
else
for i in {0..255} ; do echo -en "\033[38;5;${i}m#" ; done ; echo
fi
}
banner() {
for i in {16..21} {23..27} {27..23} {21..16} ; do echo -en "\033[38;5;${i}m#" ; done ; echo
echo -e "$LIGHTBLUE $1"
for i in {16..21} {23..27} {27..23} {21..16} ; do echo -en "\033[38;5;${i}m#" ; done ; echo
}