Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This 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.


  Search this Thread
Old 09-19-2006, 10:23 AM   #1
Registered: Nov 2003
Location: Belgium
Posts: 81

Rep: Reputation: 15
konsole window title change in SSH session

Dear all,

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?


Old 09-19-2006, 11:33 AM   #2
Senior Member
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 63
Yes it is.

I wrote a little shell script which changes a konsole tab title, and prints out the old value.

# 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
You could then write a little wrapper for ssh like this:

# 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
Old 09-19-2006, 02:50 PM   #3
Registered: Nov 2003
Location: Belgium
Posts: 81

Original Poster
Rep: Reputation: 15
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:

# 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
Old 03-03-2010, 11:10 AM   #4
LQ Newbie
Registered: Mar 2010
Posts: 1

Rep: Reputation: 0
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
DCOPClient::attachInternal. Attach failed Could not open network socket
SocketUNIXConnect: Cannot connect to non-local host
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;
# is a script of mine;
# + means exclusively with tab name given in env var.
[sw18-0216t]sw18:$VIEW_ROOT>alias setview
cde useview !:1; +

It would be nice if there's a much simpler way.
Old 08-31-2010, 02:32 PM   #5
LQ Newbie
Registered: Apr 2005
Location: boise
Distribution: Red Hat - 6.2,7.3,9.0,FC3,FC4, FC5, Debian-3.1, Ubuntu 7x,8x,10x, DSL
Posts: 14

Rep: Reputation: 0
Got to the Settings->Edit Current Profile,
then click on the tabs tab. Change your 'Tab Title format' and 'Remote tab title format' to %w

This will use your PS1 setting on whichever machine you are on. Hope that helps....


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Change Konsole default Session name zmeda Linux - Newbie 3 08-05-2006 02:01 AM
Bash: set Konsole window title to current command bforbes Programming 5 04-19-2006 11:44 AM
Change font COLOR in window title aeruzcar Linux - General 3 09-14-2005 11:26 PM
How to change window title font size in Gnome2.2(sawfish) zhaoyoubing Linux - Newbie 0 07-19-2003 09:05 PM
change window title in terminal sandman Linux - General 4 12-15-2002 03:55 AM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 07:31 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration