gnome-terminator / terminator

multiple GNOME terminals in one window
https://gnome-terminator.org
GNU General Public License v2.0
2.12k stars 257 forks source link

Remove ´title= ´ function from config file to allow dynamic titles #959

Open heit0r opened 6 days ago

heit0r commented 6 days ago

Is your feature request related to a problem? Please describe.

Thetitle= function on .config/terminator/config overrides the terminal title. Every time I make a change in the setup on terminator, this function pops up on my config file and I have to manually delete this line in order to my titles back again.

I have a function on my /etc/bash.bashrc to dynamically change the terminal title in XFCE for aliased commands:

title() {
    local title=$1
    shift
    local cmd=$1
    shift
    echo -ne "\033]0;$title\007"
    $cmd "$@"
    echo -ne "\033]0;${OLD_TITLE:-$USER@$HOSTNAME}\007"
}

And in case of commands who weren't aliased I have another function just to return the previous command:

set_title_preexec() {
    # Captures the command about to enter
    local cmd=$(history 1 | sed 's/^[ ]*[0-9]*[ ]*//;s/[;&|].*//')
    # Updates terminal title
    echo -ne "\033]0;${cmd}\007"
}

# Restore title after process ends
set_title_postexec() {
    # Restore title
    echo -ne "\033]0;Terminal\007"
}

# traps for preexec and postexec
trap 'set_title_preexec' DEBUG
PROMPT_COMMAND=set_title_postexec

The result (ignore the icon, i just changed it) :

2024-10-30_13-10_1 2024-10-30_13-10_2

Unaliased commands: 2024-10-30_13-46

Describe the solution you'd like To this function be switchable or removed if no one cares about it. I believe many users may have similar functions to alter their terminal titles and probably are facing a similar issue. Who knows..

Describe alternatives you've considered To manually delete the line every time? Not a big deal, actually. But altering this may improve every user experience.

Additional context With the title= function on my config file the title is always the same: <user>@<machine>:~

heit0r commented 6 days ago

Also, it works by just leaving title = empty. No need to take the entire line from config file.

mattrose commented 2 days ago

Looking at this now. This has always bugged me too.