Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Differrent prompt for remote machines



On Fri, 30 Mar 2001, Dominik Vogt wrote:

> I want to solve the following problem:
>
>   I'm often logged in to different machines that all share the
>   same zsh configuration files (via ssh or telnet).  But I
>   frequently forget on which machine I am, mainly because either
>   I have the machine name in my promt for all machines or for no
>   machine at all.  What I'd like to have is this:
>
>     For the machine at which I logged in:
>
>       <username> ...
>
>     and
>
>       <username>@<machine> ...
>
>     for remote logins (and possibly the machine name in bright
>     red for our server and in a different colour for other remote
>     machines).
>
>   Basically it breaks down to detecting if the shell runs on a
>   local terminal or through a network connection.
>

One possibility is to use finger (is it available on all systems?)
Something like

finger -f
root     Super-User            console        3 Tue 17:02
root     Super-User            pts/1            Fri 09:00  foo.bar.com

then check for current line and see if the last field is empty. Solaris
supports who -m:

# who -m
root       pts/1        Mar 30 09:00    (foo.bar.com)

that basically gives the same information, but it depends on system, of
course.

You could check for pty, but it won't catch the case when you run under
X11.



-andrej



Messages sorted by: Reverse Date, Date, Thread, Author