How to change the title of the current terminal tab using only the command line












28















None of the currently posted answers works/answers the question.





Using only a command at the command prompt, how do I change the title of the current terminal tab?



Many posts suggest this:



echo -en "33]0;New terminal titlea"


but it does nothing.



None of the current answers works (some don't answer the question), so for clarity:




  • Once the title is changed, I don't want it to change if I change directory etc

  • I don't want the same title on all tabs. I only want to set the title for the tab I run the command in

  • I want multiple tabs to each have different titles


Also, the PROMPT_COMMAND variable is not set in my terminal sessions. If I set it:



PROMPT_COMMAND='echo -en "33]0;New terminal titlea"'


it has no effect.



What is the correct command?





FYI, the output of uname -a is:




Linux d136172 3.13.0-45-generic #74-Ubuntu SMP Tue Jan 13 19:36:28 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux











share|improve this question




















  • 1





    Do you mean tab (mentioned in the question) or window (the title). One is more complicated than the other :) related: askubuntu.com/questions/626505/…

    – Jacob Vlijm
    Jun 16 '15 at 6:36













  • @JacobVlijm I mean tab. I didn't realise there was a difference.

    – Bohemian
    Jun 16 '15 at 8:31






  • 2





    Which terminal program? What does $PS1 contain?

    – muru
    Jun 22 '15 at 0:15






  • 2





    @muru terminal program is /usr/bin/gnome-terminal (from standard install). echo $PS1 -> [e]0;u@h: wa]${debian_chroot:+($debian_chroot)}[33[01;32m]u@h[33[00m]:[33[01;34m]w[33[00m]$

    – Bohemian
    Jun 22 '15 at 0:25






  • 2





    @Bohemian As you can see, your PS1 also sets the title

    – muru
    Jun 22 '15 at 0:25
















28















None of the currently posted answers works/answers the question.





Using only a command at the command prompt, how do I change the title of the current terminal tab?



Many posts suggest this:



echo -en "33]0;New terminal titlea"


but it does nothing.



None of the current answers works (some don't answer the question), so for clarity:




  • Once the title is changed, I don't want it to change if I change directory etc

  • I don't want the same title on all tabs. I only want to set the title for the tab I run the command in

  • I want multiple tabs to each have different titles


Also, the PROMPT_COMMAND variable is not set in my terminal sessions. If I set it:



PROMPT_COMMAND='echo -en "33]0;New terminal titlea"'


it has no effect.



What is the correct command?





FYI, the output of uname -a is:




Linux d136172 3.13.0-45-generic #74-Ubuntu SMP Tue Jan 13 19:36:28 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux











share|improve this question




















  • 1





    Do you mean tab (mentioned in the question) or window (the title). One is more complicated than the other :) related: askubuntu.com/questions/626505/…

    – Jacob Vlijm
    Jun 16 '15 at 6:36













  • @JacobVlijm I mean tab. I didn't realise there was a difference.

    – Bohemian
    Jun 16 '15 at 8:31






  • 2





    Which terminal program? What does $PS1 contain?

    – muru
    Jun 22 '15 at 0:15






  • 2





    @muru terminal program is /usr/bin/gnome-terminal (from standard install). echo $PS1 -> [e]0;u@h: wa]${debian_chroot:+($debian_chroot)}[33[01;32m]u@h[33[00m]:[33[01;34m]w[33[00m]$

    – Bohemian
    Jun 22 '15 at 0:25






  • 2





    @Bohemian As you can see, your PS1 also sets the title

    – muru
    Jun 22 '15 at 0:25














28












28








28


10






None of the currently posted answers works/answers the question.





Using only a command at the command prompt, how do I change the title of the current terminal tab?



Many posts suggest this:



echo -en "33]0;New terminal titlea"


but it does nothing.



None of the current answers works (some don't answer the question), so for clarity:




  • Once the title is changed, I don't want it to change if I change directory etc

  • I don't want the same title on all tabs. I only want to set the title for the tab I run the command in

  • I want multiple tabs to each have different titles


Also, the PROMPT_COMMAND variable is not set in my terminal sessions. If I set it:



PROMPT_COMMAND='echo -en "33]0;New terminal titlea"'


it has no effect.



What is the correct command?





FYI, the output of uname -a is:




Linux d136172 3.13.0-45-generic #74-Ubuntu SMP Tue Jan 13 19:36:28 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux











share|improve this question
















None of the currently posted answers works/answers the question.





Using only a command at the command prompt, how do I change the title of the current terminal tab?



Many posts suggest this:



echo -en "33]0;New terminal titlea"


but it does nothing.



None of the current answers works (some don't answer the question), so for clarity:




  • Once the title is changed, I don't want it to change if I change directory etc

  • I don't want the same title on all tabs. I only want to set the title for the tab I run the command in

  • I want multiple tabs to each have different titles


Also, the PROMPT_COMMAND variable is not set in my terminal sessions. If I set it:



PROMPT_COMMAND='echo -en "33]0;New terminal titlea"'


it has no effect.



What is the correct command?





FYI, the output of uname -a is:




Linux d136172 3.13.0-45-generic #74-Ubuntu SMP Tue Jan 13 19:36:28 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux








command-line






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jun 22 '15 at 0:01







Bohemian

















asked Jun 16 '15 at 2:48









BohemianBohemian

244138




244138








  • 1





    Do you mean tab (mentioned in the question) or window (the title). One is more complicated than the other :) related: askubuntu.com/questions/626505/…

    – Jacob Vlijm
    Jun 16 '15 at 6:36













  • @JacobVlijm I mean tab. I didn't realise there was a difference.

    – Bohemian
    Jun 16 '15 at 8:31






  • 2





    Which terminal program? What does $PS1 contain?

    – muru
    Jun 22 '15 at 0:15






  • 2





    @muru terminal program is /usr/bin/gnome-terminal (from standard install). echo $PS1 -> [e]0;u@h: wa]${debian_chroot:+($debian_chroot)}[33[01;32m]u@h[33[00m]:[33[01;34m]w[33[00m]$

    – Bohemian
    Jun 22 '15 at 0:25






  • 2





    @Bohemian As you can see, your PS1 also sets the title

    – muru
    Jun 22 '15 at 0:25














  • 1





    Do you mean tab (mentioned in the question) or window (the title). One is more complicated than the other :) related: askubuntu.com/questions/626505/…

    – Jacob Vlijm
    Jun 16 '15 at 6:36













  • @JacobVlijm I mean tab. I didn't realise there was a difference.

    – Bohemian
    Jun 16 '15 at 8:31






  • 2





    Which terminal program? What does $PS1 contain?

    – muru
    Jun 22 '15 at 0:15






  • 2





    @muru terminal program is /usr/bin/gnome-terminal (from standard install). echo $PS1 -> [e]0;u@h: wa]${debian_chroot:+($debian_chroot)}[33[01;32m]u@h[33[00m]:[33[01;34m]w[33[00m]$

    – Bohemian
    Jun 22 '15 at 0:25






  • 2





    @Bohemian As you can see, your PS1 also sets the title

    – muru
    Jun 22 '15 at 0:25








1




1





Do you mean tab (mentioned in the question) or window (the title). One is more complicated than the other :) related: askubuntu.com/questions/626505/…

– Jacob Vlijm
Jun 16 '15 at 6:36







Do you mean tab (mentioned in the question) or window (the title). One is more complicated than the other :) related: askubuntu.com/questions/626505/…

– Jacob Vlijm
Jun 16 '15 at 6:36















@JacobVlijm I mean tab. I didn't realise there was a difference.

– Bohemian
Jun 16 '15 at 8:31





@JacobVlijm I mean tab. I didn't realise there was a difference.

– Bohemian
Jun 16 '15 at 8:31




2




2





Which terminal program? What does $PS1 contain?

– muru
Jun 22 '15 at 0:15





Which terminal program? What does $PS1 contain?

– muru
Jun 22 '15 at 0:15




2




2





@muru terminal program is /usr/bin/gnome-terminal (from standard install). echo $PS1 -> [e]0;u@h: wa]${debian_chroot:+($debian_chroot)}[33[01;32m]u@h[33[00m]:[33[01;34m]w[33[00m]$

– Bohemian
Jun 22 '15 at 0:25





@muru terminal program is /usr/bin/gnome-terminal (from standard install). echo $PS1 -> [e]0;u@h: wa]${debian_chroot:+($debian_chroot)}[33[01;32m]u@h[33[00m]:[33[01;34m]w[33[00m]$

– Bohemian
Jun 22 '15 at 0:25




2




2





@Bohemian As you can see, your PS1 also sets the title

– muru
Jun 22 '15 at 0:25





@Bohemian As you can see, your PS1 also sets the title

– muru
Jun 22 '15 at 0:25










10 Answers
10






active

oldest

votes


















15














from @Maythux, this one works for my needs to disregard my auto-prompt current-directory on terminal.



PROMPT_COMMAND='echo -en "33]0;New terminal titlea"'


Instruction



Change the string on "New Terminal Name" with $("pwd"):



PROMPT_COMMAND='echo -en "33]0; $("pwd") a"'


This will automatically change the title even when you add a new tab.





I use the setting below which looks better, you can also play bash programming and set your own.



PROMPT_COMMAND='echo -en "33]0;$(whoami)@$(hostname)|$(pwd|cut -d "/" -f 4-100)a"'


Add this setting to your ~/.bashrc.






share|improve this answer

































    9














    When the PS1 sets the title, any attempt to set the title using a command or PROMPT_COMMAND will fail, since the prompt is printed after all of them. For this reason, I prefer to keep a simple prompt while testing titles (PS1=$; unset PROMPT_COMMAND).






    share|improve this answer
























    • That is sad you are suspended. Evil and disrespectful users are tolerated, that is how moderation goes here.

      – Billal Begueradj
      Dec 24 '18 at 14:11



















    4














    It is very likely that PROMPT_COMMAND is set and it is overwriting your choice of title every time the prompt is displayed. Try unsetting it and then issuing your title command:



    PROMPT_COMMAND=
    echo -en "33]0;New terminal titlea"





    share|improve this answer



















    • 1





      env | grep PROMPT_COMMAND returns nothing.

      – Bohemian
      Jun 16 '15 at 3:37











    • @Bohemian Why would it? It is a variable not an environment variable. If you want to check if it is set, use echo $PROMP_COMMAND

      – Anthon
      Jun 16 '15 at 4:15













    • @Anthon echo $PROMP_COMMAND prints blank. And although your "why would it?" was intended as rhetorical, I'll answer it: env prints all variables, that's why. Prove it yourself with this simple test: export foo=bar; env | grep foo prints foo=bar

      – Bohemian
      Jun 16 '15 at 14:43








    • 1





      @Bohemian PROMPT_COMMAND=something and export PROMPT_COMMAND=something will have the same effect on the current session.

      – John1024
      Jun 17 '15 at 0:12








    • 1





      @John1024 yes, in a fresh tab echo $PROMPT_COMMAND prints nothing. After executing PROMPT_COMMAND='echo -en "33]0;New terminal titlea"', executing echo $PROMPT_COMMAND prints as expected, but the title of the terminal tab is unchanged (and remains so after other commands)

      – Bohemian
      Jun 17 '15 at 7:03



















    4














    From https://askubuntu.com/a/774543/455406, a bash-specific solution is to create a custom function (see e.g. this how-to) like



    # function to set terminal title  
    function set-title() {
    if [[ -z "$ORIG" ]]; then
    ORIG=$PS1
    fi
    TITLE="[e]2;$*a]"
    PS1=${ORIG}${TITLE}
    }


    which allows you to call set-title <name you want to set it to>






    share|improve this answer


























    • how run this function in a custom commands please I fail to do it

      – Webwoman
      Sep 17 '18 at 14:43











    • per the how-to I referenced "create its own executable script in ~/bin/ which won't exist by default (it's just a directory) but should be in your path. Remember for this the file will need to be executable (chmod +x filename) and start with a proper #!/bin/bash stanza." (1) create a file in ~/bin (2) paste/type the code into the file (3) save the file (4) chmod the file to be executable . Then if you saved it as '~/bin/setATitle' you should be able to run $ setATitle a title

      – WillC
      Sep 24 '18 at 6:48













    • Works in Ubuntu 18.04, thank you. (restart Terminal after you add the script to .bashrc)

      – user1692094
      Dec 21 '18 at 14:33



















    3














    You can do it, either in CLI or GUI(I suppose you are using gnome-terminal, you can do for others just replace the name of app):



    In CLI Run the command:



    gconftool-2 --set /apps/gnome-terminal/profiles/Default/title --type=string "New Terminal Name"


    Note: the new name is applied to all instances of terminal tabs, and not for the only current tab.



    enter image description here



    Or from GUI:



    Go to Menu: Terminal --> Set Title --> Enter new title then save.





    Now Why your command not work?



    You should add this line to the .bashrc file and not directly to your terminal.



    gedit .bashrc


    Add this line:



    PROMPT_COMMAND='echo -en "33]0;New terminal titlea"'


    Then save and source the bashrc file.



    source .bashrc





    share|improve this answer





















    • 3





      But I don't want to set the title to the same title for every tab; I want to have every tab have its own different title (depending on what use I've put it to, so I can easily find the tab I want)

      – Bohemian
      Jun 16 '15 at 15:11











    • I think what you need is simply complicated enough to get your answer

      – Maythux
      Jun 17 '15 at 5:56





















    2














    Instructions




    1. Add settitle() to your .bashrc.

    2. source ~/.bashrc

    3. settitle Banana




    settitle()



    function settitle()
    {
    if [ $# -eq 0 ]
    then
    eval set -- "\u@\h: \w"
    fi

    case $TERM in
    xterm*) local title="[33]0;$@07]";;
    *) local title=''
    esac
    local prompt=$(echo "$PS1" | sed -e 's/\[\033]0;.*\007\]//')
    PS1="${title}${prompt}"
    }





    share|improve this answer
























    • Thanks, but does nothing.

      – Bohemian
      Jun 16 '15 at 3:56











    • does NOT work in xfce4-terminal 0.8.3

      – hanshenrik
      Mar 24 '17 at 19:00






    • 2





      what does the eval set -- "\u@\h: \w do ?

      – Ciprian Tomoiagă
      Apr 24 '17 at 11:01



















    1














    Using bash, wmctrl, xprop, ps



    1) For a long-running active program:



    For example, start a program (ranger) running in a terminal, started from the desktop, change the title, once, after some delay ( 5 seconds ) when the program starts :



    startranger.sh:



    #!/bin/bash
    /usr/local/bin/changetitle.sh 5 ranger
    /usr/local/bin/ranger


    changetitle.sh:



    #!/bin/bash
    delay="$1"
    shift
    wintitle="$*"
    winid=`xprop -root | grep _NET_ACTIVE_WINDOW | head -1 | awk '{print $5}' | sed 's/,//' | sed 's/^0x/0x0/'`
    /bin/bash -c "sleep $delay; wmctrl -i -r $winid -N "$wintitle"" &


    2) If you are running a terminal session without running an active program, update the title on a loop that ends when your terminal exits:



    changetitleloop.sh 1 maintenance for server


    running the above will update the title of the current terminal every 1 second even if you cd (can change it multiple times), using:



    changetitleloop.sh



    #!/bin/bash
    interval="$1"
    shift
    wintitle="$*"
    termpid="$(ps -p $$ -o ppid= | sed -e 's/^[ t]*//')"
    winid=`xprop -root | grep _NET_ACTIVE_WINDOW | head -1 | awk '{print $5}' | sed 's/,//' | sed 's/^0x/0x0/'`
    /bin/bash -c "ss=$$; echo $ss > /tmp/term-$termpid.pid; while x=$(wmctrl -i -r $winid -N "$wintitle"); ret=$?; sleep $interval; owner=$(cat /tmp/term-$termpid.pid); [ $ret -eq 0 ] && [ $ss -eq $owner ]; do continue; done;" &





    share|improve this answer

































      1














      Based on @muru answer




      PS1 sets the title, any attempt to set the title using a command or PROMPT_COMMAND will fail, since the prompt is printed after all of them




      This worked in my Elementary S.O :



      PS1='u:W$ '
      PROMPT_COMMAND='echo -en "33]0;New terminal titlea"'


      I execute this in each new tab :



      tab 1



      tab 2



      And as the previous image shows, I have several tabs with unique name.



      16.04.1-Ubuntu






      share|improve this answer


























      • This worked for me, using Xfce terminal.

        – Smile4ever
        Apr 20 '18 at 19:27



















      1














      This thread may be a little old, but here is a solution that works for me:



      https://blog.programster.org/ubuntu-16-04-set-terminal-title




      Simply edit your $HOME/.bashrc file and add the following function:

      set-title(){

      ORIG=$PS1

      TITLE="e]2;$@a"

      PS1=${ORIG}${TITLE}

      }



      Now whenever you want to set the title of your terminal, just enter
      something like:

      set-title "my awesome terminal title"







      share|improve this answer
























      • This solution is the only one that works for me.

        – stensootla
        Sep 14 '18 at 6:28



















      0














      One solution may be to install the latest version of tmux.



      tmux allows setting per-pane titles, enabled by this command:



      tmux set -g pane-border-status top


      They can also be displayed on the bottom.



      Titles are then set via an escape sequence:



      printf '33]2│;%s33\' 'My Pane Title'


      Each pane can have its own title and all titles show all the time.



      The tmux panes will then look like this:



      ──0 "My Pane Title"──────┬──1 "Another Pane"───────
      > │>


      This was tested on linux mint 18.2 (like Ubuntu) with tmux 2.8. Installation was from a tarball.



      If you want to be more productive in your terminal, tmux offers lots of other features too.






      share|improve this answer








      New contributor




      Mike Amy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.




















        Your Answer








        StackExchange.ready(function() {
        var channelOptions = {
        tags: "".split(" "),
        id: "89"
        };
        initTagRenderer("".split(" "), "".split(" "), channelOptions);

        StackExchange.using("externalEditor", function() {
        // Have to fire editor after snippets, if snippets enabled
        if (StackExchange.settings.snippets.snippetsEnabled) {
        StackExchange.using("snippets", function() {
        createEditor();
        });
        }
        else {
        createEditor();
        }
        });

        function createEditor() {
        StackExchange.prepareEditor({
        heartbeatType: 'answer',
        autoActivateHeartbeat: false,
        convertImagesToLinks: true,
        noModals: true,
        showLowRepImageUploadWarning: true,
        reputationToPostImages: 10,
        bindNavPrevention: true,
        postfix: "",
        imageUploader: {
        brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
        contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
        allowUrls: true
        },
        onDemand: true,
        discardSelector: ".discard-answer"
        ,immediatelyShowMarkdownHelp:true
        });


        }
        });














        draft saved

        draft discarded


















        StackExchange.ready(
        function () {
        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f636944%2fhow-to-change-the-title-of-the-current-terminal-tab-using-only-the-command-line%23new-answer', 'question_page');
        }
        );

        Post as a guest















        Required, but never shown

























        10 Answers
        10






        active

        oldest

        votes








        10 Answers
        10






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        15














        from @Maythux, this one works for my needs to disregard my auto-prompt current-directory on terminal.



        PROMPT_COMMAND='echo -en "33]0;New terminal titlea"'


        Instruction



        Change the string on "New Terminal Name" with $("pwd"):



        PROMPT_COMMAND='echo -en "33]0; $("pwd") a"'


        This will automatically change the title even when you add a new tab.





        I use the setting below which looks better, you can also play bash programming and set your own.



        PROMPT_COMMAND='echo -en "33]0;$(whoami)@$(hostname)|$(pwd|cut -d "/" -f 4-100)a"'


        Add this setting to your ~/.bashrc.






        share|improve this answer






























          15














          from @Maythux, this one works for my needs to disregard my auto-prompt current-directory on terminal.



          PROMPT_COMMAND='echo -en "33]0;New terminal titlea"'


          Instruction



          Change the string on "New Terminal Name" with $("pwd"):



          PROMPT_COMMAND='echo -en "33]0; $("pwd") a"'


          This will automatically change the title even when you add a new tab.





          I use the setting below which looks better, you can also play bash programming and set your own.



          PROMPT_COMMAND='echo -en "33]0;$(whoami)@$(hostname)|$(pwd|cut -d "/" -f 4-100)a"'


          Add this setting to your ~/.bashrc.






          share|improve this answer




























            15












            15








            15







            from @Maythux, this one works for my needs to disregard my auto-prompt current-directory on terminal.



            PROMPT_COMMAND='echo -en "33]0;New terminal titlea"'


            Instruction



            Change the string on "New Terminal Name" with $("pwd"):



            PROMPT_COMMAND='echo -en "33]0; $("pwd") a"'


            This will automatically change the title even when you add a new tab.





            I use the setting below which looks better, you can also play bash programming and set your own.



            PROMPT_COMMAND='echo -en "33]0;$(whoami)@$(hostname)|$(pwd|cut -d "/" -f 4-100)a"'


            Add this setting to your ~/.bashrc.






            share|improve this answer















            from @Maythux, this one works for my needs to disregard my auto-prompt current-directory on terminal.



            PROMPT_COMMAND='echo -en "33]0;New terminal titlea"'


            Instruction



            Change the string on "New Terminal Name" with $("pwd"):



            PROMPT_COMMAND='echo -en "33]0; $("pwd") a"'


            This will automatically change the title even when you add a new tab.





            I use the setting below which looks better, you can also play bash programming and set your own.



            PROMPT_COMMAND='echo -en "33]0;$(whoami)@$(hostname)|$(pwd|cut -d "/" -f 4-100)a"'


            Add this setting to your ~/.bashrc.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Dec 4 '17 at 13:55









            dessert

            22.8k56398




            22.8k56398










            answered Aug 22 '16 at 6:49









            Kelly DCKelly DC

            15113




            15113

























                9














                When the PS1 sets the title, any attempt to set the title using a command or PROMPT_COMMAND will fail, since the prompt is printed after all of them. For this reason, I prefer to keep a simple prompt while testing titles (PS1=$; unset PROMPT_COMMAND).






                share|improve this answer
























                • That is sad you are suspended. Evil and disrespectful users are tolerated, that is how moderation goes here.

                  – Billal Begueradj
                  Dec 24 '18 at 14:11
















                9














                When the PS1 sets the title, any attempt to set the title using a command or PROMPT_COMMAND will fail, since the prompt is printed after all of them. For this reason, I prefer to keep a simple prompt while testing titles (PS1=$; unset PROMPT_COMMAND).






                share|improve this answer
























                • That is sad you are suspended. Evil and disrespectful users are tolerated, that is how moderation goes here.

                  – Billal Begueradj
                  Dec 24 '18 at 14:11














                9












                9








                9







                When the PS1 sets the title, any attempt to set the title using a command or PROMPT_COMMAND will fail, since the prompt is printed after all of them. For this reason, I prefer to keep a simple prompt while testing titles (PS1=$; unset PROMPT_COMMAND).






                share|improve this answer













                When the PS1 sets the title, any attempt to set the title using a command or PROMPT_COMMAND will fail, since the prompt is printed after all of them. For this reason, I prefer to keep a simple prompt while testing titles (PS1=$; unset PROMPT_COMMAND).







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Jun 22 '15 at 0:31









                murumuru

                1




                1













                • That is sad you are suspended. Evil and disrespectful users are tolerated, that is how moderation goes here.

                  – Billal Begueradj
                  Dec 24 '18 at 14:11



















                • That is sad you are suspended. Evil and disrespectful users are tolerated, that is how moderation goes here.

                  – Billal Begueradj
                  Dec 24 '18 at 14:11

















                That is sad you are suspended. Evil and disrespectful users are tolerated, that is how moderation goes here.

                – Billal Begueradj
                Dec 24 '18 at 14:11





                That is sad you are suspended. Evil and disrespectful users are tolerated, that is how moderation goes here.

                – Billal Begueradj
                Dec 24 '18 at 14:11











                4














                It is very likely that PROMPT_COMMAND is set and it is overwriting your choice of title every time the prompt is displayed. Try unsetting it and then issuing your title command:



                PROMPT_COMMAND=
                echo -en "33]0;New terminal titlea"





                share|improve this answer



















                • 1





                  env | grep PROMPT_COMMAND returns nothing.

                  – Bohemian
                  Jun 16 '15 at 3:37











                • @Bohemian Why would it? It is a variable not an environment variable. If you want to check if it is set, use echo $PROMP_COMMAND

                  – Anthon
                  Jun 16 '15 at 4:15













                • @Anthon echo $PROMP_COMMAND prints blank. And although your "why would it?" was intended as rhetorical, I'll answer it: env prints all variables, that's why. Prove it yourself with this simple test: export foo=bar; env | grep foo prints foo=bar

                  – Bohemian
                  Jun 16 '15 at 14:43








                • 1





                  @Bohemian PROMPT_COMMAND=something and export PROMPT_COMMAND=something will have the same effect on the current session.

                  – John1024
                  Jun 17 '15 at 0:12








                • 1





                  @John1024 yes, in a fresh tab echo $PROMPT_COMMAND prints nothing. After executing PROMPT_COMMAND='echo -en "33]0;New terminal titlea"', executing echo $PROMPT_COMMAND prints as expected, but the title of the terminal tab is unchanged (and remains so after other commands)

                  – Bohemian
                  Jun 17 '15 at 7:03
















                4














                It is very likely that PROMPT_COMMAND is set and it is overwriting your choice of title every time the prompt is displayed. Try unsetting it and then issuing your title command:



                PROMPT_COMMAND=
                echo -en "33]0;New terminal titlea"





                share|improve this answer



















                • 1





                  env | grep PROMPT_COMMAND returns nothing.

                  – Bohemian
                  Jun 16 '15 at 3:37











                • @Bohemian Why would it? It is a variable not an environment variable. If you want to check if it is set, use echo $PROMP_COMMAND

                  – Anthon
                  Jun 16 '15 at 4:15













                • @Anthon echo $PROMP_COMMAND prints blank. And although your "why would it?" was intended as rhetorical, I'll answer it: env prints all variables, that's why. Prove it yourself with this simple test: export foo=bar; env | grep foo prints foo=bar

                  – Bohemian
                  Jun 16 '15 at 14:43








                • 1





                  @Bohemian PROMPT_COMMAND=something and export PROMPT_COMMAND=something will have the same effect on the current session.

                  – John1024
                  Jun 17 '15 at 0:12








                • 1





                  @John1024 yes, in a fresh tab echo $PROMPT_COMMAND prints nothing. After executing PROMPT_COMMAND='echo -en "33]0;New terminal titlea"', executing echo $PROMPT_COMMAND prints as expected, but the title of the terminal tab is unchanged (and remains so after other commands)

                  – Bohemian
                  Jun 17 '15 at 7:03














                4












                4








                4







                It is very likely that PROMPT_COMMAND is set and it is overwriting your choice of title every time the prompt is displayed. Try unsetting it and then issuing your title command:



                PROMPT_COMMAND=
                echo -en "33]0;New terminal titlea"





                share|improve this answer













                It is very likely that PROMPT_COMMAND is set and it is overwriting your choice of title every time the prompt is displayed. Try unsetting it and then issuing your title command:



                PROMPT_COMMAND=
                echo -en "33]0;New terminal titlea"






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Jun 16 '15 at 3:22









                John1024John1024

                9,9342434




                9,9342434








                • 1





                  env | grep PROMPT_COMMAND returns nothing.

                  – Bohemian
                  Jun 16 '15 at 3:37











                • @Bohemian Why would it? It is a variable not an environment variable. If you want to check if it is set, use echo $PROMP_COMMAND

                  – Anthon
                  Jun 16 '15 at 4:15













                • @Anthon echo $PROMP_COMMAND prints blank. And although your "why would it?" was intended as rhetorical, I'll answer it: env prints all variables, that's why. Prove it yourself with this simple test: export foo=bar; env | grep foo prints foo=bar

                  – Bohemian
                  Jun 16 '15 at 14:43








                • 1





                  @Bohemian PROMPT_COMMAND=something and export PROMPT_COMMAND=something will have the same effect on the current session.

                  – John1024
                  Jun 17 '15 at 0:12








                • 1





                  @John1024 yes, in a fresh tab echo $PROMPT_COMMAND prints nothing. After executing PROMPT_COMMAND='echo -en "33]0;New terminal titlea"', executing echo $PROMPT_COMMAND prints as expected, but the title of the terminal tab is unchanged (and remains so after other commands)

                  – Bohemian
                  Jun 17 '15 at 7:03














                • 1





                  env | grep PROMPT_COMMAND returns nothing.

                  – Bohemian
                  Jun 16 '15 at 3:37











                • @Bohemian Why would it? It is a variable not an environment variable. If you want to check if it is set, use echo $PROMP_COMMAND

                  – Anthon
                  Jun 16 '15 at 4:15













                • @Anthon echo $PROMP_COMMAND prints blank. And although your "why would it?" was intended as rhetorical, I'll answer it: env prints all variables, that's why. Prove it yourself with this simple test: export foo=bar; env | grep foo prints foo=bar

                  – Bohemian
                  Jun 16 '15 at 14:43








                • 1





                  @Bohemian PROMPT_COMMAND=something and export PROMPT_COMMAND=something will have the same effect on the current session.

                  – John1024
                  Jun 17 '15 at 0:12








                • 1





                  @John1024 yes, in a fresh tab echo $PROMPT_COMMAND prints nothing. After executing PROMPT_COMMAND='echo -en "33]0;New terminal titlea"', executing echo $PROMPT_COMMAND prints as expected, but the title of the terminal tab is unchanged (and remains so after other commands)

                  – Bohemian
                  Jun 17 '15 at 7:03








                1




                1





                env | grep PROMPT_COMMAND returns nothing.

                – Bohemian
                Jun 16 '15 at 3:37





                env | grep PROMPT_COMMAND returns nothing.

                – Bohemian
                Jun 16 '15 at 3:37













                @Bohemian Why would it? It is a variable not an environment variable. If you want to check if it is set, use echo $PROMP_COMMAND

                – Anthon
                Jun 16 '15 at 4:15







                @Bohemian Why would it? It is a variable not an environment variable. If you want to check if it is set, use echo $PROMP_COMMAND

                – Anthon
                Jun 16 '15 at 4:15















                @Anthon echo $PROMP_COMMAND prints blank. And although your "why would it?" was intended as rhetorical, I'll answer it: env prints all variables, that's why. Prove it yourself with this simple test: export foo=bar; env | grep foo prints foo=bar

                – Bohemian
                Jun 16 '15 at 14:43







                @Anthon echo $PROMP_COMMAND prints blank. And although your "why would it?" was intended as rhetorical, I'll answer it: env prints all variables, that's why. Prove it yourself with this simple test: export foo=bar; env | grep foo prints foo=bar

                – Bohemian
                Jun 16 '15 at 14:43






                1




                1





                @Bohemian PROMPT_COMMAND=something and export PROMPT_COMMAND=something will have the same effect on the current session.

                – John1024
                Jun 17 '15 at 0:12







                @Bohemian PROMPT_COMMAND=something and export PROMPT_COMMAND=something will have the same effect on the current session.

                – John1024
                Jun 17 '15 at 0:12






                1




                1





                @John1024 yes, in a fresh tab echo $PROMPT_COMMAND prints nothing. After executing PROMPT_COMMAND='echo -en "33]0;New terminal titlea"', executing echo $PROMPT_COMMAND prints as expected, but the title of the terminal tab is unchanged (and remains so after other commands)

                – Bohemian
                Jun 17 '15 at 7:03





                @John1024 yes, in a fresh tab echo $PROMPT_COMMAND prints nothing. After executing PROMPT_COMMAND='echo -en "33]0;New terminal titlea"', executing echo $PROMPT_COMMAND prints as expected, but the title of the terminal tab is unchanged (and remains so after other commands)

                – Bohemian
                Jun 17 '15 at 7:03











                4














                From https://askubuntu.com/a/774543/455406, a bash-specific solution is to create a custom function (see e.g. this how-to) like



                # function to set terminal title  
                function set-title() {
                if [[ -z "$ORIG" ]]; then
                ORIG=$PS1
                fi
                TITLE="[e]2;$*a]"
                PS1=${ORIG}${TITLE}
                }


                which allows you to call set-title <name you want to set it to>






                share|improve this answer


























                • how run this function in a custom commands please I fail to do it

                  – Webwoman
                  Sep 17 '18 at 14:43











                • per the how-to I referenced "create its own executable script in ~/bin/ which won't exist by default (it's just a directory) but should be in your path. Remember for this the file will need to be executable (chmod +x filename) and start with a proper #!/bin/bash stanza." (1) create a file in ~/bin (2) paste/type the code into the file (3) save the file (4) chmod the file to be executable . Then if you saved it as '~/bin/setATitle' you should be able to run $ setATitle a title

                  – WillC
                  Sep 24 '18 at 6:48













                • Works in Ubuntu 18.04, thank you. (restart Terminal after you add the script to .bashrc)

                  – user1692094
                  Dec 21 '18 at 14:33
















                4














                From https://askubuntu.com/a/774543/455406, a bash-specific solution is to create a custom function (see e.g. this how-to) like



                # function to set terminal title  
                function set-title() {
                if [[ -z "$ORIG" ]]; then
                ORIG=$PS1
                fi
                TITLE="[e]2;$*a]"
                PS1=${ORIG}${TITLE}
                }


                which allows you to call set-title <name you want to set it to>






                share|improve this answer


























                • how run this function in a custom commands please I fail to do it

                  – Webwoman
                  Sep 17 '18 at 14:43











                • per the how-to I referenced "create its own executable script in ~/bin/ which won't exist by default (it's just a directory) but should be in your path. Remember for this the file will need to be executable (chmod +x filename) and start with a proper #!/bin/bash stanza." (1) create a file in ~/bin (2) paste/type the code into the file (3) save the file (4) chmod the file to be executable . Then if you saved it as '~/bin/setATitle' you should be able to run $ setATitle a title

                  – WillC
                  Sep 24 '18 at 6:48













                • Works in Ubuntu 18.04, thank you. (restart Terminal after you add the script to .bashrc)

                  – user1692094
                  Dec 21 '18 at 14:33














                4












                4








                4







                From https://askubuntu.com/a/774543/455406, a bash-specific solution is to create a custom function (see e.g. this how-to) like



                # function to set terminal title  
                function set-title() {
                if [[ -z "$ORIG" ]]; then
                ORIG=$PS1
                fi
                TITLE="[e]2;$*a]"
                PS1=${ORIG}${TITLE}
                }


                which allows you to call set-title <name you want to set it to>






                share|improve this answer















                From https://askubuntu.com/a/774543/455406, a bash-specific solution is to create a custom function (see e.g. this how-to) like



                # function to set terminal title  
                function set-title() {
                if [[ -z "$ORIG" ]]; then
                ORIG=$PS1
                fi
                TITLE="[e]2;$*a]"
                PS1=${ORIG}${TITLE}
                }


                which allows you to call set-title <name you want to set it to>







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Apr 13 '17 at 12:23









                Community

                1




                1










                answered Feb 24 '17 at 0:31









                WillCWillC

                68879




                68879













                • how run this function in a custom commands please I fail to do it

                  – Webwoman
                  Sep 17 '18 at 14:43











                • per the how-to I referenced "create its own executable script in ~/bin/ which won't exist by default (it's just a directory) but should be in your path. Remember for this the file will need to be executable (chmod +x filename) and start with a proper #!/bin/bash stanza." (1) create a file in ~/bin (2) paste/type the code into the file (3) save the file (4) chmod the file to be executable . Then if you saved it as '~/bin/setATitle' you should be able to run $ setATitle a title

                  – WillC
                  Sep 24 '18 at 6:48













                • Works in Ubuntu 18.04, thank you. (restart Terminal after you add the script to .bashrc)

                  – user1692094
                  Dec 21 '18 at 14:33



















                • how run this function in a custom commands please I fail to do it

                  – Webwoman
                  Sep 17 '18 at 14:43











                • per the how-to I referenced "create its own executable script in ~/bin/ which won't exist by default (it's just a directory) but should be in your path. Remember for this the file will need to be executable (chmod +x filename) and start with a proper #!/bin/bash stanza." (1) create a file in ~/bin (2) paste/type the code into the file (3) save the file (4) chmod the file to be executable . Then if you saved it as '~/bin/setATitle' you should be able to run $ setATitle a title

                  – WillC
                  Sep 24 '18 at 6:48













                • Works in Ubuntu 18.04, thank you. (restart Terminal after you add the script to .bashrc)

                  – user1692094
                  Dec 21 '18 at 14:33

















                how run this function in a custom commands please I fail to do it

                – Webwoman
                Sep 17 '18 at 14:43





                how run this function in a custom commands please I fail to do it

                – Webwoman
                Sep 17 '18 at 14:43













                per the how-to I referenced "create its own executable script in ~/bin/ which won't exist by default (it's just a directory) but should be in your path. Remember for this the file will need to be executable (chmod +x filename) and start with a proper #!/bin/bash stanza." (1) create a file in ~/bin (2) paste/type the code into the file (3) save the file (4) chmod the file to be executable . Then if you saved it as '~/bin/setATitle' you should be able to run $ setATitle a title

                – WillC
                Sep 24 '18 at 6:48







                per the how-to I referenced "create its own executable script in ~/bin/ which won't exist by default (it's just a directory) but should be in your path. Remember for this the file will need to be executable (chmod +x filename) and start with a proper #!/bin/bash stanza." (1) create a file in ~/bin (2) paste/type the code into the file (3) save the file (4) chmod the file to be executable . Then if you saved it as '~/bin/setATitle' you should be able to run $ setATitle a title

                – WillC
                Sep 24 '18 at 6:48















                Works in Ubuntu 18.04, thank you. (restart Terminal after you add the script to .bashrc)

                – user1692094
                Dec 21 '18 at 14:33





                Works in Ubuntu 18.04, thank you. (restart Terminal after you add the script to .bashrc)

                – user1692094
                Dec 21 '18 at 14:33











                3














                You can do it, either in CLI or GUI(I suppose you are using gnome-terminal, you can do for others just replace the name of app):



                In CLI Run the command:



                gconftool-2 --set /apps/gnome-terminal/profiles/Default/title --type=string "New Terminal Name"


                Note: the new name is applied to all instances of terminal tabs, and not for the only current tab.



                enter image description here



                Or from GUI:



                Go to Menu: Terminal --> Set Title --> Enter new title then save.





                Now Why your command not work?



                You should add this line to the .bashrc file and not directly to your terminal.



                gedit .bashrc


                Add this line:



                PROMPT_COMMAND='echo -en "33]0;New terminal titlea"'


                Then save and source the bashrc file.



                source .bashrc





                share|improve this answer





















                • 3





                  But I don't want to set the title to the same title for every tab; I want to have every tab have its own different title (depending on what use I've put it to, so I can easily find the tab I want)

                  – Bohemian
                  Jun 16 '15 at 15:11











                • I think what you need is simply complicated enough to get your answer

                  – Maythux
                  Jun 17 '15 at 5:56


















                3














                You can do it, either in CLI or GUI(I suppose you are using gnome-terminal, you can do for others just replace the name of app):



                In CLI Run the command:



                gconftool-2 --set /apps/gnome-terminal/profiles/Default/title --type=string "New Terminal Name"


                Note: the new name is applied to all instances of terminal tabs, and not for the only current tab.



                enter image description here



                Or from GUI:



                Go to Menu: Terminal --> Set Title --> Enter new title then save.





                Now Why your command not work?



                You should add this line to the .bashrc file and not directly to your terminal.



                gedit .bashrc


                Add this line:



                PROMPT_COMMAND='echo -en "33]0;New terminal titlea"'


                Then save and source the bashrc file.



                source .bashrc





                share|improve this answer





















                • 3





                  But I don't want to set the title to the same title for every tab; I want to have every tab have its own different title (depending on what use I've put it to, so I can easily find the tab I want)

                  – Bohemian
                  Jun 16 '15 at 15:11











                • I think what you need is simply complicated enough to get your answer

                  – Maythux
                  Jun 17 '15 at 5:56
















                3












                3








                3







                You can do it, either in CLI or GUI(I suppose you are using gnome-terminal, you can do for others just replace the name of app):



                In CLI Run the command:



                gconftool-2 --set /apps/gnome-terminal/profiles/Default/title --type=string "New Terminal Name"


                Note: the new name is applied to all instances of terminal tabs, and not for the only current tab.



                enter image description here



                Or from GUI:



                Go to Menu: Terminal --> Set Title --> Enter new title then save.





                Now Why your command not work?



                You should add this line to the .bashrc file and not directly to your terminal.



                gedit .bashrc


                Add this line:



                PROMPT_COMMAND='echo -en "33]0;New terminal titlea"'


                Then save and source the bashrc file.



                source .bashrc





                share|improve this answer















                You can do it, either in CLI or GUI(I suppose you are using gnome-terminal, you can do for others just replace the name of app):



                In CLI Run the command:



                gconftool-2 --set /apps/gnome-terminal/profiles/Default/title --type=string "New Terminal Name"


                Note: the new name is applied to all instances of terminal tabs, and not for the only current tab.



                enter image description here



                Or from GUI:



                Go to Menu: Terminal --> Set Title --> Enter new title then save.





                Now Why your command not work?



                You should add this line to the .bashrc file and not directly to your terminal.



                gedit .bashrc


                Add this line:



                PROMPT_COMMAND='echo -en "33]0;New terminal titlea"'


                Then save and source the bashrc file.



                source .bashrc






                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Jun 16 '15 at 6:38

























                answered Jun 16 '15 at 6:28









                MaythuxMaythux

                51k32171217




                51k32171217








                • 3





                  But I don't want to set the title to the same title for every tab; I want to have every tab have its own different title (depending on what use I've put it to, so I can easily find the tab I want)

                  – Bohemian
                  Jun 16 '15 at 15:11











                • I think what you need is simply complicated enough to get your answer

                  – Maythux
                  Jun 17 '15 at 5:56
















                • 3





                  But I don't want to set the title to the same title for every tab; I want to have every tab have its own different title (depending on what use I've put it to, so I can easily find the tab I want)

                  – Bohemian
                  Jun 16 '15 at 15:11











                • I think what you need is simply complicated enough to get your answer

                  – Maythux
                  Jun 17 '15 at 5:56










                3




                3





                But I don't want to set the title to the same title for every tab; I want to have every tab have its own different title (depending on what use I've put it to, so I can easily find the tab I want)

                – Bohemian
                Jun 16 '15 at 15:11





                But I don't want to set the title to the same title for every tab; I want to have every tab have its own different title (depending on what use I've put it to, so I can easily find the tab I want)

                – Bohemian
                Jun 16 '15 at 15:11













                I think what you need is simply complicated enough to get your answer

                – Maythux
                Jun 17 '15 at 5:56







                I think what you need is simply complicated enough to get your answer

                – Maythux
                Jun 17 '15 at 5:56













                2














                Instructions




                1. Add settitle() to your .bashrc.

                2. source ~/.bashrc

                3. settitle Banana




                settitle()



                function settitle()
                {
                if [ $# -eq 0 ]
                then
                eval set -- "\u@\h: \w"
                fi

                case $TERM in
                xterm*) local title="[33]0;$@07]";;
                *) local title=''
                esac
                local prompt=$(echo "$PS1" | sed -e 's/\[\033]0;.*\007\]//')
                PS1="${title}${prompt}"
                }





                share|improve this answer
























                • Thanks, but does nothing.

                  – Bohemian
                  Jun 16 '15 at 3:56











                • does NOT work in xfce4-terminal 0.8.3

                  – hanshenrik
                  Mar 24 '17 at 19:00






                • 2





                  what does the eval set -- "\u@\h: \w do ?

                  – Ciprian Tomoiagă
                  Apr 24 '17 at 11:01
















                2














                Instructions




                1. Add settitle() to your .bashrc.

                2. source ~/.bashrc

                3. settitle Banana




                settitle()



                function settitle()
                {
                if [ $# -eq 0 ]
                then
                eval set -- "\u@\h: \w"
                fi

                case $TERM in
                xterm*) local title="[33]0;$@07]";;
                *) local title=''
                esac
                local prompt=$(echo "$PS1" | sed -e 's/\[\033]0;.*\007\]//')
                PS1="${title}${prompt}"
                }





                share|improve this answer
























                • Thanks, but does nothing.

                  – Bohemian
                  Jun 16 '15 at 3:56











                • does NOT work in xfce4-terminal 0.8.3

                  – hanshenrik
                  Mar 24 '17 at 19:00






                • 2





                  what does the eval set -- "\u@\h: \w do ?

                  – Ciprian Tomoiagă
                  Apr 24 '17 at 11:01














                2












                2








                2







                Instructions




                1. Add settitle() to your .bashrc.

                2. source ~/.bashrc

                3. settitle Banana




                settitle()



                function settitle()
                {
                if [ $# -eq 0 ]
                then
                eval set -- "\u@\h: \w"
                fi

                case $TERM in
                xterm*) local title="[33]0;$@07]";;
                *) local title=''
                esac
                local prompt=$(echo "$PS1" | sed -e 's/\[\033]0;.*\007\]//')
                PS1="${title}${prompt}"
                }





                share|improve this answer













                Instructions




                1. Add settitle() to your .bashrc.

                2. source ~/.bashrc

                3. settitle Banana




                settitle()



                function settitle()
                {
                if [ $# -eq 0 ]
                then
                eval set -- "\u@\h: \w"
                fi

                case $TERM in
                xterm*) local title="[33]0;$@07]";;
                *) local title=''
                esac
                local prompt=$(echo "$PS1" | sed -e 's/\[\033]0;.*\007\]//')
                PS1="${title}${prompt}"
                }






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Jun 16 '15 at 3:42









                earthmeLonearthmeLon

                6,3441851




                6,3441851













                • Thanks, but does nothing.

                  – Bohemian
                  Jun 16 '15 at 3:56











                • does NOT work in xfce4-terminal 0.8.3

                  – hanshenrik
                  Mar 24 '17 at 19:00






                • 2





                  what does the eval set -- "\u@\h: \w do ?

                  – Ciprian Tomoiagă
                  Apr 24 '17 at 11:01



















                • Thanks, but does nothing.

                  – Bohemian
                  Jun 16 '15 at 3:56











                • does NOT work in xfce4-terminal 0.8.3

                  – hanshenrik
                  Mar 24 '17 at 19:00






                • 2





                  what does the eval set -- "\u@\h: \w do ?

                  – Ciprian Tomoiagă
                  Apr 24 '17 at 11:01

















                Thanks, but does nothing.

                – Bohemian
                Jun 16 '15 at 3:56





                Thanks, but does nothing.

                – Bohemian
                Jun 16 '15 at 3:56













                does NOT work in xfce4-terminal 0.8.3

                – hanshenrik
                Mar 24 '17 at 19:00





                does NOT work in xfce4-terminal 0.8.3

                – hanshenrik
                Mar 24 '17 at 19:00




                2




                2





                what does the eval set -- "\u@\h: \w do ?

                – Ciprian Tomoiagă
                Apr 24 '17 at 11:01





                what does the eval set -- "\u@\h: \w do ?

                – Ciprian Tomoiagă
                Apr 24 '17 at 11:01











                1














                Using bash, wmctrl, xprop, ps



                1) For a long-running active program:



                For example, start a program (ranger) running in a terminal, started from the desktop, change the title, once, after some delay ( 5 seconds ) when the program starts :



                startranger.sh:



                #!/bin/bash
                /usr/local/bin/changetitle.sh 5 ranger
                /usr/local/bin/ranger


                changetitle.sh:



                #!/bin/bash
                delay="$1"
                shift
                wintitle="$*"
                winid=`xprop -root | grep _NET_ACTIVE_WINDOW | head -1 | awk '{print $5}' | sed 's/,//' | sed 's/^0x/0x0/'`
                /bin/bash -c "sleep $delay; wmctrl -i -r $winid -N "$wintitle"" &


                2) If you are running a terminal session without running an active program, update the title on a loop that ends when your terminal exits:



                changetitleloop.sh 1 maintenance for server


                running the above will update the title of the current terminal every 1 second even if you cd (can change it multiple times), using:



                changetitleloop.sh



                #!/bin/bash
                interval="$1"
                shift
                wintitle="$*"
                termpid="$(ps -p $$ -o ppid= | sed -e 's/^[ t]*//')"
                winid=`xprop -root | grep _NET_ACTIVE_WINDOW | head -1 | awk '{print $5}' | sed 's/,//' | sed 's/^0x/0x0/'`
                /bin/bash -c "ss=$$; echo $ss > /tmp/term-$termpid.pid; while x=$(wmctrl -i -r $winid -N "$wintitle"); ret=$?; sleep $interval; owner=$(cat /tmp/term-$termpid.pid); [ $ret -eq 0 ] && [ $ss -eq $owner ]; do continue; done;" &





                share|improve this answer






























                  1














                  Using bash, wmctrl, xprop, ps



                  1) For a long-running active program:



                  For example, start a program (ranger) running in a terminal, started from the desktop, change the title, once, after some delay ( 5 seconds ) when the program starts :



                  startranger.sh:



                  #!/bin/bash
                  /usr/local/bin/changetitle.sh 5 ranger
                  /usr/local/bin/ranger


                  changetitle.sh:



                  #!/bin/bash
                  delay="$1"
                  shift
                  wintitle="$*"
                  winid=`xprop -root | grep _NET_ACTIVE_WINDOW | head -1 | awk '{print $5}' | sed 's/,//' | sed 's/^0x/0x0/'`
                  /bin/bash -c "sleep $delay; wmctrl -i -r $winid -N "$wintitle"" &


                  2) If you are running a terminal session without running an active program, update the title on a loop that ends when your terminal exits:



                  changetitleloop.sh 1 maintenance for server


                  running the above will update the title of the current terminal every 1 second even if you cd (can change it multiple times), using:



                  changetitleloop.sh



                  #!/bin/bash
                  interval="$1"
                  shift
                  wintitle="$*"
                  termpid="$(ps -p $$ -o ppid= | sed -e 's/^[ t]*//')"
                  winid=`xprop -root | grep _NET_ACTIVE_WINDOW | head -1 | awk '{print $5}' | sed 's/,//' | sed 's/^0x/0x0/'`
                  /bin/bash -c "ss=$$; echo $ss > /tmp/term-$termpid.pid; while x=$(wmctrl -i -r $winid -N "$wintitle"); ret=$?; sleep $interval; owner=$(cat /tmp/term-$termpid.pid); [ $ret -eq 0 ] && [ $ss -eq $owner ]; do continue; done;" &





                  share|improve this answer




























                    1












                    1








                    1







                    Using bash, wmctrl, xprop, ps



                    1) For a long-running active program:



                    For example, start a program (ranger) running in a terminal, started from the desktop, change the title, once, after some delay ( 5 seconds ) when the program starts :



                    startranger.sh:



                    #!/bin/bash
                    /usr/local/bin/changetitle.sh 5 ranger
                    /usr/local/bin/ranger


                    changetitle.sh:



                    #!/bin/bash
                    delay="$1"
                    shift
                    wintitle="$*"
                    winid=`xprop -root | grep _NET_ACTIVE_WINDOW | head -1 | awk '{print $5}' | sed 's/,//' | sed 's/^0x/0x0/'`
                    /bin/bash -c "sleep $delay; wmctrl -i -r $winid -N "$wintitle"" &


                    2) If you are running a terminal session without running an active program, update the title on a loop that ends when your terminal exits:



                    changetitleloop.sh 1 maintenance for server


                    running the above will update the title of the current terminal every 1 second even if you cd (can change it multiple times), using:



                    changetitleloop.sh



                    #!/bin/bash
                    interval="$1"
                    shift
                    wintitle="$*"
                    termpid="$(ps -p $$ -o ppid= | sed -e 's/^[ t]*//')"
                    winid=`xprop -root | grep _NET_ACTIVE_WINDOW | head -1 | awk '{print $5}' | sed 's/,//' | sed 's/^0x/0x0/'`
                    /bin/bash -c "ss=$$; echo $ss > /tmp/term-$termpid.pid; while x=$(wmctrl -i -r $winid -N "$wintitle"); ret=$?; sleep $interval; owner=$(cat /tmp/term-$termpid.pid); [ $ret -eq 0 ] && [ $ss -eq $owner ]; do continue; done;" &





                    share|improve this answer















                    Using bash, wmctrl, xprop, ps



                    1) For a long-running active program:



                    For example, start a program (ranger) running in a terminal, started from the desktop, change the title, once, after some delay ( 5 seconds ) when the program starts :



                    startranger.sh:



                    #!/bin/bash
                    /usr/local/bin/changetitle.sh 5 ranger
                    /usr/local/bin/ranger


                    changetitle.sh:



                    #!/bin/bash
                    delay="$1"
                    shift
                    wintitle="$*"
                    winid=`xprop -root | grep _NET_ACTIVE_WINDOW | head -1 | awk '{print $5}' | sed 's/,//' | sed 's/^0x/0x0/'`
                    /bin/bash -c "sleep $delay; wmctrl -i -r $winid -N "$wintitle"" &


                    2) If you are running a terminal session without running an active program, update the title on a loop that ends when your terminal exits:



                    changetitleloop.sh 1 maintenance for server


                    running the above will update the title of the current terminal every 1 second even if you cd (can change it multiple times), using:



                    changetitleloop.sh



                    #!/bin/bash
                    interval="$1"
                    shift
                    wintitle="$*"
                    termpid="$(ps -p $$ -o ppid= | sed -e 's/^[ t]*//')"
                    winid=`xprop -root | grep _NET_ACTIVE_WINDOW | head -1 | awk '{print $5}' | sed 's/,//' | sed 's/^0x/0x0/'`
                    /bin/bash -c "ss=$$; echo $ss > /tmp/term-$termpid.pid; while x=$(wmctrl -i -r $winid -N "$wintitle"); ret=$?; sleep $interval; owner=$(cat /tmp/term-$termpid.pid); [ $ret -eq 0 ] && [ $ss -eq $owner ]; do continue; done;" &






                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited Apr 16 '18 at 15:53

























                    answered Apr 16 '18 at 15:17









                    Der BosstDer Bosst

                    112




                    112























                        1














                        Based on @muru answer




                        PS1 sets the title, any attempt to set the title using a command or PROMPT_COMMAND will fail, since the prompt is printed after all of them




                        This worked in my Elementary S.O :



                        PS1='u:W$ '
                        PROMPT_COMMAND='echo -en "33]0;New terminal titlea"'


                        I execute this in each new tab :



                        tab 1



                        tab 2



                        And as the previous image shows, I have several tabs with unique name.



                        16.04.1-Ubuntu






                        share|improve this answer


























                        • This worked for me, using Xfce terminal.

                          – Smile4ever
                          Apr 20 '18 at 19:27
















                        1














                        Based on @muru answer




                        PS1 sets the title, any attempt to set the title using a command or PROMPT_COMMAND will fail, since the prompt is printed after all of them




                        This worked in my Elementary S.O :



                        PS1='u:W$ '
                        PROMPT_COMMAND='echo -en "33]0;New terminal titlea"'


                        I execute this in each new tab :



                        tab 1



                        tab 2



                        And as the previous image shows, I have several tabs with unique name.



                        16.04.1-Ubuntu






                        share|improve this answer


























                        • This worked for me, using Xfce terminal.

                          – Smile4ever
                          Apr 20 '18 at 19:27














                        1












                        1








                        1







                        Based on @muru answer




                        PS1 sets the title, any attempt to set the title using a command or PROMPT_COMMAND will fail, since the prompt is printed after all of them




                        This worked in my Elementary S.O :



                        PS1='u:W$ '
                        PROMPT_COMMAND='echo -en "33]0;New terminal titlea"'


                        I execute this in each new tab :



                        tab 1



                        tab 2



                        And as the previous image shows, I have several tabs with unique name.



                        16.04.1-Ubuntu






                        share|improve this answer















                        Based on @muru answer




                        PS1 sets the title, any attempt to set the title using a command or PROMPT_COMMAND will fail, since the prompt is printed after all of them




                        This worked in my Elementary S.O :



                        PS1='u:W$ '
                        PROMPT_COMMAND='echo -en "33]0;New terminal titlea"'


                        I execute this in each new tab :



                        tab 1



                        tab 2



                        And as the previous image shows, I have several tabs with unique name.



                        16.04.1-Ubuntu







                        share|improve this answer














                        share|improve this answer



                        share|improve this answer








                        edited Apr 20 '18 at 21:06

























                        answered Jan 15 '18 at 14:32









                        JRichardszJRichardsz

                        1135




                        1135













                        • This worked for me, using Xfce terminal.

                          – Smile4ever
                          Apr 20 '18 at 19:27



















                        • This worked for me, using Xfce terminal.

                          – Smile4ever
                          Apr 20 '18 at 19:27

















                        This worked for me, using Xfce terminal.

                        – Smile4ever
                        Apr 20 '18 at 19:27





                        This worked for me, using Xfce terminal.

                        – Smile4ever
                        Apr 20 '18 at 19:27











                        1














                        This thread may be a little old, but here is a solution that works for me:



                        https://blog.programster.org/ubuntu-16-04-set-terminal-title




                        Simply edit your $HOME/.bashrc file and add the following function:

                        set-title(){

                        ORIG=$PS1

                        TITLE="e]2;$@a"

                        PS1=${ORIG}${TITLE}

                        }



                        Now whenever you want to set the title of your terminal, just enter
                        something like:

                        set-title "my awesome terminal title"







                        share|improve this answer
























                        • This solution is the only one that works for me.

                          – stensootla
                          Sep 14 '18 at 6:28
















                        1














                        This thread may be a little old, but here is a solution that works for me:



                        https://blog.programster.org/ubuntu-16-04-set-terminal-title




                        Simply edit your $HOME/.bashrc file and add the following function:

                        set-title(){

                        ORIG=$PS1

                        TITLE="e]2;$@a"

                        PS1=${ORIG}${TITLE}

                        }



                        Now whenever you want to set the title of your terminal, just enter
                        something like:

                        set-title "my awesome terminal title"







                        share|improve this answer
























                        • This solution is the only one that works for me.

                          – stensootla
                          Sep 14 '18 at 6:28














                        1












                        1








                        1







                        This thread may be a little old, but here is a solution that works for me:



                        https://blog.programster.org/ubuntu-16-04-set-terminal-title




                        Simply edit your $HOME/.bashrc file and add the following function:

                        set-title(){

                        ORIG=$PS1

                        TITLE="e]2;$@a"

                        PS1=${ORIG}${TITLE}

                        }



                        Now whenever you want to set the title of your terminal, just enter
                        something like:

                        set-title "my awesome terminal title"







                        share|improve this answer













                        This thread may be a little old, but here is a solution that works for me:



                        https://blog.programster.org/ubuntu-16-04-set-terminal-title




                        Simply edit your $HOME/.bashrc file and add the following function:

                        set-title(){

                        ORIG=$PS1

                        TITLE="e]2;$@a"

                        PS1=${ORIG}${TITLE}

                        }



                        Now whenever you want to set the title of your terminal, just enter
                        something like:

                        set-title "my awesome terminal title"








                        share|improve this answer












                        share|improve this answer



                        share|improve this answer










                        answered May 17 '18 at 8:49









                        SjoerdSjoerd

                        111




                        111













                        • This solution is the only one that works for me.

                          – stensootla
                          Sep 14 '18 at 6:28



















                        • This solution is the only one that works for me.

                          – stensootla
                          Sep 14 '18 at 6:28

















                        This solution is the only one that works for me.

                        – stensootla
                        Sep 14 '18 at 6:28





                        This solution is the only one that works for me.

                        – stensootla
                        Sep 14 '18 at 6:28











                        0














                        One solution may be to install the latest version of tmux.



                        tmux allows setting per-pane titles, enabled by this command:



                        tmux set -g pane-border-status top


                        They can also be displayed on the bottom.



                        Titles are then set via an escape sequence:



                        printf '33]2│;%s33\' 'My Pane Title'


                        Each pane can have its own title and all titles show all the time.



                        The tmux panes will then look like this:



                        ──0 "My Pane Title"──────┬──1 "Another Pane"───────
                        > │>


                        This was tested on linux mint 18.2 (like Ubuntu) with tmux 2.8. Installation was from a tarball.



                        If you want to be more productive in your terminal, tmux offers lots of other features too.






                        share|improve this answer








                        New contributor




                        Mike Amy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                        Check out our Code of Conduct.

























                          0














                          One solution may be to install the latest version of tmux.



                          tmux allows setting per-pane titles, enabled by this command:



                          tmux set -g pane-border-status top


                          They can also be displayed on the bottom.



                          Titles are then set via an escape sequence:



                          printf '33]2│;%s33\' 'My Pane Title'


                          Each pane can have its own title and all titles show all the time.



                          The tmux panes will then look like this:



                          ──0 "My Pane Title"──────┬──1 "Another Pane"───────
                          > │>


                          This was tested on linux mint 18.2 (like Ubuntu) with tmux 2.8. Installation was from a tarball.



                          If you want to be more productive in your terminal, tmux offers lots of other features too.






                          share|improve this answer








                          New contributor




                          Mike Amy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.























                            0












                            0








                            0







                            One solution may be to install the latest version of tmux.



                            tmux allows setting per-pane titles, enabled by this command:



                            tmux set -g pane-border-status top


                            They can also be displayed on the bottom.



                            Titles are then set via an escape sequence:



                            printf '33]2│;%s33\' 'My Pane Title'


                            Each pane can have its own title and all titles show all the time.



                            The tmux panes will then look like this:



                            ──0 "My Pane Title"──────┬──1 "Another Pane"───────
                            > │>


                            This was tested on linux mint 18.2 (like Ubuntu) with tmux 2.8. Installation was from a tarball.



                            If you want to be more productive in your terminal, tmux offers lots of other features too.






                            share|improve this answer








                            New contributor




                            Mike Amy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                            Check out our Code of Conduct.










                            One solution may be to install the latest version of tmux.



                            tmux allows setting per-pane titles, enabled by this command:



                            tmux set -g pane-border-status top


                            They can also be displayed on the bottom.



                            Titles are then set via an escape sequence:



                            printf '33]2│;%s33\' 'My Pane Title'


                            Each pane can have its own title and all titles show all the time.



                            The tmux panes will then look like this:



                            ──0 "My Pane Title"──────┬──1 "Another Pane"───────
                            > │>


                            This was tested on linux mint 18.2 (like Ubuntu) with tmux 2.8. Installation was from a tarball.



                            If you want to be more productive in your terminal, tmux offers lots of other features too.







                            share|improve this answer








                            New contributor




                            Mike Amy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                            Check out our Code of Conduct.









                            share|improve this answer



                            share|improve this answer






                            New contributor




                            Mike Amy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                            Check out our Code of Conduct.









                            answered yesterday









                            Mike AmyMike Amy

                            1




                            1




                            New contributor




                            Mike Amy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                            Check out our Code of Conduct.





                            New contributor





                            Mike Amy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                            Check out our Code of Conduct.






                            Mike Amy is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                            Check out our Code of Conduct.






























                                draft saved

                                draft discarded




















































                                Thanks for contributing an answer to Ask Ubuntu!


                                • Please be sure to answer the question. Provide details and share your research!

                                But avoid



                                • Asking for help, clarification, or responding to other answers.

                                • Making statements based on opinion; back them up with references or personal experience.


                                To learn more, see our tips on writing great answers.




                                draft saved


                                draft discarded














                                StackExchange.ready(
                                function () {
                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f636944%2fhow-to-change-the-title-of-the-current-terminal-tab-using-only-the-command-line%23new-answer', 'question_page');
                                }
                                );

                                Post as a guest















                                Required, but never shown





















































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown

































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown







                                Popular posts from this blog

                                How did Captain America manage to do this?

                                迪纳利

                                南乌拉尔铁路局