Set name of Konsole window

8,605

Solution 1

you can add a bash function at the end of your ~/.bashrc

title() {
  echo $'\033]30;'$*$'\007'
}

(after saving .bashrc remember to type in the console: . ~/.bashrc to add the function to your shell, or else you can open a new terminal)

You can use the new function like this:

title this is my console

Solution 2

It seems, at least in recent versions of Konsole, the title cannot be changed. You can change the tab, though, for example by the following ANSI sequence:

echo $'\033]30;NewName\007'

Update:

For inspiration, I tried another approach. I created a file ~/konsole-name.sh:

function kname {
    name=$(grep $WINDOWID .knamerc)
    name=${name#*$'\t'}
    if [[ $name ]] ; then
        qdbus org.kde.konsole $KONSOLE_DBUS_SESSION \
            org.kde.konsole.Session.setTitle 1 $name > /dev/null
    fi
}

function kname-set {
    sed -i "/^$WINDOWID\t/d" .knamerc
    echo $WINDOWID$'\t'"$1" >> .knamerc
    kname
}

And I added the following to my .bashrc:

. ~/konsole-name.sh && kname

Then, when a new konsole is started, I can just type kname-set THE-ONE-TRUE-KONSOLE in the first window. All newly created tabs will be named the same. You can give any konsole its "name" by calling the function in its first tab.

You might need to clobber the file .knamerc on logout.

The rest is left as an exercise to the reader :-)

Share:
8,605

Related videos on Youtube

dotancohen
Author by

dotancohen

Updated on September 18, 2022

Comments

  • dotancohen
    dotancohen over 1 year

    How can one set the name of a Konsole window in KDE? I know that we can change the names of the tabs, and the Konsole window title is preconfigured to use the name of the current tab, but this is not what I would like to do.

    I have one Konsole window with three tabs that I always keep open (vimwiki, cmus, and a custom Python script) which I would like to be easy to find among my sea of other Konsole windows, each with its own set of tags.

    As a workaround name all tabs to the name that I would like for the window, but that has many drawbacks. A simple way to rename the entire window would be best. I could also use a different terminal emulator for this 'special' window, but I really like Konsole.

    • choroba
      choroba over 10 years
    • dotancohen
      dotancohen over 10 years
      @choroba: Thank you, but that only sets the name of the first tab in a newly-opened Konsole window. It has no functionality advantage over setting the tab name in all the extant window tabs, which as I mentioned has drawbacks.
    • choroba
      choroba over 10 years
  • terdon
    terdon over 10 years
  • dotancohen
    dotancohen over 10 years
    Thank you choroba, but as I mention in the OP, setting all the tabs' titles is not practical and has too many drawbacks.
  • choroba
    choroba over 10 years
    @dotancohen: Check the update.
  • Uyghur Lives Matter
    Uyghur Lives Matter over 8 years
    Gnome terminal has since removed this functionality unfortunately.
  • dotancohen
    dotancohen over 3 years
    Thank you Lucio!
  • Cymatical
    Cymatical over 2 years
    Is this valid in 2021 for KDE Plasma 5+?
  • Cymatical
    Cymatical over 2 years
    Is this valid in 2021 for KDE Plasma 5+?
  • Cymatical
    Cymatical over 2 years
    Is this valid in 2021 for KDE Plasma 5+?
  • choroba
    choroba over 2 years
    @Cymatical: I have no idea. I moved to LXDE.
  • Simon1901
    Simon1901 over 2 years
    Not sure, dont remember what the command does. 7+years ago