Skip to content

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

Open
@heit0r

Description

@heit0r

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

The title= 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>:~

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions