Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
I would like the window title and if possible also the tab title of the KDE terminal program konsole to change to the name of the remote host when I start an SSH session. Would that be possible?
I wrote a little shell script which changes a konsole tab title, and prints out the old value.
Code:
#!/bin/bash
# This script is called "konsole_tabname"
if [ -n "$KONSOLE_DCOP_SESSION" ] ; then
dcop $KONSOLE_DCOP_SESSION sessionName
dcop $KONSOLE_DCOP_SESSION renameSession "$1" 2> /dev/null 1>&2
fi
You could then write a little wrapper for ssh like this:
Code:
#!/bin/bash
# This script is called "kssh". DO NOT call it ssh or it
# will call itself recursively!
old_tab_title="$(konsole_tabname "ssh session")"
ssh "$@"
konsole_tabname "$old_tab_title" > /dev/null
thanx, that is exactly what I needed. I made a minor change to your script so that the tab title shows the hostname. In case anybody is interested:
Code:
# This script is called "kssh". DO NOT call it ssh or it
# will call itself recursively!
eval hostname=\$$#
old_tab_title="$(konsole_tabname "$hostname")"
ssh "$@"
konsole_tabname "$old_tab_title" > /dev/null
I got help from the posts. I'd like to contribute something hopefully also useful.
1. It's not necessary to name "kssh" differently from ssh, if you use the full path, say /usr/bin/ssh in "kssh". This saved me from the "oops, should have use kssh, not ssh" moments.
2. dcop works for me only on the machine I launched konsole.
(Got this kind of errors:
[sw18-0216t]sw18:$VIEW_ROOT>dcop --user jshau --session .DCOPserver_swvnc3.kickfire.com__50
SocketUNIXConnect: Cannot connect to non-local host swvnc3.kickfire.com
DCOPClient::attachInternal. Attach failed Could not open network socket
SocketUNIXConnect: Cannot connect to non-local host swvnc3.kickfire.com
DCOPClient::attachInternal. Attach failed Could not open network socket
ERROR: Couldn't attach to DCOP server!
)
But I'd like to be able update the tab name as I continue to ssh to
other machines, or more importantly to me, as I use svn views. I need
to do something a bit complicated as follows.
* All the following is done only for interactive shell (e.g. check the prompt variable).
o Upon shell startup, (including use svn view in my case)
if KONSOLE_DCOP_SESSION is defined and first time for this terminal,
= mkdir -p ~/rdcop/`tty`; let it be TTY_DIR
= launch a background process, which
- save its pid in a file in TTY_DIR
- periodically (e.g. 1 sec) set the session tab name with the
last line in file <TTY_DIR>/tabname.stk.
- self clean up if the tty no longer in /dev/pts.
append the desired tab name to <TTY_DIR>/tabname.stk.
also save it in an env var for this shell process.
o In "kssh", mainly need to let the login shell in the remote
machine to know which <TTY_DIR> to use. I just saved it in
a file ~/rdcop/<remote hostname>, followed by sync(1) to make
to sure the remote shell will pick it up reliably.
o I have two flavors of "popping" tabname.stk: popping to
the given tab name (saved in env var), inclusively or exclusivly.
Use the inclusive version upon logout of login shell (in .logout
for tcsh). I use the exclusive version when the popping needs
to be done by "the parent", e.g.
# cde useview is my command to use svn view;
# pop_konsole_tabname.pl is a script of mine;
# + means exclusively with tab name given in env var.
[sw18-0216t]sw18:$VIEW_ROOT>alias setview
cde useview !:1; pop_konsole_tabname.pl +
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.