How can I change the konsole tab title? By default, it's set to %u : %n
, so it always changes automatically.
I can set it with:
qdbus org.kde.konsole $KONSOLE_DBUS_SESSION setTitle 1 "My Title"
But as soon as you run something in the console, it changes back to %u : %n
. Of course. I can set it to %w
to tell it to set the title to "Window Title set by shell", but later (if I don't explicitly set it), it will be empty. (Every new tab will be empty, unless I set it.)
The question is how to make it persistent (or how to switch profile via command line)? I can make another profile in which the title format is set to %w
, and before I set my custom title, switch to that profile.
edit: I think I have found the answer
qdbus org.kde.konsole $KONSOLE_DBUS_SESSION setTabTitleFormat 0 "" qdbus org.kde.konsole $KONSOLE_DBUS_SESSION setTitle 0 "My Title"
Posting my own solution to this old question, because
org.kde.konsole
echo
require a permanent change to konsole settingsAfter reading the Scripting Konsole chapter in the konsole documentation I wrote these bash functions which can be added to
$HOME/.bashrc
:Example 1: set both local & remote tab formats
Example 2: leave remote tab format unchanged
Example 3: leave local tab format unchanged
You can also use this function to set the tab title dynamically to
%w
for theecho
solutions.You may need to use this variant:
echo -ne "\033]30;test change title\007"
To set title "MyTitle" on your new tab the right syntax is:
(tested on Konsole version 17.12.3, S.O. Kubuntu 18.04)
Konsole -> Settings -> Configure Konsole ...
Enable option "Show window title on the titlebar" then run in console:
I was never happy with setting the title for konsole windows, then I saw Tim's comment. This was a big improvement for me. Thank you, Tim!!
But that did not quite get me where I wanted to be.
I wanted to go beyond typing in the given command line example because I have a terrible memory and 3 weeks from now, I will not remember the character sequence of the variant.
I wanted to be able to create an alias that would allow me to do the following:
The 'T' alias changes the window title to 'titleName' and the alias 'DT' changes the window title to '%d titleName' where %d is the directory name.
It took some experimenting. It is worth mentioning that I took a bad first step by trying to edit my .cshrc first. I could not quite get the backslash escaping to work correctly, not being sure when the escaping was taking place: when reading the .cshrc file or when running the alias. After a few minutes of frustration, I tried defining the alias first, character by character, in a cycle:
This worked and I got my alias to work in a minute or two. Once the aliases were working, I just copied and pasted them into my .cshrc file and the aliases both worked. My working aliases are:
Note that I had to use the environment variable 'Z' to make the aliases 'variable'. Not too elegant, but it largely satisfies me. So after changing my .cshrc and sourcing the .cshrc file in the window shell, I do this
and I get my title set. When I change to a different task, I change Z to a new name and run my alias 'T' or 'DT' again.
konsole -p tabtitle='some title: %w'
For more options try
konsole --list-profile-properties
.