From owner-freebsd-questions Wed Jul 5 20: 5:21 2000 Delivered-To: freebsd-questions@freebsd.org Received: from [24.163.183.119] (nic-163-c183-119.mn.mediaone.net [24.163.183.119]) by hub.freebsd.org (Postfix) with SMTP id 9D34D37C06E for ; Wed, 5 Jul 2000 20:05:14 -0700 (PDT) (envelope-from root@pounded.nailed.org) Received: from 24.163.183.119 by 24.163.183.119; Wed, 5 Jul 2000 22:05:09 -0500 User-Agent: Microsoft-Outlook-Express-Macintosh-Edition/5.02.2022 Date: Wed, 05 Jul 2000 22:05:08 -0500 Subject: ANSI sequences in PS1? From: Senior Root To: Message-ID: Mime-version: 1.0 Content-type: text/plain; charset="US-ASCII" Content-transfer-encoding: 7bit Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Hey there folks. I'm writing regarding a question about how to implement ANSI color codes in the PS1 variable. I attempted to do so with the following instructions (obtained from a linux site, but which seemed portable enough), but ran into problems, ie. tput apparrently thinks that cons25 (the default console set by /etc/ttys) doesen't have ANSI capabilities, when in fact it supports them very well. Anyone have solutions or past experience with this? Instructions are as follows: 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} \@ ${RESET_CRS}${BOLD}${ALT_FOREG}\]\u\[${NORMAL}\]@\h:\w\$ " } set_prompt This is will display a yellow username, (in normal colors) "@" + hostname, ":" + path, "$" and a cyan clock in the upper right corner, 10 columns from the line end. The clock will only be updated when you enter a new command, though (or press return). The clock is annyoing when scrolling up or cutting and pasting. However, it is just a demonstration how to do cursor movements. Note that you don't need to enter _any_ escape commands, because I use tput to get them. See "man 5 terminfo" for a list of terminal capabilities. Thanks in advance, Eric Djerf To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message