Forwarded on request. This sure has charm ;) Marcus
----- Forwarded message from [EMAIL PROTECTED] ----- Delivered-To: [EMAIL PROTECTED] Subject: Re: ANSI Color Escapes in $PS1.. heh. To: [EMAIL PROTECTED] (Marcus Brinkmann) Date: Tue, 8 Dec 1998 00:36:51 -0500 (EST) From: [EMAIL PROTECTED] Reply-to: [EMAIL PROTECTED] X-UIDL: d541f21f09d02714a084baa0f026dcfa So this is a little late...had some e-mail issues that took too long to sort-out... Marcus Brinkmann said > On Wed, Dec 02, 1998 at 12:41:06PM -0600, Ryan King wrote: > > Just how stupid an idea did I have when I did this: > > > > $PS1="[\e[31m\h\e[m:\e[34m\u\e[m:\e[31m\w\$\e[m]" > > > > in my /etc/profile? > > > > It looks really nifty until I try to do commands that wrap around, in which > > case the first line returns, but keeps going on the current spot. > > What the other said, is correct, so you already know what is happening here. > However, here is just another example for you: > > # ~/.bash_profile: executed by bash(1) for login shells. > > [...snipped...] > > set_prompt () > { > local SAVE_CRS=`tput sc 2> /dev/null` > local RESET_CRS=`tput rc 2> /dev/null` > local CLOCKPOS=`tput cup 0 $(($HZ-10)) 2> /dev/null` > local FOREG=`tput setaf 6 2> /dev/null` #4 > local ALT_FOREG=`tput setaf 3 2> /dev/null` #4 > local BACKG=`tput setab 0 2> /dev/null` #6 > local NORMAL=`tput sgr0 2> /dev/null` > local BOLD=`tput bold 2> /dev/null` > > PS1="\[${NORMAL}${SAVE_CRS}${CLOCKPOS}${FOREG}${BACKG}${BOLD} \@ [EMAIL > PROTECTED]:\w\$ " > } > set_prompt > I took this a little over-the-top, but it was a fun excersize. Here's my adaptations to set_prompt(): set_prompt () { local EUID=$1; local NORMAL=`tput sgr0 2> /dev/null`; local BOLD=`tput bold 2> /dev/null`; # local DIM=`tput dim 2> /dev/null`; local BLINK=`tput blink 2> /dev/null`; # local REVERSE=`tput rev 2> /dev/null`; # local STANDOUT=`tput smso 2> /dev/null`; # local UNDERLINE=`tput smul 2> /dev/null`; # local INVISIBLE=`tput invis 2> /dev/null`; # local BEEP=`tput bel 2> /dev/null`; # local HOME=`tput home 2> /dev/null`; # local CLEAR=`tput clear 2> /dev/null`; # local FG_BLACK=`tput setaf 0 2> /dev/null`; local FG_RED=`tput setaf 1 2> /dev/null`; # local FG_GREEN=`tput setaf 2 2> /dev/null`; local FG_YELLOW=`tput setaf 3 2> /dev/null`; # local FG_BLUE=`tput setaf 4 2> /dev/null`; # local FG_MAGENTA=`tput setaf 5 2> /dev/null`; local FG_CYAN=`tput setaf 6 2> /dev/null`; local FG_WHITE=`tput setaf 7 2> /dev/null`; # local BG_BLACK=`tput setab 0 2> /dev/null`; # local BG_RED=`tput setab 1 2> /dev/null`; # local BG_GREEN=`tput setab 2 2> /dev/null`; # local BG_YELLOW=`tput setab 3 2> /dev/null`; # local BG_BLUE=`tput setab 4 2> /dev/null`; # local BG_MAGENTA=`tput setab 5 2> /dev/null`; # local BG_CYAN=`tput setab 6 2> /dev/null`; # local BG_WHITE=`tput setab 7 2> /dev/null`; if [ "$EUID" == "0" ]; then PS1="\[${NORMAL}${BOLD}${BLINK}${FG_RED}\]\u\[${NORMAL}${BOLD} \ [EMAIL PROTECTED]: "; else PS1="[EMAIL PROTECTED] ${FG_CYAN}\]\h\[${NORMAL}\]: "; fi; PS2="\[${NORMAL}${BOLD}${FG_YELLOW}\]continue\[${NORMAL}\]> "; return } set_prompt $EUID For root the username is in blinking, bright red - to help remind you of your login. For Regular Users the username is bright yellow. From there it's a bright white '@' and then the hostname in bright cyan. Oh, yeah, I almost forgot the ": " in bright white at the end. [Too much time waiting for downloads...] Use it if you want. Chuck PS. Don't forget to put the set_prompt() function somewhere where it will get executed for those times you `su` or `su -`. -- Chuck Stickelman, Owner E-Mail: <[EMAIL PROTECTED]> Practical Network Design Voice: +1-419-529-3841 9 Chambers Road FAX: +1-419-529-3625 Mansfield, OH 44906-1301 USA ----- End forwarded message ----- -- "Rhubarb is no Egyptian god." Debian GNU/Linux finger brinkmd@ Marcus Brinkmann http://www.debian.org master.debian.org [EMAIL PROTECTED] for public PGP Key http://homepage.ruhr-uni-bochum.de/Marcus.Brinkmann/ PGP Key ID 36E7CD09