From owner-freebsd-questions Fri Sep 26 02:56:58 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.7/8.8.7) id CAA25807 for questions-outgoing; Fri, 26 Sep 1997 02:56:58 -0700 (PDT) Received: from freebie.lemis.com (freebie.lemis.com [192.109.197.137]) by hub.freebsd.org (8.8.7/8.8.7) with ESMTP id CAA25801 for ; Fri, 26 Sep 1997 02:56:54 -0700 (PDT) Received: (from grog@localhost) by freebie.lemis.com (8.8.7/8.8.5) id TAA08713; Fri, 26 Sep 1997 19:26:31 +0930 (CST) Message-ID: <19970926192631.61428@lemis.com> Date: Fri, 26 Sep 1997 19:26:31 +0930 From: Greg Lehey To: Jose Monteiro Cc: freebsd-questions@FreeBSD.ORG Subject: Re: Setting PS1 References: <342c7acd.3384017@mail.leirianet.pt> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.81e In-Reply-To: <342c7acd.3384017@mail.leirianet.pt>; from Jose Monteiro on Fri, Sep 26, 1997 at 09:11:57AM +0000 Organisation: LEMIS, PO Box 460, Echunga SA 5153, Australia Phone: +61-8-8388-8250 Fax: +61-8-8388-8250 Mobile: +61-41-739-7062 WWW-Home-Page: http://www.lemis.com/~grog Fight-Spam-Now: http://www.cauce.org Sender: owner-freebsd-questions@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk On Fri, Sep 26, 1997 at 09:11:57AM +0000, Jose Monteiro wrote: > Hi, > > Originally my .bash_profile came with: > > # # set prompt: ``username@hostname$ '' > PS1="`whoami`@`hostname | sed 's/\..*//'`" > case `id -u` in > 0) PS1="${PS1} # ";; > *) PS1="${PS1} $ ";; > esac > > In order to put the current working directory in PS1, I changed the > above lines to: > > # # set prompt: ``username@hostname$ '' > PS1="`whoami`@`hostname | sed 's/\..*//'`" > case `id -u` in > 0) PS1="${PS1} ${PWD}# ";; > *) PS1="${PS1} ${PWD}$ ";; > esac > > But the result is a permanent $HOME in PS1, even if I cd to anywhere > else. It's also a cumbersome way of doing it. > What should I do in order to get a prompt like: > > jose@thor /usr/local$ cd bin > jose@thor /usr/local/bin$ AFAIK the following information only applies to bash, but some other shells have similar metavariables. \u represents your user name \h represents your host name \w represents your home directory There are more in the bash man page, but these are the ones you want. Write: PS1='\u@\h \w\$ ' This is in fact not too different from mine: PS1='=== \u@\h (`tty`) \w \# -> ' Greg