[comp.unix.i386] prompt in cshell

hazela@watserv1.waterloo.edu (Jose Reynaldo Setti) (04/09/90)

Some time ago there was a request for a prompt that
would tell where in the subdirectory structure you
were.

This is the way I do it, using the cshell. I wanted to
now whose account and which terminal I am on -- 
in a 386/ix SVR3.2. So I put the following lines in
.cshrc:

	set TTY='tty'
	set TTY="'basename ${TTY}'"
	set USER='logname'
	alias cd 'cd \!*; set prompt="${USER}@{TTY}:`pwd`>"'
	cd .

this gives me a prompt like:
root@console:/usr >
or
jrs@vt1:/usr/jrs/foo >

It should work if I typed all '"'s in the right places. If anycone
knows how to get a similar prompt in a better way, let me know.


jr setti	       hazela@watserv1.waterloo.edu [uwaterloo.ca]
the transport group -- dept. of civil engineering -- u of waterloo
waterloo, ontario, canada N2L 3G1

jeff@samna.UUCP (Jeff Barber) (04/11/90)

In article <1785@watserv1.waterloo.edu> hazela@watserv1.waterloo.edu (Jose Reynaldo Setti) writes:
<This is the way I do it, using the cshell. I wanted to
<now whose account and which terminal I am on -- 
<in a 386/ix SVR3.2. So I put the following lines in
<.cshrc:
<
<	set TTY='tty'
<	set TTY="'basename ${TTY}'"
<	set USER='logname'
<	alias cd 'cd \!*; set prompt="${USER}@{TTY}:`pwd`>"'
<	cd .
<
<this gives me a prompt like:
<root@console:/usr >

A slight correction: the first three lines above should have all
the ' characters changed to ` characters.  Otherwise the shell
variables TTY and USER end up with the values: "basename ${TTY}"
and "logname" respectively which is clearly not what is wanted.
The ` character indicates that the output of the program between
the ` pairs is to be used.  Thus, with the replacements done, the
TTY and USER variables get the values "console" and "root".

Jeff