Operating System - HP-UX
1751877 Members
5396 Online
108782 Solutions
New Discussion юеВ

displaying hostname on xterm window titlebar

 
SOLVED
Go to solution
Shivkumar
Super Advisor

displaying hostname on xterm window titlebar

Hi,

I am working on various hpux 11i boxes by connecting through Reflection 12 remote connection software. Sometime it is very confusing to identify on which box i am working.

Can anyone suggest "xterm" command to display the titlebar of the hostname of the unix servers ?

Thanks,
Shiv
8 REPLIES 8
Paul Eadington_1
Valued Contributor
Solution

Re: displaying hostname on xterm window titlebar

I use the following line buried in a little script for popping up new windows.

nohup xterm -title $1 -n $1 -sb -e /opt/ssh/bin/ssh $1 -l root 2>&1 1>/dev/null&

Where $1 is the name of the system

Hope this helps
I had hair .. then I got into Unix
Stephen Keane
Honored Contributor

Re: displaying hostname on xterm window titlebar

xterm -title `uname -n` ....

This will show you the hostname of the box at the time the xterm is created. It won't change when you, say, rlogin to another box though. The usual technique is to modify PS1 prompt to include the hostname.

Eknath
Trusted Contributor

Re: displaying hostname on xterm window titlebar

Hi Shiv

try this

xterm -title `hostname` ....

but I what appreciate stephen says

thanx

eknath
Enrico P.
Honored Contributor

Re: displaying hostname on xterm window titlebar

Hi,
I use reflection version 6, if I insert the hostname in the "description" field of the "Connection Type" Windows I can see the hostname in the window titlebar.
I don't know if this changed in the version 12.

Enrico
Ganesha Sridhara
Honored Contributor

Re: displaying hostname on xterm window titlebar

Here is sample line:

---------- HP Term -----------
"Hpterm" _o f.exec "hpterm -ls -sb -sl 2048 -fg white -bg black -cr red -n -title "

---------- DT Term -----------
"DtTerm" _o f.exec "dtterm -ls -sb -sl 2048 -fg black -cr red -n -title "

---------- XTerm -----------
"Xterm" _o f.exec "xterm -ls -sb -sl 2048 -fg white -cr red -n -title "


Note add the above line in file:
~/.dt/dtwmrc

To get the list in the mouse right click you can add:

Menu DtRootMenu
{
" Shivkumar " _o f.title
" SHIV " _o f.title
"Hpterm" _o f.exec "hpterm -ls -sb -sl 2048 -fg white -bg black -cr red -n -title "

"DtTerm" _o f.exec "dtterm -ls -sb -sl 2048 -fg black -cr red -n -title "

"Xterm" _o f.exec "xterm -ls -sb -sl 2048 -fg white -cr red -n -title "
}


Regards
Ganesha Sridhara
Rick Garland
Honored Contributor

Re: displaying hostname on xterm window titlebar

xterm -name -title ...

Other options you can include such as colors and all but these will get the name of the window and the title on the window. Will work for dtterm as well.

H.Merijn Brand (procura
Honored Contributor

Re: displaying hostname on xterm window titlebar

In the tcsh, you have a special alias 'cwdcmd' that get executed when you do a 'cd'

I've set it to

alias cwdcmd 'glob "\E]0;'${LOGNAME}'@'${HOST}':$cwd ['$$':'$tty']\7"'

where \E is an escape, and \7 the Ctrl-G

This is the escape sequence for an xterm to change the title bar. With this knowledge, you can change it whenever you like, and not - as suggested by all above - just at startup

# perl -le'print "\e]0;$ENV{HOST}\7"'

is one way to set your titlebar to what currently is in $HOST

Enjoy, Have FUN! H.Merijn
Enjoy, Have FUN! H.Merijn
Doug O'Leary
Honored Contributor

Re: displaying hostname on xterm window titlebar

Hey;

I have a function in my ~/.kshrc file on all systems that I manage that updates the xterm title with who I'm logged in as, what system I'm on and my current directory. It's a pretty cool little utility. For instance, my current window shows

dkoleary@linux:/home/dkoleary/working/clients

as the xterm title.
mcd()
{ Me=$(whoami)
Host=$(hostname)
cd $*
Pwd=$(pwd)
echo "^[]0;${Me}@${Host}:${Pwd}^G\c"
}

The definition is as follows:

The echo command is a little tricky. For the ^[ key sequence, hit V and for the ^G, hit VG

Once you have that, alias cd to mcd and you're done...

HTH;

Doug


------
Senior UNIX Admin
O'Leary Computers Inc
linkedin: http://www.linkedin.com/dkoleary
Resume: http://www.olearycomputers.com/resume.html