From: Jim Winstead Jr. (jwinstea@jarthur.claremont.edu)
Date: 06/26/92


From: jwinstea@jarthur.claremont.edu (Jim Winstead Jr.)
Subject: Re: distinguishing virtual consoles
Date: Sat, 27 Jun 1992 00:06:22 GMT

In article <BqH4tv.71D@world.std.com> dsb@world.std.com (David Boyce) writes:
>Does anyone know of a way for a login shell to determine which virtual
>console it's running in, so you could put it in your prompt,
>for instance?

Try the 'tty' command, which I believe is part of the GNU shell
utilities, if you don't have it already.

As an example, my prompt looks like the following:

        cerebus:1: /usr/src/linux
        ; _

Cerebus is my hostname (my prompt is the same on my school's computer,
'cept it says jarthur there instead), 1 is the window number (I use
iScreen on the school's computer, so I have window numbers on both
machines), and the directory is the current working directory.

That part of the prompt is all handled by the prompt() function, which
is executed before the prompt is displayed each time. The hostname
and window number and hostname are figured out on login, and I have
cd/pwd functions to keep the current working directory updated without
running /bin/pwd all the time.

; is then the 'standard' prompt for my shell.

For those that haven't guessed, I'm not using some bloated bohemoth
like bash, tcsh, or even zsh - I'm using rc, an implementation of the
Plan 9 shell.

This goes beyond what you're asking, but I thought others might be
interested to see the sort of thing people might put into their prompt.

Oh, I should also add that the info line of my prompt is in red when
I've su'ed to root, to remind me of the dangers. :)

-- 
                                    +    Jim Winstead Jr. (CSci '95)
                                    |            Harvey Mudd College
                                    | jwinstea@jarthur.Claremont.EDU
                                    + This is all my words.  Honest!