Using Terminal 6.1.2, everything up-to-date.

I currently have the following in my .bashrc, as suggested in this answer:

case "$TERM" in
    PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"'

    # Show the currently running command in the terminal title:
    # http://www.davidpashley.com/articles/xterm-titles-with-bash.html
        case "$BASH_COMMAND" in
                # The command is trying to set the title bar as well;
                # this is most likely the execution of $PROMPT_COMMAND.
                # In any case nested escapes confuse the terminal, so don't
                # output them.
                echo -ne "\033]0;${USER}@${HOSTNAME}: ${BASH_COMMAND}\007"
    trap show_command_in_title_bar DEBUG

It changes the window title to the currently running process, which is great. However, it doesn't change the tab title. So if I have multiple tabs open in the same directory, they all have the same title, and I can't immediately see which program is running in which tab.

Is there a way to make this apply to the tab titles as well?

Please let me know if there's a better forum for this; I'm not sure if it's an elementary Terminal thing, or a bash thing, or what.

  • This is an interesting question. I haven't seen this done on a tab level as of yet. Will look forward to any answers 🤔
    – matigo
    Commented Aug 8, 2023 at 1:52

1 Answer 1


I think you are on the right path. Your script sets the title as good as it can, and it seems your terminal emulator already makes use of the set title, but at the wrong place, you just need to tell it to name your tabs based on it.

For KDE Konsole, in the menu where you can change the title of a tab, the title can be based on a pattern, where the %w pattern means the window title set by the shell.

Now, I'm not an Elementary OS user so I don't know whether this is supported in its native terminal, but I just figured it out for myself for KDE Konsole with your help (that commented link was very useful!), so I figured I could let you know about it, in case Elementary's terminal also supports something similar.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.