Header Shadow Image

Terminal Emulators: Dynamically changing the tab title text in Konsole and alternative emulators.

Some time back I was introduced to konsole and never went back to terminal emulators like xterm, however a list of good tabbed linux terminal emulator alternatives is provided below in case konsole isn't available to all.  There are ones such as putty however this is an Windows ssh client.   Just the fact that I could start multiple sessions in tabs from a single window freed my desktop from alot of clutter I could do without.  One thing I wanted to do from an early start with konsole is to have the tabs renamed depending on where I was working with such as including the host name when working with multiple hosts so I could easily tell where I was amongst the many tabs I had open.  Here's how to go about renaming tabs using the DCOP communication protocol bound to DCOP commonly used on Fedora 8 and earlier.  including all applications not yet updated to use the newer KDE communication protocol DBUS that came with Fedora 9 and above. 

/usr/bin/konsole SOLUTION

The solution was to use the built in dcop command to dynamically update the konsole tabs using this code inside the ~/.bashrc file on my Fedora installation:

if [[ $KONSOLE_DCOP != “” ]]; then
        # Check if the KONSOLE* variables actually hold konsole instances that can be worked with.
        KONSOLE_RESULT=`dcop $KONSOLE_DCOP currentSession 2>&1`;
        echo $RESULT|egrep -i "call failed|object not accessible" 2>&1 >/dev/null;
        if [[ $? == 1 ]]; then
                SESSION=`dcop $KONSOLE_DCOP currentSession`;dcop `dcopclient $KONSOLE_DCOP` $SESSION renameSession "LS"
                echo $(date)": ~./.bashrc: Error: Received either 'call failed' or object not accessible' when trying to work with KONSOLE_DCOP or KONSOLE_DCOP_SESSION… " >> /var/log/messages;


Once you edit your ~/.bashrc file run the following

$ . ./.bashrc
$ tail -f /var/log/messages  (ctrl-c when done viewing)

The related global konsole variables should be already set similar to the following:


In case above were not set automatically, it may be possible to set them using the below two lines if you are still running a konsole versions that has retained the DCOP source code (See more on this below):

declare -x KONSOLE_DCOP_SESSION="DCOPRef("`ps ax|grep /usr/bin/konsole|egrep -v grep|awk '{ print "konsole-"$1 }'`",session-"`echo $KONSOLE_DBUS_SESSION|sed -e "s/[^0-9]//g"`")"

declare -x KONSOLE_DCOP="DCOPRef("`ps ax|grep /usr/bin/konsole|egrep -v grep|awk '{ print "konsole-"$1 }'`",konsole)"


Of course, the above assumes you're using DBUS and you are using KDE 4.  In the event you are using versions prior to KDE 4, try the instructions on this page with regards to restarting DCOP server for hints on debugging and restarting DCOP problems.  Test the variables with


and then try again.  Should you receive a call failed or object not accessible error message, check the above KONSOLE_DCOP and KONSOLE_DCOP_SESSION variables and try the solutions with regards to restarting DCOP server as the problems may be related to DCOP

However, as of this writing and per konsole-devel [AT] kde.org email group KONSOLE _DCOP support no longer appears working as of KDE 4 due to the introduction of DBUS.  Further to that, the old code for DCOP support in konsole appears to have been removed so trying to set the variables per above might not work out for you, as mentioned.  Unfortunately, due to the replacement of DCOP with DBUS, there is more push to work on the DBUS scripting interface as of Dec 4th 2008 then to reinstate the old DCOP scripting interface from the konsole-devel community.  I suppose this is to provide incentive for developers to work with DBUS instead of DCOP, however as of Dec 4th 2008, some attempts have been made to start work on the DBUS equivalent so we can expect this in the near future.  Here is more information on the DBUS support as of Dec 5th 2008.

However, there are aternatives to konsole per below you may find helpful and may even have a smaller footprint.

Alternative tabbed emulators to Konsole,many that also include some features like renaming tabs, window titles etc.:

/usr/bin/mrxvt SOLUTION

mrxvt is another tabbed emulator for Linux.  It however didn't come preinstalled on my Fedora 9 so you may need to install it.  There are a number of sites that could carry it including rpmfind.net however you may get away with this simple solution for installing it:

  1. yum search mrxvt             
  2. yum install mrxvt   

On my system this installed mrxvt in /usr/bin/mrxvtmrxvt comes with quite an extensive man page: man mrxvt.  This details well settings you can use.  Here are a few examples.


Command Effect
echo -ne "\e]61;"$(hostname;pwd)"\a" Change the current tab title to the hostname and present working directory (pwd)
echo -ne "\e]60;$(whoami;date;pwd)\a Set the terminal title (Window title) to the current user name, date and present working directory.
echo -ne "\e]62;$(pwd)\a" Set both the tab title and window title to the present working directory.
$ mrxvt -mtw 40 Start mrxvt with this command to set the maximum size of the tab title allowed to 40.  Max is 40.

There are many more including window transparency etc.  In addition to the above, you can also check out the /usr/share/doc/mrxvt-0.5.3/ path for more infromation including the ./scripts path in the doc path for scripts you can compile which can automate some of the above.  This site has additional tips.  Another great resource on this can be found at this FAQ section.


/usr/bin/gnome-terminal SOLUTION

This is the Gnome counterpart to the KDE konsole but doesn't allow scripting tab title and window title names.


/usr/bin/yakuake SOLUTION

Another great terminal emulator for KDE and based on konsoleyakuake IS essentially konsole with D-Bus interface scripted. The full page can be seen here.  To install it if you do not already have the application follow these simple steps.

   1. yum search yakuake           
   2. yum install yakuake 

Once installed run it by typing yakuake at the command terminal.    One annoying feature I find of yakuake is probably it's intential feature, in that it hands from the top of the scrreen.  I like to move the windw around the screen however couldn't seam to locate the feature.  In either case, here is how to script some of it's functionality from within it's windows:


Command Effect
$ dbus-send –print-reply –type=method_call –dest='org.kde.yakuake' /yakuake/tabs org.kde.yakuake.setTabTitle int32:0 string:"MyTabTitle" Sets the tab title to "MyTabTitle"

The issue however is that once the window is minimized / retracted, the tab title changes back to "Shell" overwriting the above.  The yakuake home page can be found here.


5 Responses to “Terminal Emulators: Dynamically changing the tab title text in Konsole and alternative emulators.”

  1. Or you could skip all of that nonsense, use screen and let it do all that for you.

  2. Hey G. Quagmire,

    Cool. Curious. Please demonstrate how screen can rename Konsole, gnome-terminal or mrxvt tab title text. 🙂


  3. check out .bashrc setting for screen, works fine


    (not my website)

  4. […] Konsole (/usr/bin/konsole) terminal emulator from KDE or any other terminal emulator you may have. […]

  5. […] in checking into my system workings is ‘konsole‘. This is just one variation of many dozens of GUI based Linux consoles, however I find this one most useful due to it’s behavior like a browser allowing you to open […]

Leave a Reply

You must be logged in to post a comment.

  Copyright © 2003 - 2013 Tom Kacperski (microdevsys.com). All rights reserved.

Creative Commons License
This work is licensed under a Creative Commons Attribution 3.0 Unported License