From owner-freebsd-questions@FreeBSD.ORG Mon Jul 14 10:24:06 2003 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 06C9A37B401 for ; Mon, 14 Jul 2003 10:24:06 -0700 (PDT) Received: from adsl-64-161-78-226.dsl.lsan03.pacbell.net (adsl-64-161-78-226.dsl.lsan03.pacbell.net [64.161.78.226]) by mx1.FreeBSD.org (Postfix) with SMTP id 470C743F93 for ; Mon, 14 Jul 2003 10:24:05 -0700 (PDT) (envelope-from oremanj@adsl-64-161-78-226.dsl.lsan03.pacbell.net) Received: (qmail 16236 invoked by uid 1001); 14 Jul 2003 17:24:21 -0000 Date: Mon, 14 Jul 2003 10:24:21 -0700 From: Joshua Oremzn To: Kevin Berrien Message-ID: <20030714172421.GC11619@webserver.get-linux.org> References: <20030714013931.7485.qmail@web41107.mail.yahoo.com> <3F12DF9F.2060304@comcast.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3F12DF9F.2060304@comcast.net> User-Agent: Mutt/1.4.1i cc: questions@freebsd.org Subject: Color shell prompts (was Re: FreeBSD 4.8-RELEASE mutt & color (color)) X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Jul 2003 17:24:06 -0000 On Mon, Jul 14, 2003 at 12:51:43PM -0400 or thereabouts, Kevin Berrien wrote: > Speaking of color. Does anyone have a good tutorial/script to add color > in bash as one finds in the newer linux distributions? > "The Bash-Prompt HOWTO" @ tldp.org is a good one. Just to give you an idea about how crazy this all can get, take a look at this prompt (for zsh). Note that ^[ means the real ESC character, not caret + left bracket. Sorry about the long lines: PS1='%{^[[1;34m%}--[ %{^[[1;36m%}$(pwd), $(ls -1 | wc -l | tr -d " ") files / ${SIZE}%{^[[1;34m%} ]-- --[ %{^[[1;36m%}$(date "+%I:%M %p")%{^[[1;34m%} ]-- --[ %{^[[1;36m%}%n @ %M[$(jobs | wc -l | tr -d " ")] / $(tty | sed "s:/dev/pts/:ttyp:g;s:/dev/::g")%{^[[1;34m%} ]-- --[ %{^[[1;36m%}$(ps ax | wc -l | tr -d " ") processes%{^[[1;34m%} ]-- --[ %{^[[1;36m%}$(who | wc -l | tr -d " ") users%{^[[1;34m%} ]-- --[ %{^[[1;36m%}%# %{^[[1;34m%}]-- %{^[[0m%}' PS2='%{^[[1;34m%}--[ %{^[[1;36m%}%_ > %{^[[1;34m%}]-- %{^[[0m%}' function precmd () { let TotalBytes=0 for Bytes in $(command ls -l | grep "^-" | awk '{ print $5 }') do let TotalBytes=$TotalBytes+$Bytes done if [ $TotalBytes -lt 1024 ]; then TotalSize=$(echo -e "scale=0 \n$TotalBytes \nquit" | bc | tr -d '\n') suffix=" bytes" elif [ $TotalBytes -lt 1048576 ]; then TotalSize=$(echo -e "scale=0 \n$TotalBytes/1024 \nquit" | bc | tr -d '\n') suffix="K" elif [ $TotalBytes -lt 1073741824 ]; then TotalSize=$(echo -e "scale=0 \n$TotalBytes/1048576 \nquit" | bc | tr -d '\n') suffix="M" else TotalSize=$(echo -e "scale=0 \n$TotalBytes/1073741824 \nquit" | bc | tr -d '\n') suffix="G" fi SIZE="${TotalSize}${suffix}" UPTIME="`uptime | sed -e 's/.* \(.* days,\)\? \(.*:..,\) .*/\1 \2/' \ -e 's/,//g' -e 's/ up //'`" } It makes a prompt like this, but in color: --[ /, 33 files / 10M ]-- --[ 10:23 AM ]-- --[ oremanj @ webserver.get-linux.org[0] / ttyv1 ]-- --[ 136 processes ]-- --[ 4 users ]-- --[ % ]-- -- Josh P.S. Of course I don't use that prompt! > > _______________________________________________ > freebsd-questions@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.org"