# # Copyright (c) 2002, 2003 David Yeske # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer # in this position and unchanged. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # # $collective: dyeske/.bash/.bash_prompt,v 1.65 2003/10/17 18:41:30 dyeske Exp $ # $Id: spike_bash_prompt_20031023,v 1.1 2004/03/18 03:42:09 nugget Exp $ # # If you try and run this under bash 1.x # i'll try not to laugh too hard at you ansi_clear='\033[00;00m' ansi_grey='\033[01;30m' ansi_red='\033[01;31m' ansi_green='\033[01;32m' ansi_yellow='\033[01;33m' ansi_blue='\033[01;34m' ansi_magenta='\033[01;35m' ansi_cyan='\033[01;36m' ansi_white='\033[01;37m' grey=30 red=31 green=32 yellow=33 blue=34 magenta=35 cyan=36 white=37 F="=" FL="[" FR="]" prompt[0]='\033[$red;$(($cyan + 10))m' prompt[1]=$ansi_magenta prompt[2]='\033[$blue;$(($yellow + 10))m' #the colors!!! #F='\033[01;35m'= #FL='\033[01;$((30 + $RANDOM % 9));$((40 + $RANDOM % 9))m'[ #FR=]'\033[00;00m' #number of lines in history stack STACKY=3 #uname and tty need to be in your path _uname=`uname` _unamer=`uname -r` _tty=`tty` PROMPT_COMMAND=prompt_command color() { PS1="$PS1${prompt[$i]}" i=$(( $i + 1 )) } prompt_command() { #global history fix history -a history -c history -r prompt #! "x$TERM" = "xqansi-m" -a \ #don't mess up terminal if [ ! "x$TERM" = "xlinux" -a \ ! "x$TERM" = "xvt220" -a \ ! "x$TERM" = "xvt100" -a \ ! "x$TERM" = "xcons25" ]; then prompt_xterm fi } prompt() { PS1="" color if [ -n "$USERDOMAIN" -a -n "$USERNAME" ]; then PS1="$PS1$FL$USERDOMAIN\134$USERNAME$FR" USER="$USERDOMAIN\\$USERNAME" else PS1="$PS1$FL\u$FR" fi PS1="$PS1$F$FL\h$FR" [ $COLUMNS -gt 90 -a -n "$SSH_CLIENT" ] \ && PS1="$PS1$F$FL$SSH_CLIENT$FR" [ $COLUMNS -gt 90 -a -n "$DISPLAY" ] \ && PS1="$PS1$F$FL$DISPLAY$FR" if [ $COLUMNS -gt 60 ]; then PS1="$PS1$F$FL$_uname$FR" PS1="$PS1$F$FL$_unamer$FR" PS1="$PS1$F$FL$HOSTTYPE$FR" fi if [ $COLUMNS -gt 79 ]; then PS1="$PS1$F$FL$TERM$FR" PS1="$PS1$F$FL$_tty$FR" fi if [ $COLUMNS -gt 135 ]; then PS1="$PS1$F$FL\d$FR" PS1="$PS1$F$FL\t$FR" fi if [ $COLUMNS -gt 145 ]; then PS1="$PS1$F$FL$COLUMNS$FR" PS1="$PS1$F$FL$LINES$FR" fi [ $COLUMNS -gt 190 -a -x /usr/games/pom ] \ && PS1="$PS1 \`/usr/games/pom\`" if [ -n "$STACKY" ]; then if [ "$STACKY" -gt 0 ]; then PS1="$PS1$ansi_clear" PS1="$PS1\n" color PS1="$PS1\`history $STACKY\`" fi fi PS1="$PS1$ansi_clear" PS1="$PS1\n" color PS1="$PS1$FL\w$FR" PS1="$PS1$F$FL\!$FR" PS1="$PS1$F$FL\#$FR" [ -n "$CVSROOT" ] && PS1="$PS1 $FL"CVSROOT="$CVSROOT$FR" [ -n "$CVS_SERVER" ] && PS1="$PS1 $FL"CVS_SERVER="$CVS_SERVER$FR" [ -n "$CC" ] && PS1="$PS1 $FL"CC="$CC$FR" [ -n "$CXX" ] && PS1="$PS1 $FL"CXX="$CXX$FR" [ -n "$LDFLAGS" ] && PS1="$PS1 $FL"LDFLAGS="$LDFLAGS$FR" [ -n "$LIBS" ] && PS1="$PS1 $FL"LIBS="$LIBS$FR" [ -n "$CFLAGS" ] && PS1="$PS1 $FL"CFLAGS="$CFLAGS$FR" [ -n "$CPPFLAGS" ] && PS1="$PS1 $FL"CPPFLAGS="$CPPFLAGS$FR" [ -n "$CXXFLAGS" ] && PS1="$PS1 $FL"CXXFLAGS="$CXXFLAGS$FR" [ -n "$MAKE_ENV" ] && PS1="$PS1 $FL"MAKE_ENV="$MAKE_ENV$FR" [ -n "$SSH_AGENT_PID" ] && PS1="$PS1 $FL"SSH_AGENT_PID="$SSH_AGENT_PID$FR" [ -n "$STOCK" ] && PS1="$PS1 \`(echo 'GET /d/quotes.csv?s=$STOCK&f=sl1d1t1c1ohgv&e=.csv' 1>&3 & cat 0<&3) 3