*BSD News Article 67241


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.anu.edu.au!harbinger.cc.monash.edu.au!news.rmit.EDU.AU!news.unimelb.EDU.AU!munnari.OZ.AU!news.ecn.uoknor.edu!news.ysu.edu!usenet.ins.cwru.edu!agate!howland.reston.ans.net!blackbush.xlink.net!ka.sub.net!ardbeg.islay.sub.org!ardbeg.islay.sub.org!pmh
From: pmh@ardbeg.islay.sub.org (Patrick M. Hausen)
Newsgroups: comp.unix.bsd.misc
Subject: Re: Help! How do I set my prompt?
Date: 28 Apr 1996 21:45:24 +0200
Organization: Patrick M. Hausen - private site
Lines: 47
Message-ID: <pmh.830720362@ardbeg.islay.sub.org>
References: <317E4568.62C0@cyclesak.com> <4lqbrf$c7k@innocence.interface-business.de>
NNTP-Posting-Host: localhost
X-Newsreader: NN version 6.5.0 #1 (NOV)

j@ida.interface-business.de (J Wunsch) writes:

>"Tokewanna Inc." <sales@cyclesak.com> writes:
>>I'm using csh shell and I was wondering what the set command is so
>>it will show my directory locations.  Thanks!

>``set prompt'', but you knew this. :-)

>The standard csh doesn't provide a good means to arrange for a prompt
>displaying the cwd.  You can only do this by overriding the `cd',
>`pushd', and `popd' builtins by something that uses the `chdir'
>builtin, and sets the prompt internal variable.  Alas, pushd and popd
>are rather complex to implement.

>Modern shells (tcsh, bash) allow for a much more sophisticated prompt
>string, so your wishes should easily be accomplished there.  For
>example, all my xterms display the $cwd in their window title.

... as do mine, but why don't you give him your .bashrc code?

If you're using bash, you can get your prompt set by (for example):

	HOSTNAME=`hostname -s`
	if [ "$TERM" = xterm ]
	then
	        PROMPT_COMMAND='echo -n "^[]0;${USER}@${HOSTNAME}: `dirs`^G"'
        	PS1="$ "
	else
        	PROMPT_COMMAND=
        	PS1="${USER}@${HOSTNAME}:\${PWD}> "
	fi
	export PROMPT_COMMAND PS1

Note, that the strings ^[ and ^G stand for the single characters ESC and
CTRL-G, respectively.

On the SVR4 systems at work I use the Korn shell with a setting like:

	export PS1='$PWD> '

You get the idea ...

Paddy
-- 
Patrick M. Hausen   Gerwigstr. 11   76131 Karlsruhe   pmh@islay.sub.org
"Responsibility, n. A detachable burden easily shifted to the shoulders
  of God, Fate or Fortune, Luck, or one's neighbor" -- Ambrose Bierce