fixed up colors for windows

pull/1/head
Adam Veldhousen 2014-07-16 01:56:28 -05:00
parent d82f587f95
commit aff2da5028
1 changed files with 31 additions and 17 deletions

View File

@ -8,11 +8,11 @@
# If not running interactively, don't do anything # If not running interactively, don't do anything
[ -z "$PS1" ] && return [ -z "$PS1" ] && return
RED="\033[0;31m\]" RED="\033[0;31m"
YELLOW="\033[0;33m\]" YELLOW="\033[0;33m"
GREEN="\033[0;32m\]" GREEN="\033[0;32m"
GRAY="\033[1;30m\]" GRAY="\033[1;30m"
EMPTY="\033[0;37m\]" EMPTY="\033[0;37m"
LIGHTBLUE="\033[38;5;111m" LIGHTBLUE="\033[38;5;111m"
LIGHTORANGE="\033[38;5;172m" LIGHTORANGE="\033[38;5;172m"
@ -23,7 +23,13 @@ CONTINUE="\033[38;5;242m"
DARKGRAY="\033[38;5;247m" DARKGRAY="\033[38;5;247m"
colorize() { colorize() {
echo -en "\033[$2;5;$3m $1 \033[0m" # $1 is foreground
# $2 is background
if [ $OSTYPE = 'msys' ]; then
echo "\033[$2;$1m"
else
echo "\033[$BG;5;$FGm"
fi
} }
parse_git_branch () { parse_git_branch () {
@ -35,19 +41,15 @@ parse_git_tag () {
} }
parse_git_branch_or_tag() { parse_git_branch_or_tag() {
local OUT="$(parse_git_branch)" local OUT="$(parse_git_branch)"
if [ "$OUT" == " ((no branch))" ]; then if [ "$OUT" == " ((no branch))" ]; then
OUT="($(parse_git_tag))"; OUT=" ($(parse_git_tag))";
else [ "$OUT" == "" ];
OUT="";
fi fi
echo $OUT echo $OUT
} }
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
}
# [hh:mm] username@host (git branch || svn revision) ~/working/directory # [hh:mm] username@host (git branch || svn revision) ~/working/directory
# $ # $
# [hh:mm] username@host (git branch || svn revision) ~/working/directory # [hh:mm] username@host (git branch || svn revision) ~/working/directory
@ -55,8 +57,7 @@ banner() {
# Pretty ugly hack for msys... need to figure out how to determine if my # Pretty ugly hack for msys... need to figure out how to determine if my
# console is 256 color capable # console is 256 color capable
if [ $OSTYPE = 'msys' ]; then 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"
PROMPT_COMMAND='PS1="$GREEN[\$(date +%H:%M)]  \u@\h  $RED$(parse_git_branch_or_tag) $YELLOW\w \n\$ $GRAY"
PS2="$CONTINUE> "' PS2="$CONTINUE> "'
else else
PROMPT_COMMAND='PS1="$LIGHTBLUE[\$(date +%H:%M)] $LIGHTGREEN\u@\h $LIGHTRED$(parse_git_branch_or_tag) $LIGHTYELLOW\w \n$EMPTY\$ $DARKGRAY" PROMPT_COMMAND='PS1="$LIGHTBLUE[\$(date +%H:%M)] $LIGHTGREEN\u@\h $LIGHTRED$(parse_git_branch_or_tag) $LIGHTYELLOW\w \n$EMPTY\$ $DARKGRAY"
@ -64,5 +65,18 @@ else
fi 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
}