Date: Fri, 26 Sep 1997 19:26:31 +0930 From: Greg Lehey <grog@lemis.com> To: Jose Monteiro <jm@pluriproj.pt> Cc: freebsd-questions@FreeBSD.ORG Subject: Re: Setting PS1 Message-ID: <19970926192631.61428@lemis.com> In-Reply-To: <342c7acd.3384017@mail.leirianet.pt>; from Jose Monteiro on Fri, Sep 26, 1997 at 09:11:57AM %2B0000 References: <342c7acd.3384017@mail.leirianet.pt>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19970926192631.61428>