LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
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.

Notices

Reply
 
Search this Thread
Old 09-19-2006, 10:23 AM   #1
maenho
Member
 
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?

thanks,

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

Rep: Reputation: 62
Yes it is.

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
 
Old 09-19-2006, 02:50 PM   #3
maenho
Member
 
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:

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
 
Old 03-03-2010, 11:10 AM   #4
jamesshau
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 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 +


It would be nice if there's a much simpler way.
 
Old 08-31-2010, 02:32 PM   #5
RickyRockRat
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....
 
  


Reply


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


All times are GMT -5. The time now is 11:51 AM.

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