Xfce Forum

Sub domains
 

You are not logged in.

#1 2026-08-28 17:00:17

organicode
Member
Registered: 2026-04-01
Posts: 30
LinuxFirefox 140.0

More useful title for terminal tabs? [SOLVED]

While in the process of adapting Triskel (KDE) to be more like Manjaro Xfce and replacing Konsole with xfce4-terminal, I identified one thing that I really liked from Konsole.

This is how Konsole (of KDE) does does tab titles by default, name of running process after subtle ~ or -, eg.

  |  ~ : bash   |  - : sudo -i   |  ~ : wget -c   |  ~ : sleep 200   |  ~ : rsync   | 

Less useful and more kludge is displaying user@hostname, ie. below is what xfce terminal shows, eg :

  |  user1@compute |  root@comput |  user1@compute |  user1@compute |  user1@compute | 

BTW in case devs don't know, the Help button on the Title Popup-Editor-Bubble links to a broken/non-existent page:

I did a blind probe/test, which seems to indicate only the following dynamic variables exist for tab titles:
%# : the tab number (eg. "1" for first tab, then "2", etc...)
%d : username of user that started the tab?? Even when root it says non-root 'user1'???
%D : home dir of user that started the tab?? Even when root it says /home/user1/ ???, and
%w : (default) the slightly more useful title (eg. user1@compu..., or root@compu...)

What may be intuitive, user-friendly, less kludge could be something like:
%c : command (full with options etc), and
%C : command (first word ie. "$0" only)

The speculative '%c' above would at least result in something like below, which would be helpful:

  |   bash     |   sudo -i     |   wget -c     |   sleep 200     |   rsync -avu    | 

EDIT: So I guess my question is, have I just missed something, or is the thing I'm looking for just not an option?

Added later 8 h 54 min 32 s:
Guessing by lack of response from this learned community that there is no method to easily do above.

I re-edited the above post to make it hopefully extra readable, when I get time i'll patch xfce4-terminal to do this and produce a fairly detailed post on re-building xfce4-terminal on a Trisquel (debian) amd64 setup (until maybe it ends up in the main project). In the meantime thanks for reading, non-responses are also responses. Any further input will of course still be apprciated. Till then, peace and joy to all. smile

Last edited by organicode (Today 02:26:40)


No LLM was used in the production of this post

Offline

#2 2026-08-29 10:31:55

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 12,671
LinuxFirefox 154.0

Re: More useful title for terminal tabs? [SOLVED]

If you are using bash as your shell, you can use it's trap/DEBUG with PROMPT_COMMAND extensions to accomplish the same effect:

trap '[[ "$BASH_COMMAND" == "$PROMPT_COMMAND" ]] || printf "\e]0;%s : %s\a" "$PWD" "$BASH_COMMAND"' DEBUG
PROMPT_COMMAND='printf "\e]0;%s\a" "$PWD"'

Place this code in your ~/.bashrc file and open a new terminal window to test.


Mark solved threads as [SOLVED] to make it easier for others to find solutions.
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#3 2026-08-31 15:11:27

bigbadaboum
Member
Registered: 2022-12-22
Posts: 29
LinuxUnknown

Re: More useful title for terminal tabs? [SOLVED]

Work great for me.

xfce4-terminal-0.6.3
bash-4.4.23
ncurses-6.3

It's sad to think that this thread will get buried in the forum, we need a new option called [Tip of the Week]  smile .

Offline

#4 2026-09-05 20:52:16

organicode
Member
Registered: 2026-04-01
Posts: 30
LinuxFirefox 140.0

Re: More useful title for terminal tabs? [SOLVED]

ToZ wrote:

Place this code in your ~/.bashrc

Niiiice! Def a top tip! Thanks ToZ. The '$PWD' part seems to output the full path to a folder (ie. "/home/user1"), so i replaced it with a more simple dash '-' for root users or a tilde '~' for non-root. I never want a full PWD in the title.

This is a result of mangling your code, ToZ, but it only seems to work for non-root for some reason??

if [[ ${EUID} == 0 ]] ; then
	trap '[[ "$BASH_COMMAND" == "$PROMPT_COMMAND" ]] || printf "\e]0;- : %s\a" "$BASH_COMMAND"' DEBUG
  PROMPT_COMMAND='printf "\e]0;- : bash\a"'
else
	trap '[[ "$BASH_COMMAND" == "$PROMPT_COMMAND" ]] || printf "\e]0;~ : %s\a" "$BASH_COMMAND"' DEBUG
  PROMPT_COMMAND='printf "\e]0;~ : bash\a"'
fi

Getting sooo close! big_smile


No LLM was used in the production of this post

Offline

#5 Yesterday 02:18:06

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 12,671
LinuxFirefox 155.0

Re: More useful title for terminal tabs? [SOLVED]

but it only seems to work for non-root for some reason??

How are you running these root commands/sessions?


Mark solved threads as [SOLVED] to make it easier for others to find solutions.
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#6 Yesterday 15:16:02

organicode
Member
Registered: 2026-04-01
Posts: 30
LinuxFirefox 140.0

Re: More useful title for terminal tabs? [SOLVED]

sudo -i # or
sudo su

I suppose I'm expecting something like what is is the OP, like sudo -i to appear as the "running" command, until i launch another command as root i guess. smile


No LLM was used in the production of this post

Offline

#7 Yesterday 17:50:22

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 12,671
LinuxFirefox 155.0

Re: More useful title for terminal tabs? [SOLVED]

For "sudo -i", you need to put the same snippet into the root's bash initialization file (/root/.bash_profile).

"sudo su" is somewhat redundant as both commands kind of do the same thing (sudo to run commands as root, su to get a root login), but try running "sudo su -" which will simulate a root login and read .bash_profile as in "sudo -i".


Mark solved threads as [SOLVED] to make it easier for others to find solutions.
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#8 Today 02:25:45

organicode
Member
Registered: 2026-04-01
Posts: 30
LinuxFirefox 140.0

Re: More useful title for terminal tabs? [SOLVED]

ToZ wrote:

put the same snippet into the root's bash initialization file

Don't mind me, its as if the internet switched my brain off hahaha

MARKING AS SOLVED

Congrats all! Long live freedom software! big_smile


No LLM was used in the production of this post

Offline

Registered users online in this topic: 0, guests: 1
[Bot] CCBot

Board footer

Powered by FluxBB
Modified by Visman

[ Generated in 0.027 seconds, 7 queries executed - Memory usage: 550.41 KiB (Peak: 567.39 KiB) ]