Xfce Forum

Sub domains
 

You are not logged in.

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

organicode
Member
Registered: 2026-04-01
Posts: 31
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 (2026-09-07 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,695
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 ---

Online

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

bigbadaboum
Member
Registered: 2022-12-22
Posts: 30
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: 31
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 2026-09-06 02:18:06

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 12,695
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 ---

Online

#6 2026-09-06 15:16:02

organicode
Member
Registered: 2026-04-01
Posts: 31
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 2026-09-06 17:50:22

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 12,695
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 ---

Online

#8 2026-09-07 02:25:45

organicode
Member
Registered: 2026-04-01
Posts: 31
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

#9 2026-09-19 14:15:18

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

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

Just a final post to outline exactly what I did for Trisquel 12.0 Ecne (KDE aka Triskel):

The bash rc files are slightly different between root and normal users but that doesn't affect what you need to do to make the tab titles cleaner.

There are two places to make changes for two distinct reasons:

1. Under the following comment:

# If this is an xterm set the title to user@host:dir

Add:

# ...Actually no, Organicode comments out that, and uses simpler default title, namely
#    'bash' for logged-in user, else name of user being "acted". When sudo, displays
#    either 'sudo', 'root' or 'su' to keep user slightly unaccustom to use.

Then in the 'case' condition replace the line starting with "PS1=" with the following:

    # Commented by Organicode (see above)
#     PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
    # Added by Organicode
    if [[ ${EUID} == 0 ]] ; then
      case $(($(date +%s)%3)) in
        1) TITLE_USER=root;;
        2) TITLE_USER=su;;
        *) TITLE_USER=sudo;;
      esac
      PS1="\[\e]0;- : $TITLE_USER\a\]$PS1"
    else
      seshUser="${SESSION_MANAGER/local\/}"
      seshUser="${seshUser%%:*}" # rm everything after ':'
      if [ "$USER" = "$seshUser" ]; then
        TITLE_USER="~"
      else
        TITLE_USER="$USER"
      fi
      PS1="\[\e]0;$TITLE_USER : bash\a\]$PS1"
    fi
    unset seshUser
    # END added

2. Then at the end of the file add:

# Added by Organicode to dynamically display cmd akin to kde's konsole
if [[ ${EUID} == 0 ]] ; then
  trap '[[ "$BASH_COMMAND" == "$PROMPT_COMMAND" ]] || printf "\e]0;- : %s\a" "$BASH_COMMAND"' DEBUG
else
  trap '[[ "$BASH_COMMAND" == "$PROMPT_COMMAND" ]] || printf "\e]0;$TITLE_USER : %s\a" "$BASH_COMMAND"' DEBUG
fi

If anyone sees a major issue with this, ie. not just "tilde must mean home folder always", please chime in.


No LLM was used in the production of this post

Offline

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

Board footer

Powered by FluxBB
Modified by Visman

[ Generated in 0.025 seconds, 11 queries executed - Memory usage: 576.37 KiB (Peak: 593.34 KiB) ]