With Bash + iTerm2, how to name tabs?












162















In iTerm2 (Build 1.0.0.20120203), I typically open several tabs, each of which has split panes , and is about one particular theme of work, for example revision control, coding, managing files, mysql terminal work. I typically need to switch between 5 or more tabs in my work flow. It is sometimes hard to remember or tell which is which by looking at the content of the screen. I'd like to name the tabs somehow, so I can quickly tell which is which by quickly glancing. Is this possible?










share|improve this question

























  • possible duplicate of Change iTerm2 window and tab titles in zsh

    – Daniel Beck
    May 2 '12 at 19:11











  • Not entirely duplicate. So how to add the currently running app as a part of tab title? I.e. which tab is running emacs, mysql, etc.?

    – qazwsx
    May 2 '12 at 19:16








  • 1





    I.e. all my tabs have same host and user. So using those won't differentiate my tabs.

    – qazwsx
    May 2 '12 at 19:27











  • You mean you want Show current job name from iTerm's preferences? Note that the linked topic isn't about username or host.

    – Daniel Beck
    May 2 '12 at 19:31











  • Right, I want to show some indication of what program is running or was run in each tabs. Also, the solution given in the other post doesn't work for Bash + iTerm2.

    – qazwsx
    May 2 '12 at 20:08


















162















In iTerm2 (Build 1.0.0.20120203), I typically open several tabs, each of which has split panes , and is about one particular theme of work, for example revision control, coding, managing files, mysql terminal work. I typically need to switch between 5 or more tabs in my work flow. It is sometimes hard to remember or tell which is which by looking at the content of the screen. I'd like to name the tabs somehow, so I can quickly tell which is which by quickly glancing. Is this possible?










share|improve this question

























  • possible duplicate of Change iTerm2 window and tab titles in zsh

    – Daniel Beck
    May 2 '12 at 19:11











  • Not entirely duplicate. So how to add the currently running app as a part of tab title? I.e. which tab is running emacs, mysql, etc.?

    – qazwsx
    May 2 '12 at 19:16








  • 1





    I.e. all my tabs have same host and user. So using those won't differentiate my tabs.

    – qazwsx
    May 2 '12 at 19:27











  • You mean you want Show current job name from iTerm's preferences? Note that the linked topic isn't about username or host.

    – Daniel Beck
    May 2 '12 at 19:31











  • Right, I want to show some indication of what program is running or was run in each tabs. Also, the solution given in the other post doesn't work for Bash + iTerm2.

    – qazwsx
    May 2 '12 at 20:08
















162












162








162


48






In iTerm2 (Build 1.0.0.20120203), I typically open several tabs, each of which has split panes , and is about one particular theme of work, for example revision control, coding, managing files, mysql terminal work. I typically need to switch between 5 or more tabs in my work flow. It is sometimes hard to remember or tell which is which by looking at the content of the screen. I'd like to name the tabs somehow, so I can quickly tell which is which by quickly glancing. Is this possible?










share|improve this question
















In iTerm2 (Build 1.0.0.20120203), I typically open several tabs, each of which has split panes , and is about one particular theme of work, for example revision control, coding, managing files, mysql terminal work. I typically need to switch between 5 or more tabs in my work flow. It is sometimes hard to remember or tell which is which by looking at the content of the screen. I'd like to name the tabs somehow, so I can quickly tell which is which by quickly glancing. Is this possible?







terminal iterm iterm2






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited May 2 '12 at 21:16









nc4pk

7,262115167




7,262115167










asked May 2 '12 at 19:08









qazwsxqazwsx

3,045154771




3,045154771













  • possible duplicate of Change iTerm2 window and tab titles in zsh

    – Daniel Beck
    May 2 '12 at 19:11











  • Not entirely duplicate. So how to add the currently running app as a part of tab title? I.e. which tab is running emacs, mysql, etc.?

    – qazwsx
    May 2 '12 at 19:16








  • 1





    I.e. all my tabs have same host and user. So using those won't differentiate my tabs.

    – qazwsx
    May 2 '12 at 19:27











  • You mean you want Show current job name from iTerm's preferences? Note that the linked topic isn't about username or host.

    – Daniel Beck
    May 2 '12 at 19:31











  • Right, I want to show some indication of what program is running or was run in each tabs. Also, the solution given in the other post doesn't work for Bash + iTerm2.

    – qazwsx
    May 2 '12 at 20:08





















  • possible duplicate of Change iTerm2 window and tab titles in zsh

    – Daniel Beck
    May 2 '12 at 19:11











  • Not entirely duplicate. So how to add the currently running app as a part of tab title? I.e. which tab is running emacs, mysql, etc.?

    – qazwsx
    May 2 '12 at 19:16








  • 1





    I.e. all my tabs have same host and user. So using those won't differentiate my tabs.

    – qazwsx
    May 2 '12 at 19:27











  • You mean you want Show current job name from iTerm's preferences? Note that the linked topic isn't about username or host.

    – Daniel Beck
    May 2 '12 at 19:31











  • Right, I want to show some indication of what program is running or was run in each tabs. Also, the solution given in the other post doesn't work for Bash + iTerm2.

    – qazwsx
    May 2 '12 at 20:08



















possible duplicate of Change iTerm2 window and tab titles in zsh

– Daniel Beck
May 2 '12 at 19:11





possible duplicate of Change iTerm2 window and tab titles in zsh

– Daniel Beck
May 2 '12 at 19:11













Not entirely duplicate. So how to add the currently running app as a part of tab title? I.e. which tab is running emacs, mysql, etc.?

– qazwsx
May 2 '12 at 19:16







Not entirely duplicate. So how to add the currently running app as a part of tab title? I.e. which tab is running emacs, mysql, etc.?

– qazwsx
May 2 '12 at 19:16






1




1





I.e. all my tabs have same host and user. So using those won't differentiate my tabs.

– qazwsx
May 2 '12 at 19:27





I.e. all my tabs have same host and user. So using those won't differentiate my tabs.

– qazwsx
May 2 '12 at 19:27













You mean you want Show current job name from iTerm's preferences? Note that the linked topic isn't about username or host.

– Daniel Beck
May 2 '12 at 19:31





You mean you want Show current job name from iTerm's preferences? Note that the linked topic isn't about username or host.

– Daniel Beck
May 2 '12 at 19:31













Right, I want to show some indication of what program is running or was run in each tabs. Also, the solution given in the other post doesn't work for Bash + iTerm2.

– qazwsx
May 2 '12 at 20:08







Right, I want to show some indication of what program is running or was run in each tabs. Also, the solution given in the other post doesn't work for Bash + iTerm2.

– qazwsx
May 2 '12 at 20:08












13 Answers
13






active

oldest

votes


















195














Since you're using iterm2 on a mac, another option is you can just hit CmdI, type something, and hit ESC.



The terminal solution is a bit quicker than this, but just wanted to let you know.






share|improve this answer





















  • 11





    This works for a second until I issue a return on the tab that I have renamed.

    – Stewie
    Jan 29 '14 at 15:39






  • 12





    @Stewie In Preferences -> Profiles -> Terminal, uncheck "Allow terminal to report window title".

    – Max Cantor
    Apr 4 '14 at 13:19






  • 3





    It is unchecked. It still renames the title.

    – Stewie
    Apr 6 '14 at 1:05






  • 6





    @SteveBennett it's not the "theme" (actually the term is "profile") itself; the CMD+I command is "Edit Current Session..." (under the View menu), so it's just changing that tab's instance of the profile. Hitting Escape just closes the window, which is needed since that window doesn't have a "save" button on it.

    – MidnightLightning
    Aug 4 '15 at 13:39






  • 4





    What if you have multiple panes open? Do you have to rename each one to fully name the tab itself?

    – theicfire
    Aug 10 '15 at 21:01



















112














I've found the following function, placed in my ~/.bashrc to be helpful:



function title {
echo -ne "33]0;"$*"07"
}


Then I can call it from my bash prompt as follows:



> title I want a pony!


And my tab gets titled accordingly.






share|improve this answer



















  • 1





    I tried this, but it still doesn't work. I put this definition into bash_aliases, and have it loaded in .profile (if [ -f ${HOME}/.bash_aliases ]; then . ${HOME}/.bash_aliases fi) But then title dog didn't turn tab title into "dog"

    – qazwsx
    Jun 6 '13 at 21:06






  • 2





    +1 - I added mine to /etc/profile just cause that's where my aliases are... don't forget to source the file after you're done. Note: this also works in terminal.

    – blak3r
    Dec 10 '13 at 19:52






  • 3





    Very helpful. I wanted a pony; and I got one!

    – SoEzPz
    Oct 26 '15 at 16:55






  • 1





    I put mine in .bash_profile, restarted and it worked like a charm.

    – C Johnson
    Apr 14 '16 at 20:33






  • 1





    Those thinking it doesn't work it's because your command prompt instantly changes it back. Try title dog && sleep 5 and you'll see that it works. Note the answer from @schpet to address this

    – Mikhail
    Oct 26 '18 at 21:55



















41














run this command to set the title of your tab or window:



export PROMPT_COMMAND='echo -ne "33]0;YOUR NAME HERE07"'


i've added the following to my ~/.bash_profile to always list the current directory relative to my home dir:



export PROMPT_COMMAND='echo -ne "33]0;${PWD/#$HOME/~}07"'


useful when you have 100 minimized terminals in your dock



hat tip to mac world






share|improve this answer


























  • Works! Just keep in mind that either .bashrc or .bash_profiles can be loaded and not both together. I already had a .bash_profiles file so I had to paste it into this file. Thanks.

    – therealmarv
    Jul 31 '13 at 11:13






  • 1





    oh thanks! i've updated the answer to match this. i have "source ~/.bashrc" in my .bash_profile and forget that this is not common

    – schpet
    Aug 1 '13 at 11:59



















15














Add this function to your ~/.bash_profile file and it should work.



function title ()
{
TITLE=$*;
export PROMPT_COMMAND='echo -ne "33]0;$TITLE07"'
}





share|improve this answer

































    13














    I used solutions similar to the above for quite a while, but I use enough tabs that I also want them color-coded for easy visual reference. So I whipped up tabset, a utility to set the tab title, badge, and color based on the kind of work I am doing in each tab.



    example



    It requires node, but that is now a commonly installed platform. To install:



    npm install -g iterm2-tab-set





    share|improve this answer


























    • This is awesome! I especially love the auto setting of the tab color. Thank you!

      – Ashutosh Jindal
      Jun 11 '18 at 14:22



















    7














    I like this one:



    #setup terminal tab title
    function title {
    if [ "$1" ]
    then
    unset PROMPT_COMMAND
    echo -ne "33]0;${*}07"
    else
    export PROMPT_COMMAND='echo -ne "33]0;${PWD/#$HOME/~}07"'
    fi
    }
    title


    It will let you toggle the name of a tab between a custom name and a default of your CWD.



    title -> your tab title will be ~/YOUR_CWD/



    title hey there -> your tab title will be hey there






    share|improve this answer
























    • Note that as-is, this will clobber iTerm shell integration.

      – Michael
      Mar 18 '16 at 15:30



















    4














    I really like taylorstine's answer, but it breaks iTerm2's shell integration which relies on the PROMPT_COMMAND variable. You can modify Taylor's code to correct this by adding the __bp_precmd_invoke_cmd back into the PROMPT_COMMAND any time you tinker with it:



    # iTerm2 shell integration
    test -e "${HOME}/.iterm2_shell_integration.bash" && source "${HOME}/.iterm2_shell_integration.bash"

    # iTerm2 tab titles
    function title {
    if [ "$1" ]
    then
    export PROMPT_COMMAND='__bp_precmd_invoke_cmd'
    echo -ne "33]0;${*}07"
    else
    export PROMPT_COMMAND='echo -ne "33]0;${PWD/#$HOME/~}07";__bp_precmd_invoke_cmd'
    fi
    }
    title





    share|improve this answer

































      3














      I like Michael's answer.



      But what if .iterm2_shell_integration.bash does not exist?



      Here's my take:



      # iTerm2 shell integration
      test -e "${HOME}/.iterm2_shell_integration.bash" && source "${HOME}/.iterm2_shell_integration.bash"

      # iTerm2 tab titles
      function title {
      if [ "$1" ] ; then
      test -e "${HOME}/.iterm2_shell_integration.bash"
      && export PROMPT_COMMAND='iterm2_preexec_invoke_cmd'
      || unset PROMPT_COMMAND
      echo -ne "33]0;${*}07"
      else
      test -e "${HOME}/.iterm2_shell_integration.bash"
      && export PROMPT_COMMAND='echo -ne "33]0;${PWD/#$HOME/~}07";iterm2_preexec_invoke_cmd'
      || export PROMPT_COMMAND='echo -ne "33]0;${PWD/#$HOME/~}07"'
      fi
      }
      title





      share|improve this answer


























      • Note that in v3.1, iterm2_preexec_invoke_cmd has become __bp_precmd_invoke_cmd

        – Michael
        Sep 20 '17 at 21:50



















      2














      If you're working with Profiles (which is very convenient):
      Preferences -> Appearance -> Window & Tab Titles: tick 'Show profile name':



      image



      That's how it looks after:



      thumbnail linked to main image






      share|improve this answer

































        2














        Preferences -> Profiles -> Terminal
        uncheck Terminal may set Tab/Window title


        Max Cantor's comment worked for me.






        share|improve this answer



















        • 1





          This is what I was looking for. Thanks!

          – William Schroeder McKinley
          Nov 28 '18 at 17:06



















        0














        I think Automatic Profile Switching and Badges are exactly designed for what you need:




        Automatic Profile Switching iTerm2 can use information it knows about your current path, host name, and user name to change profiles. For example, your window's background color or the terminal's character encoding could change when connecting to different hosts.



        Badges
        You can put a badge in the top right of your terminal showing information about the current session. It can show your username, hostname, or even custom data like the current git branch.




        so the result may like this:



        enter image description here






        share|improve this answer


























        • Please quote the essential parts of the answer from the reference link(s), as the answer can become invalid if the linked page(s) change.

          – DavidPostill
          May 1 '17 at 9:28



















        0














        I would like to extend B Seven's answer a little for absolute clarity.



        Since most of us would like to know how can one set a title of a tab even when they are not in local shell, instead of in remote shell (e.g over ssh).



        Step 1. Preferences -> Profiles -> Terminal
        uncheck Terminal may set Tab/Window title



        Step 2. For each tabs, double click on the tab -> Session Title



        Now, whatever you'd set in the session title, it would stay as is.






        share|improve this answer































          -1














          Yuk, all those aliases and functions. Easier solution (if you are root), paste this into a terminal:



          TARGET=/usr/bin/title
          sudo tee "$TARGET" <<'EOF'
          #!/usr/bin/env bash
          echo -ne "33]0;$*07"
          EOF
          sudo chmod 755 "$TARGET"


          Or just make a file call title somewhere in your path, or global path, and paste the two lines between EOF.






          share|improve this answer



















          • 11





            "Yuk with all those aliases." Enters answer no one can possible remember or type by hand.

            – Dan
            Jan 14 '16 at 18:09






          • 1





            @Dan not saying this is great, just that there's no need to remember that since it's just creating a script called title in /usr/bin.

            – Emile Bergeron
            Jan 9 '17 at 21:43











          • @EmileBergeron thx, although it seems you (we) are in a minority. The answer was only 1 line, the rest is for lazy people.

            – Orwellophile
            Jan 10 '17 at 7:09











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "3"
          };
          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%2fsuperuser.com%2fquestions%2f419775%2fwith-bash-iterm2-how-to-name-tabs%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          13 Answers
          13






          active

          oldest

          votes








          13 Answers
          13






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          195














          Since you're using iterm2 on a mac, another option is you can just hit CmdI, type something, and hit ESC.



          The terminal solution is a bit quicker than this, but just wanted to let you know.






          share|improve this answer





















          • 11





            This works for a second until I issue a return on the tab that I have renamed.

            – Stewie
            Jan 29 '14 at 15:39






          • 12





            @Stewie In Preferences -> Profiles -> Terminal, uncheck "Allow terminal to report window title".

            – Max Cantor
            Apr 4 '14 at 13:19






          • 3





            It is unchecked. It still renames the title.

            – Stewie
            Apr 6 '14 at 1:05






          • 6





            @SteveBennett it's not the "theme" (actually the term is "profile") itself; the CMD+I command is "Edit Current Session..." (under the View menu), so it's just changing that tab's instance of the profile. Hitting Escape just closes the window, which is needed since that window doesn't have a "save" button on it.

            – MidnightLightning
            Aug 4 '15 at 13:39






          • 4





            What if you have multiple panes open? Do you have to rename each one to fully name the tab itself?

            – theicfire
            Aug 10 '15 at 21:01
















          195














          Since you're using iterm2 on a mac, another option is you can just hit CmdI, type something, and hit ESC.



          The terminal solution is a bit quicker than this, but just wanted to let you know.






          share|improve this answer





















          • 11





            This works for a second until I issue a return on the tab that I have renamed.

            – Stewie
            Jan 29 '14 at 15:39






          • 12





            @Stewie In Preferences -> Profiles -> Terminal, uncheck "Allow terminal to report window title".

            – Max Cantor
            Apr 4 '14 at 13:19






          • 3





            It is unchecked. It still renames the title.

            – Stewie
            Apr 6 '14 at 1:05






          • 6





            @SteveBennett it's not the "theme" (actually the term is "profile") itself; the CMD+I command is "Edit Current Session..." (under the View menu), so it's just changing that tab's instance of the profile. Hitting Escape just closes the window, which is needed since that window doesn't have a "save" button on it.

            – MidnightLightning
            Aug 4 '15 at 13:39






          • 4





            What if you have multiple panes open? Do you have to rename each one to fully name the tab itself?

            – theicfire
            Aug 10 '15 at 21:01














          195












          195








          195







          Since you're using iterm2 on a mac, another option is you can just hit CmdI, type something, and hit ESC.



          The terminal solution is a bit quicker than this, but just wanted to let you know.






          share|improve this answer















          Since you're using iterm2 on a mac, another option is you can just hit CmdI, type something, and hit ESC.



          The terminal solution is a bit quicker than this, but just wanted to let you know.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Oct 3 '18 at 18:17









          SomeGuyOnAComputer

          280139




          280139










          answered Aug 8 '13 at 15:29









          mawaldnemawaldne

          2,071195




          2,071195








          • 11





            This works for a second until I issue a return on the tab that I have renamed.

            – Stewie
            Jan 29 '14 at 15:39






          • 12





            @Stewie In Preferences -> Profiles -> Terminal, uncheck "Allow terminal to report window title".

            – Max Cantor
            Apr 4 '14 at 13:19






          • 3





            It is unchecked. It still renames the title.

            – Stewie
            Apr 6 '14 at 1:05






          • 6





            @SteveBennett it's not the "theme" (actually the term is "profile") itself; the CMD+I command is "Edit Current Session..." (under the View menu), so it's just changing that tab's instance of the profile. Hitting Escape just closes the window, which is needed since that window doesn't have a "save" button on it.

            – MidnightLightning
            Aug 4 '15 at 13:39






          • 4





            What if you have multiple panes open? Do you have to rename each one to fully name the tab itself?

            – theicfire
            Aug 10 '15 at 21:01














          • 11





            This works for a second until I issue a return on the tab that I have renamed.

            – Stewie
            Jan 29 '14 at 15:39






          • 12





            @Stewie In Preferences -> Profiles -> Terminal, uncheck "Allow terminal to report window title".

            – Max Cantor
            Apr 4 '14 at 13:19






          • 3





            It is unchecked. It still renames the title.

            – Stewie
            Apr 6 '14 at 1:05






          • 6





            @SteveBennett it's not the "theme" (actually the term is "profile") itself; the CMD+I command is "Edit Current Session..." (under the View menu), so it's just changing that tab's instance of the profile. Hitting Escape just closes the window, which is needed since that window doesn't have a "save" button on it.

            – MidnightLightning
            Aug 4 '15 at 13:39






          • 4





            What if you have multiple panes open? Do you have to rename each one to fully name the tab itself?

            – theicfire
            Aug 10 '15 at 21:01








          11




          11





          This works for a second until I issue a return on the tab that I have renamed.

          – Stewie
          Jan 29 '14 at 15:39





          This works for a second until I issue a return on the tab that I have renamed.

          – Stewie
          Jan 29 '14 at 15:39




          12




          12





          @Stewie In Preferences -> Profiles -> Terminal, uncheck "Allow terminal to report window title".

          – Max Cantor
          Apr 4 '14 at 13:19





          @Stewie In Preferences -> Profiles -> Terminal, uncheck "Allow terminal to report window title".

          – Max Cantor
          Apr 4 '14 at 13:19




          3




          3





          It is unchecked. It still renames the title.

          – Stewie
          Apr 6 '14 at 1:05





          It is unchecked. It still renames the title.

          – Stewie
          Apr 6 '14 at 1:05




          6




          6





          @SteveBennett it's not the "theme" (actually the term is "profile") itself; the CMD+I command is "Edit Current Session..." (under the View menu), so it's just changing that tab's instance of the profile. Hitting Escape just closes the window, which is needed since that window doesn't have a "save" button on it.

          – MidnightLightning
          Aug 4 '15 at 13:39





          @SteveBennett it's not the "theme" (actually the term is "profile") itself; the CMD+I command is "Edit Current Session..." (under the View menu), so it's just changing that tab's instance of the profile. Hitting Escape just closes the window, which is needed since that window doesn't have a "save" button on it.

          – MidnightLightning
          Aug 4 '15 at 13:39




          4




          4





          What if you have multiple panes open? Do you have to rename each one to fully name the tab itself?

          – theicfire
          Aug 10 '15 at 21:01





          What if you have multiple panes open? Do you have to rename each one to fully name the tab itself?

          – theicfire
          Aug 10 '15 at 21:01













          112














          I've found the following function, placed in my ~/.bashrc to be helpful:



          function title {
          echo -ne "33]0;"$*"07"
          }


          Then I can call it from my bash prompt as follows:



          > title I want a pony!


          And my tab gets titled accordingly.






          share|improve this answer



















          • 1





            I tried this, but it still doesn't work. I put this definition into bash_aliases, and have it loaded in .profile (if [ -f ${HOME}/.bash_aliases ]; then . ${HOME}/.bash_aliases fi) But then title dog didn't turn tab title into "dog"

            – qazwsx
            Jun 6 '13 at 21:06






          • 2





            +1 - I added mine to /etc/profile just cause that's where my aliases are... don't forget to source the file after you're done. Note: this also works in terminal.

            – blak3r
            Dec 10 '13 at 19:52






          • 3





            Very helpful. I wanted a pony; and I got one!

            – SoEzPz
            Oct 26 '15 at 16:55






          • 1





            I put mine in .bash_profile, restarted and it worked like a charm.

            – C Johnson
            Apr 14 '16 at 20:33






          • 1





            Those thinking it doesn't work it's because your command prompt instantly changes it back. Try title dog && sleep 5 and you'll see that it works. Note the answer from @schpet to address this

            – Mikhail
            Oct 26 '18 at 21:55
















          112














          I've found the following function, placed in my ~/.bashrc to be helpful:



          function title {
          echo -ne "33]0;"$*"07"
          }


          Then I can call it from my bash prompt as follows:



          > title I want a pony!


          And my tab gets titled accordingly.






          share|improve this answer



















          • 1





            I tried this, but it still doesn't work. I put this definition into bash_aliases, and have it loaded in .profile (if [ -f ${HOME}/.bash_aliases ]; then . ${HOME}/.bash_aliases fi) But then title dog didn't turn tab title into "dog"

            – qazwsx
            Jun 6 '13 at 21:06






          • 2





            +1 - I added mine to /etc/profile just cause that's where my aliases are... don't forget to source the file after you're done. Note: this also works in terminal.

            – blak3r
            Dec 10 '13 at 19:52






          • 3





            Very helpful. I wanted a pony; and I got one!

            – SoEzPz
            Oct 26 '15 at 16:55






          • 1





            I put mine in .bash_profile, restarted and it worked like a charm.

            – C Johnson
            Apr 14 '16 at 20:33






          • 1





            Those thinking it doesn't work it's because your command prompt instantly changes it back. Try title dog && sleep 5 and you'll see that it works. Note the answer from @schpet to address this

            – Mikhail
            Oct 26 '18 at 21:55














          112












          112








          112







          I've found the following function, placed in my ~/.bashrc to be helpful:



          function title {
          echo -ne "33]0;"$*"07"
          }


          Then I can call it from my bash prompt as follows:



          > title I want a pony!


          And my tab gets titled accordingly.






          share|improve this answer













          I've found the following function, placed in my ~/.bashrc to be helpful:



          function title {
          echo -ne "33]0;"$*"07"
          }


          Then I can call it from my bash prompt as follows:



          > title I want a pony!


          And my tab gets titled accordingly.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered May 23 '13 at 17:57









          Jason SundramJason Sundram

          2,15652130




          2,15652130








          • 1





            I tried this, but it still doesn't work. I put this definition into bash_aliases, and have it loaded in .profile (if [ -f ${HOME}/.bash_aliases ]; then . ${HOME}/.bash_aliases fi) But then title dog didn't turn tab title into "dog"

            – qazwsx
            Jun 6 '13 at 21:06






          • 2





            +1 - I added mine to /etc/profile just cause that's where my aliases are... don't forget to source the file after you're done. Note: this also works in terminal.

            – blak3r
            Dec 10 '13 at 19:52






          • 3





            Very helpful. I wanted a pony; and I got one!

            – SoEzPz
            Oct 26 '15 at 16:55






          • 1





            I put mine in .bash_profile, restarted and it worked like a charm.

            – C Johnson
            Apr 14 '16 at 20:33






          • 1





            Those thinking it doesn't work it's because your command prompt instantly changes it back. Try title dog && sleep 5 and you'll see that it works. Note the answer from @schpet to address this

            – Mikhail
            Oct 26 '18 at 21:55














          • 1





            I tried this, but it still doesn't work. I put this definition into bash_aliases, and have it loaded in .profile (if [ -f ${HOME}/.bash_aliases ]; then . ${HOME}/.bash_aliases fi) But then title dog didn't turn tab title into "dog"

            – qazwsx
            Jun 6 '13 at 21:06






          • 2





            +1 - I added mine to /etc/profile just cause that's where my aliases are... don't forget to source the file after you're done. Note: this also works in terminal.

            – blak3r
            Dec 10 '13 at 19:52






          • 3





            Very helpful. I wanted a pony; and I got one!

            – SoEzPz
            Oct 26 '15 at 16:55






          • 1





            I put mine in .bash_profile, restarted and it worked like a charm.

            – C Johnson
            Apr 14 '16 at 20:33






          • 1





            Those thinking it doesn't work it's because your command prompt instantly changes it back. Try title dog && sleep 5 and you'll see that it works. Note the answer from @schpet to address this

            – Mikhail
            Oct 26 '18 at 21:55








          1




          1





          I tried this, but it still doesn't work. I put this definition into bash_aliases, and have it loaded in .profile (if [ -f ${HOME}/.bash_aliases ]; then . ${HOME}/.bash_aliases fi) But then title dog didn't turn tab title into "dog"

          – qazwsx
          Jun 6 '13 at 21:06





          I tried this, but it still doesn't work. I put this definition into bash_aliases, and have it loaded in .profile (if [ -f ${HOME}/.bash_aliases ]; then . ${HOME}/.bash_aliases fi) But then title dog didn't turn tab title into "dog"

          – qazwsx
          Jun 6 '13 at 21:06




          2




          2





          +1 - I added mine to /etc/profile just cause that's where my aliases are... don't forget to source the file after you're done. Note: this also works in terminal.

          – blak3r
          Dec 10 '13 at 19:52





          +1 - I added mine to /etc/profile just cause that's where my aliases are... don't forget to source the file after you're done. Note: this also works in terminal.

          – blak3r
          Dec 10 '13 at 19:52




          3




          3





          Very helpful. I wanted a pony; and I got one!

          – SoEzPz
          Oct 26 '15 at 16:55





          Very helpful. I wanted a pony; and I got one!

          – SoEzPz
          Oct 26 '15 at 16:55




          1




          1





          I put mine in .bash_profile, restarted and it worked like a charm.

          – C Johnson
          Apr 14 '16 at 20:33





          I put mine in .bash_profile, restarted and it worked like a charm.

          – C Johnson
          Apr 14 '16 at 20:33




          1




          1





          Those thinking it doesn't work it's because your command prompt instantly changes it back. Try title dog && sleep 5 and you'll see that it works. Note the answer from @schpet to address this

          – Mikhail
          Oct 26 '18 at 21:55





          Those thinking it doesn't work it's because your command prompt instantly changes it back. Try title dog && sleep 5 and you'll see that it works. Note the answer from @schpet to address this

          – Mikhail
          Oct 26 '18 at 21:55











          41














          run this command to set the title of your tab or window:



          export PROMPT_COMMAND='echo -ne "33]0;YOUR NAME HERE07"'


          i've added the following to my ~/.bash_profile to always list the current directory relative to my home dir:



          export PROMPT_COMMAND='echo -ne "33]0;${PWD/#$HOME/~}07"'


          useful when you have 100 minimized terminals in your dock



          hat tip to mac world






          share|improve this answer


























          • Works! Just keep in mind that either .bashrc or .bash_profiles can be loaded and not both together. I already had a .bash_profiles file so I had to paste it into this file. Thanks.

            – therealmarv
            Jul 31 '13 at 11:13






          • 1





            oh thanks! i've updated the answer to match this. i have "source ~/.bashrc" in my .bash_profile and forget that this is not common

            – schpet
            Aug 1 '13 at 11:59
















          41














          run this command to set the title of your tab or window:



          export PROMPT_COMMAND='echo -ne "33]0;YOUR NAME HERE07"'


          i've added the following to my ~/.bash_profile to always list the current directory relative to my home dir:



          export PROMPT_COMMAND='echo -ne "33]0;${PWD/#$HOME/~}07"'


          useful when you have 100 minimized terminals in your dock



          hat tip to mac world






          share|improve this answer


























          • Works! Just keep in mind that either .bashrc or .bash_profiles can be loaded and not both together. I already had a .bash_profiles file so I had to paste it into this file. Thanks.

            – therealmarv
            Jul 31 '13 at 11:13






          • 1





            oh thanks! i've updated the answer to match this. i have "source ~/.bashrc" in my .bash_profile and forget that this is not common

            – schpet
            Aug 1 '13 at 11:59














          41












          41








          41







          run this command to set the title of your tab or window:



          export PROMPT_COMMAND='echo -ne "33]0;YOUR NAME HERE07"'


          i've added the following to my ~/.bash_profile to always list the current directory relative to my home dir:



          export PROMPT_COMMAND='echo -ne "33]0;${PWD/#$HOME/~}07"'


          useful when you have 100 minimized terminals in your dock



          hat tip to mac world






          share|improve this answer















          run this command to set the title of your tab or window:



          export PROMPT_COMMAND='echo -ne "33]0;YOUR NAME HERE07"'


          i've added the following to my ~/.bash_profile to always list the current directory relative to my home dir:



          export PROMPT_COMMAND='echo -ne "33]0;${PWD/#$HOME/~}07"'


          useful when you have 100 minimized terminals in your dock



          hat tip to mac world







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Aug 1 '13 at 11:57

























          answered Mar 4 '13 at 0:33









          schpetschpet

          72968




          72968













          • Works! Just keep in mind that either .bashrc or .bash_profiles can be loaded and not both together. I already had a .bash_profiles file so I had to paste it into this file. Thanks.

            – therealmarv
            Jul 31 '13 at 11:13






          • 1





            oh thanks! i've updated the answer to match this. i have "source ~/.bashrc" in my .bash_profile and forget that this is not common

            – schpet
            Aug 1 '13 at 11:59



















          • Works! Just keep in mind that either .bashrc or .bash_profiles can be loaded and not both together. I already had a .bash_profiles file so I had to paste it into this file. Thanks.

            – therealmarv
            Jul 31 '13 at 11:13






          • 1





            oh thanks! i've updated the answer to match this. i have "source ~/.bashrc" in my .bash_profile and forget that this is not common

            – schpet
            Aug 1 '13 at 11:59

















          Works! Just keep in mind that either .bashrc or .bash_profiles can be loaded and not both together. I already had a .bash_profiles file so I had to paste it into this file. Thanks.

          – therealmarv
          Jul 31 '13 at 11:13





          Works! Just keep in mind that either .bashrc or .bash_profiles can be loaded and not both together. I already had a .bash_profiles file so I had to paste it into this file. Thanks.

          – therealmarv
          Jul 31 '13 at 11:13




          1




          1





          oh thanks! i've updated the answer to match this. i have "source ~/.bashrc" in my .bash_profile and forget that this is not common

          – schpet
          Aug 1 '13 at 11:59





          oh thanks! i've updated the answer to match this. i have "source ~/.bashrc" in my .bash_profile and forget that this is not common

          – schpet
          Aug 1 '13 at 11:59











          15














          Add this function to your ~/.bash_profile file and it should work.



          function title ()
          {
          TITLE=$*;
          export PROMPT_COMMAND='echo -ne "33]0;$TITLE07"'
          }





          share|improve this answer






























            15














            Add this function to your ~/.bash_profile file and it should work.



            function title ()
            {
            TITLE=$*;
            export PROMPT_COMMAND='echo -ne "33]0;$TITLE07"'
            }





            share|improve this answer




























              15












              15








              15







              Add this function to your ~/.bash_profile file and it should work.



              function title ()
              {
              TITLE=$*;
              export PROMPT_COMMAND='echo -ne "33]0;$TITLE07"'
              }





              share|improve this answer















              Add this function to your ~/.bash_profile file and it should work.



              function title ()
              {
              TITLE=$*;
              export PROMPT_COMMAND='echo -ne "33]0;$TITLE07"'
              }






              share|improve this answer














              share|improve this answer



              share|improve this answer








              edited Nov 25 '13 at 10:43









              richsage

              1135




              1135










              answered Oct 24 '13 at 3:26









              jiangyu7408jiangyu7408

              15112




              15112























                  13














                  I used solutions similar to the above for quite a while, but I use enough tabs that I also want them color-coded for easy visual reference. So I whipped up tabset, a utility to set the tab title, badge, and color based on the kind of work I am doing in each tab.



                  example



                  It requires node, but that is now a commonly installed platform. To install:



                  npm install -g iterm2-tab-set





                  share|improve this answer


























                  • This is awesome! I especially love the auto setting of the tab color. Thank you!

                    – Ashutosh Jindal
                    Jun 11 '18 at 14:22
















                  13














                  I used solutions similar to the above for quite a while, but I use enough tabs that I also want them color-coded for easy visual reference. So I whipped up tabset, a utility to set the tab title, badge, and color based on the kind of work I am doing in each tab.



                  example



                  It requires node, but that is now a commonly installed platform. To install:



                  npm install -g iterm2-tab-set





                  share|improve this answer


























                  • This is awesome! I especially love the auto setting of the tab color. Thank you!

                    – Ashutosh Jindal
                    Jun 11 '18 at 14:22














                  13












                  13








                  13







                  I used solutions similar to the above for quite a while, but I use enough tabs that I also want them color-coded for easy visual reference. So I whipped up tabset, a utility to set the tab title, badge, and color based on the kind of work I am doing in each tab.



                  example



                  It requires node, but that is now a commonly installed platform. To install:



                  npm install -g iterm2-tab-set





                  share|improve this answer















                  I used solutions similar to the above for quite a while, but I use enough tabs that I also want them color-coded for easy visual reference. So I whipped up tabset, a utility to set the tab title, badge, and color based on the kind of work I am doing in each tab.



                  example



                  It requires node, but that is now a commonly installed platform. To install:



                  npm install -g iterm2-tab-set






                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Jul 26 '16 at 15:33

























                  answered Jun 15 '16 at 14:19









                  Jonathan EuniceJonathan Eunice

                  23125




                  23125













                  • This is awesome! I especially love the auto setting of the tab color. Thank you!

                    – Ashutosh Jindal
                    Jun 11 '18 at 14:22



















                  • This is awesome! I especially love the auto setting of the tab color. Thank you!

                    – Ashutosh Jindal
                    Jun 11 '18 at 14:22

















                  This is awesome! I especially love the auto setting of the tab color. Thank you!

                  – Ashutosh Jindal
                  Jun 11 '18 at 14:22





                  This is awesome! I especially love the auto setting of the tab color. Thank you!

                  – Ashutosh Jindal
                  Jun 11 '18 at 14:22











                  7














                  I like this one:



                  #setup terminal tab title
                  function title {
                  if [ "$1" ]
                  then
                  unset PROMPT_COMMAND
                  echo -ne "33]0;${*}07"
                  else
                  export PROMPT_COMMAND='echo -ne "33]0;${PWD/#$HOME/~}07"'
                  fi
                  }
                  title


                  It will let you toggle the name of a tab between a custom name and a default of your CWD.



                  title -> your tab title will be ~/YOUR_CWD/



                  title hey there -> your tab title will be hey there






                  share|improve this answer
























                  • Note that as-is, this will clobber iTerm shell integration.

                    – Michael
                    Mar 18 '16 at 15:30
















                  7














                  I like this one:



                  #setup terminal tab title
                  function title {
                  if [ "$1" ]
                  then
                  unset PROMPT_COMMAND
                  echo -ne "33]0;${*}07"
                  else
                  export PROMPT_COMMAND='echo -ne "33]0;${PWD/#$HOME/~}07"'
                  fi
                  }
                  title


                  It will let you toggle the name of a tab between a custom name and a default of your CWD.



                  title -> your tab title will be ~/YOUR_CWD/



                  title hey there -> your tab title will be hey there






                  share|improve this answer
























                  • Note that as-is, this will clobber iTerm shell integration.

                    – Michael
                    Mar 18 '16 at 15:30














                  7












                  7








                  7







                  I like this one:



                  #setup terminal tab title
                  function title {
                  if [ "$1" ]
                  then
                  unset PROMPT_COMMAND
                  echo -ne "33]0;${*}07"
                  else
                  export PROMPT_COMMAND='echo -ne "33]0;${PWD/#$HOME/~}07"'
                  fi
                  }
                  title


                  It will let you toggle the name of a tab between a custom name and a default of your CWD.



                  title -> your tab title will be ~/YOUR_CWD/



                  title hey there -> your tab title will be hey there






                  share|improve this answer













                  I like this one:



                  #setup terminal tab title
                  function title {
                  if [ "$1" ]
                  then
                  unset PROMPT_COMMAND
                  echo -ne "33]0;${*}07"
                  else
                  export PROMPT_COMMAND='echo -ne "33]0;${PWD/#$HOME/~}07"'
                  fi
                  }
                  title


                  It will let you toggle the name of a tab between a custom name and a default of your CWD.



                  title -> your tab title will be ~/YOUR_CWD/



                  title hey there -> your tab title will be hey there







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Jul 26 '15 at 15:29









                  taylorstinetaylorstine

                  17112




                  17112













                  • Note that as-is, this will clobber iTerm shell integration.

                    – Michael
                    Mar 18 '16 at 15:30



















                  • Note that as-is, this will clobber iTerm shell integration.

                    – Michael
                    Mar 18 '16 at 15:30

















                  Note that as-is, this will clobber iTerm shell integration.

                  – Michael
                  Mar 18 '16 at 15:30





                  Note that as-is, this will clobber iTerm shell integration.

                  – Michael
                  Mar 18 '16 at 15:30











                  4














                  I really like taylorstine's answer, but it breaks iTerm2's shell integration which relies on the PROMPT_COMMAND variable. You can modify Taylor's code to correct this by adding the __bp_precmd_invoke_cmd back into the PROMPT_COMMAND any time you tinker with it:



                  # iTerm2 shell integration
                  test -e "${HOME}/.iterm2_shell_integration.bash" && source "${HOME}/.iterm2_shell_integration.bash"

                  # iTerm2 tab titles
                  function title {
                  if [ "$1" ]
                  then
                  export PROMPT_COMMAND='__bp_precmd_invoke_cmd'
                  echo -ne "33]0;${*}07"
                  else
                  export PROMPT_COMMAND='echo -ne "33]0;${PWD/#$HOME/~}07";__bp_precmd_invoke_cmd'
                  fi
                  }
                  title





                  share|improve this answer






























                    4














                    I really like taylorstine's answer, but it breaks iTerm2's shell integration which relies on the PROMPT_COMMAND variable. You can modify Taylor's code to correct this by adding the __bp_precmd_invoke_cmd back into the PROMPT_COMMAND any time you tinker with it:



                    # iTerm2 shell integration
                    test -e "${HOME}/.iterm2_shell_integration.bash" && source "${HOME}/.iterm2_shell_integration.bash"

                    # iTerm2 tab titles
                    function title {
                    if [ "$1" ]
                    then
                    export PROMPT_COMMAND='__bp_precmd_invoke_cmd'
                    echo -ne "33]0;${*}07"
                    else
                    export PROMPT_COMMAND='echo -ne "33]0;${PWD/#$HOME/~}07";__bp_precmd_invoke_cmd'
                    fi
                    }
                    title





                    share|improve this answer




























                      4












                      4








                      4







                      I really like taylorstine's answer, but it breaks iTerm2's shell integration which relies on the PROMPT_COMMAND variable. You can modify Taylor's code to correct this by adding the __bp_precmd_invoke_cmd back into the PROMPT_COMMAND any time you tinker with it:



                      # iTerm2 shell integration
                      test -e "${HOME}/.iterm2_shell_integration.bash" && source "${HOME}/.iterm2_shell_integration.bash"

                      # iTerm2 tab titles
                      function title {
                      if [ "$1" ]
                      then
                      export PROMPT_COMMAND='__bp_precmd_invoke_cmd'
                      echo -ne "33]0;${*}07"
                      else
                      export PROMPT_COMMAND='echo -ne "33]0;${PWD/#$HOME/~}07";__bp_precmd_invoke_cmd'
                      fi
                      }
                      title





                      share|improve this answer















                      I really like taylorstine's answer, but it breaks iTerm2's shell integration which relies on the PROMPT_COMMAND variable. You can modify Taylor's code to correct this by adding the __bp_precmd_invoke_cmd back into the PROMPT_COMMAND any time you tinker with it:



                      # iTerm2 shell integration
                      test -e "${HOME}/.iterm2_shell_integration.bash" && source "${HOME}/.iterm2_shell_integration.bash"

                      # iTerm2 tab titles
                      function title {
                      if [ "$1" ]
                      then
                      export PROMPT_COMMAND='__bp_precmd_invoke_cmd'
                      echo -ne "33]0;${*}07"
                      else
                      export PROMPT_COMMAND='echo -ne "33]0;${PWD/#$HOME/~}07";__bp_precmd_invoke_cmd'
                      fi
                      }
                      title






                      share|improve this answer














                      share|improve this answer



                      share|improve this answer








                      edited Jan 3 '18 at 18:30

























                      answered Mar 30 '16 at 14:45









                      MichaelMichael

                      353412




                      353412























                          3














                          I like Michael's answer.



                          But what if .iterm2_shell_integration.bash does not exist?



                          Here's my take:



                          # iTerm2 shell integration
                          test -e "${HOME}/.iterm2_shell_integration.bash" && source "${HOME}/.iterm2_shell_integration.bash"

                          # iTerm2 tab titles
                          function title {
                          if [ "$1" ] ; then
                          test -e "${HOME}/.iterm2_shell_integration.bash"
                          && export PROMPT_COMMAND='iterm2_preexec_invoke_cmd'
                          || unset PROMPT_COMMAND
                          echo -ne "33]0;${*}07"
                          else
                          test -e "${HOME}/.iterm2_shell_integration.bash"
                          && export PROMPT_COMMAND='echo -ne "33]0;${PWD/#$HOME/~}07";iterm2_preexec_invoke_cmd'
                          || export PROMPT_COMMAND='echo -ne "33]0;${PWD/#$HOME/~}07"'
                          fi
                          }
                          title





                          share|improve this answer


























                          • Note that in v3.1, iterm2_preexec_invoke_cmd has become __bp_precmd_invoke_cmd

                            – Michael
                            Sep 20 '17 at 21:50
















                          3














                          I like Michael's answer.



                          But what if .iterm2_shell_integration.bash does not exist?



                          Here's my take:



                          # iTerm2 shell integration
                          test -e "${HOME}/.iterm2_shell_integration.bash" && source "${HOME}/.iterm2_shell_integration.bash"

                          # iTerm2 tab titles
                          function title {
                          if [ "$1" ] ; then
                          test -e "${HOME}/.iterm2_shell_integration.bash"
                          && export PROMPT_COMMAND='iterm2_preexec_invoke_cmd'
                          || unset PROMPT_COMMAND
                          echo -ne "33]0;${*}07"
                          else
                          test -e "${HOME}/.iterm2_shell_integration.bash"
                          && export PROMPT_COMMAND='echo -ne "33]0;${PWD/#$HOME/~}07";iterm2_preexec_invoke_cmd'
                          || export PROMPT_COMMAND='echo -ne "33]0;${PWD/#$HOME/~}07"'
                          fi
                          }
                          title





                          share|improve this answer


























                          • Note that in v3.1, iterm2_preexec_invoke_cmd has become __bp_precmd_invoke_cmd

                            – Michael
                            Sep 20 '17 at 21:50














                          3












                          3








                          3







                          I like Michael's answer.



                          But what if .iterm2_shell_integration.bash does not exist?



                          Here's my take:



                          # iTerm2 shell integration
                          test -e "${HOME}/.iterm2_shell_integration.bash" && source "${HOME}/.iterm2_shell_integration.bash"

                          # iTerm2 tab titles
                          function title {
                          if [ "$1" ] ; then
                          test -e "${HOME}/.iterm2_shell_integration.bash"
                          && export PROMPT_COMMAND='iterm2_preexec_invoke_cmd'
                          || unset PROMPT_COMMAND
                          echo -ne "33]0;${*}07"
                          else
                          test -e "${HOME}/.iterm2_shell_integration.bash"
                          && export PROMPT_COMMAND='echo -ne "33]0;${PWD/#$HOME/~}07";iterm2_preexec_invoke_cmd'
                          || export PROMPT_COMMAND='echo -ne "33]0;${PWD/#$HOME/~}07"'
                          fi
                          }
                          title





                          share|improve this answer















                          I like Michael's answer.



                          But what if .iterm2_shell_integration.bash does not exist?



                          Here's my take:



                          # iTerm2 shell integration
                          test -e "${HOME}/.iterm2_shell_integration.bash" && source "${HOME}/.iterm2_shell_integration.bash"

                          # iTerm2 tab titles
                          function title {
                          if [ "$1" ] ; then
                          test -e "${HOME}/.iterm2_shell_integration.bash"
                          && export PROMPT_COMMAND='iterm2_preexec_invoke_cmd'
                          || unset PROMPT_COMMAND
                          echo -ne "33]0;${*}07"
                          else
                          test -e "${HOME}/.iterm2_shell_integration.bash"
                          && export PROMPT_COMMAND='echo -ne "33]0;${PWD/#$HOME/~}07";iterm2_preexec_invoke_cmd'
                          || export PROMPT_COMMAND='echo -ne "33]0;${PWD/#$HOME/~}07"'
                          fi
                          }
                          title






                          share|improve this answer














                          share|improve this answer



                          share|improve this answer








                          edited May 23 '17 at 16:33









                          Toby Speight

                          3,6161532




                          3,6161532










                          answered May 23 '17 at 13:21









                          user1318024user1318024

                          311




                          311













                          • Note that in v3.1, iterm2_preexec_invoke_cmd has become __bp_precmd_invoke_cmd

                            – Michael
                            Sep 20 '17 at 21:50



















                          • Note that in v3.1, iterm2_preexec_invoke_cmd has become __bp_precmd_invoke_cmd

                            – Michael
                            Sep 20 '17 at 21:50

















                          Note that in v3.1, iterm2_preexec_invoke_cmd has become __bp_precmd_invoke_cmd

                          – Michael
                          Sep 20 '17 at 21:50





                          Note that in v3.1, iterm2_preexec_invoke_cmd has become __bp_precmd_invoke_cmd

                          – Michael
                          Sep 20 '17 at 21:50











                          2














                          If you're working with Profiles (which is very convenient):
                          Preferences -> Appearance -> Window & Tab Titles: tick 'Show profile name':



                          image



                          That's how it looks after:



                          thumbnail linked to main image






                          share|improve this answer






























                            2














                            If you're working with Profiles (which is very convenient):
                            Preferences -> Appearance -> Window & Tab Titles: tick 'Show profile name':



                            image



                            That's how it looks after:



                            thumbnail linked to main image






                            share|improve this answer




























                              2












                              2








                              2







                              If you're working with Profiles (which is very convenient):
                              Preferences -> Appearance -> Window & Tab Titles: tick 'Show profile name':



                              image



                              That's how it looks after:



                              thumbnail linked to main image






                              share|improve this answer















                              If you're working with Profiles (which is very convenient):
                              Preferences -> Appearance -> Window & Tab Titles: tick 'Show profile name':



                              image



                              That's how it looks after:



                              thumbnail linked to main image







                              share|improve this answer














                              share|improve this answer



                              share|improve this answer








                              edited Jan 25 '17 at 5:48









                              MJH

                              1,02941018




                              1,02941018










                              answered Jan 24 '17 at 20:45









                              aianitroaianitro

                              1213




                              1213























                                  2














                                  Preferences -> Profiles -> Terminal
                                  uncheck Terminal may set Tab/Window title


                                  Max Cantor's comment worked for me.






                                  share|improve this answer



















                                  • 1





                                    This is what I was looking for. Thanks!

                                    – William Schroeder McKinley
                                    Nov 28 '18 at 17:06
















                                  2














                                  Preferences -> Profiles -> Terminal
                                  uncheck Terminal may set Tab/Window title


                                  Max Cantor's comment worked for me.






                                  share|improve this answer



















                                  • 1





                                    This is what I was looking for. Thanks!

                                    – William Schroeder McKinley
                                    Nov 28 '18 at 17:06














                                  2












                                  2








                                  2







                                  Preferences -> Profiles -> Terminal
                                  uncheck Terminal may set Tab/Window title


                                  Max Cantor's comment worked for me.






                                  share|improve this answer













                                  Preferences -> Profiles -> Terminal
                                  uncheck Terminal may set Tab/Window title


                                  Max Cantor's comment worked for me.







                                  share|improve this answer












                                  share|improve this answer



                                  share|improve this answer










                                  answered Feb 27 '18 at 13:22









                                  B SevenB Seven

                                  2751516




                                  2751516








                                  • 1





                                    This is what I was looking for. Thanks!

                                    – William Schroeder McKinley
                                    Nov 28 '18 at 17:06














                                  • 1





                                    This is what I was looking for. Thanks!

                                    – William Schroeder McKinley
                                    Nov 28 '18 at 17:06








                                  1




                                  1





                                  This is what I was looking for. Thanks!

                                  – William Schroeder McKinley
                                  Nov 28 '18 at 17:06





                                  This is what I was looking for. Thanks!

                                  – William Schroeder McKinley
                                  Nov 28 '18 at 17:06











                                  0














                                  I think Automatic Profile Switching and Badges are exactly designed for what you need:




                                  Automatic Profile Switching iTerm2 can use information it knows about your current path, host name, and user name to change profiles. For example, your window's background color or the terminal's character encoding could change when connecting to different hosts.



                                  Badges
                                  You can put a badge in the top right of your terminal showing information about the current session. It can show your username, hostname, or even custom data like the current git branch.




                                  so the result may like this:



                                  enter image description here






                                  share|improve this answer


























                                  • Please quote the essential parts of the answer from the reference link(s), as the answer can become invalid if the linked page(s) change.

                                    – DavidPostill
                                    May 1 '17 at 9:28
















                                  0














                                  I think Automatic Profile Switching and Badges are exactly designed for what you need:




                                  Automatic Profile Switching iTerm2 can use information it knows about your current path, host name, and user name to change profiles. For example, your window's background color or the terminal's character encoding could change when connecting to different hosts.



                                  Badges
                                  You can put a badge in the top right of your terminal showing information about the current session. It can show your username, hostname, or even custom data like the current git branch.




                                  so the result may like this:



                                  enter image description here






                                  share|improve this answer


























                                  • Please quote the essential parts of the answer from the reference link(s), as the answer can become invalid if the linked page(s) change.

                                    – DavidPostill
                                    May 1 '17 at 9:28














                                  0












                                  0








                                  0







                                  I think Automatic Profile Switching and Badges are exactly designed for what you need:




                                  Automatic Profile Switching iTerm2 can use information it knows about your current path, host name, and user name to change profiles. For example, your window's background color or the terminal's character encoding could change when connecting to different hosts.



                                  Badges
                                  You can put a badge in the top right of your terminal showing information about the current session. It can show your username, hostname, or even custom data like the current git branch.




                                  so the result may like this:



                                  enter image description here






                                  share|improve this answer















                                  I think Automatic Profile Switching and Badges are exactly designed for what you need:




                                  Automatic Profile Switching iTerm2 can use information it knows about your current path, host name, and user name to change profiles. For example, your window's background color or the terminal's character encoding could change when connecting to different hosts.



                                  Badges
                                  You can put a badge in the top right of your terminal showing information about the current session. It can show your username, hostname, or even custom data like the current git branch.




                                  so the result may like this:



                                  enter image description here







                                  share|improve this answer














                                  share|improve this answer



                                  share|improve this answer








                                  edited May 1 '17 at 13:05

























                                  answered May 1 '17 at 9:15









                                  lengxuehxlengxuehx

                                  1013




                                  1013













                                  • Please quote the essential parts of the answer from the reference link(s), as the answer can become invalid if the linked page(s) change.

                                    – DavidPostill
                                    May 1 '17 at 9:28



















                                  • Please quote the essential parts of the answer from the reference link(s), as the answer can become invalid if the linked page(s) change.

                                    – DavidPostill
                                    May 1 '17 at 9:28

















                                  Please quote the essential parts of the answer from the reference link(s), as the answer can become invalid if the linked page(s) change.

                                  – DavidPostill
                                  May 1 '17 at 9:28





                                  Please quote the essential parts of the answer from the reference link(s), as the answer can become invalid if the linked page(s) change.

                                  – DavidPostill
                                  May 1 '17 at 9:28











                                  0














                                  I would like to extend B Seven's answer a little for absolute clarity.



                                  Since most of us would like to know how can one set a title of a tab even when they are not in local shell, instead of in remote shell (e.g over ssh).



                                  Step 1. Preferences -> Profiles -> Terminal
                                  uncheck Terminal may set Tab/Window title



                                  Step 2. For each tabs, double click on the tab -> Session Title



                                  Now, whatever you'd set in the session title, it would stay as is.






                                  share|improve this answer




























                                    0














                                    I would like to extend B Seven's answer a little for absolute clarity.



                                    Since most of us would like to know how can one set a title of a tab even when they are not in local shell, instead of in remote shell (e.g over ssh).



                                    Step 1. Preferences -> Profiles -> Terminal
                                    uncheck Terminal may set Tab/Window title



                                    Step 2. For each tabs, double click on the tab -> Session Title



                                    Now, whatever you'd set in the session title, it would stay as is.






                                    share|improve this answer


























                                      0












                                      0








                                      0







                                      I would like to extend B Seven's answer a little for absolute clarity.



                                      Since most of us would like to know how can one set a title of a tab even when they are not in local shell, instead of in remote shell (e.g over ssh).



                                      Step 1. Preferences -> Profiles -> Terminal
                                      uncheck Terminal may set Tab/Window title



                                      Step 2. For each tabs, double click on the tab -> Session Title



                                      Now, whatever you'd set in the session title, it would stay as is.






                                      share|improve this answer













                                      I would like to extend B Seven's answer a little for absolute clarity.



                                      Since most of us would like to know how can one set a title of a tab even when they are not in local shell, instead of in remote shell (e.g over ssh).



                                      Step 1. Preferences -> Profiles -> Terminal
                                      uncheck Terminal may set Tab/Window title



                                      Step 2. For each tabs, double click on the tab -> Session Title



                                      Now, whatever you'd set in the session title, it would stay as is.







                                      share|improve this answer












                                      share|improve this answer



                                      share|improve this answer










                                      answered Jan 17 at 8:32









                                      Krishna GuptaKrishna Gupta

                                      1112




                                      1112























                                          -1














                                          Yuk, all those aliases and functions. Easier solution (if you are root), paste this into a terminal:



                                          TARGET=/usr/bin/title
                                          sudo tee "$TARGET" <<'EOF'
                                          #!/usr/bin/env bash
                                          echo -ne "33]0;$*07"
                                          EOF
                                          sudo chmod 755 "$TARGET"


                                          Or just make a file call title somewhere in your path, or global path, and paste the two lines between EOF.






                                          share|improve this answer



















                                          • 11





                                            "Yuk with all those aliases." Enters answer no one can possible remember or type by hand.

                                            – Dan
                                            Jan 14 '16 at 18:09






                                          • 1





                                            @Dan not saying this is great, just that there's no need to remember that since it's just creating a script called title in /usr/bin.

                                            – Emile Bergeron
                                            Jan 9 '17 at 21:43











                                          • @EmileBergeron thx, although it seems you (we) are in a minority. The answer was only 1 line, the rest is for lazy people.

                                            – Orwellophile
                                            Jan 10 '17 at 7:09
















                                          -1














                                          Yuk, all those aliases and functions. Easier solution (if you are root), paste this into a terminal:



                                          TARGET=/usr/bin/title
                                          sudo tee "$TARGET" <<'EOF'
                                          #!/usr/bin/env bash
                                          echo -ne "33]0;$*07"
                                          EOF
                                          sudo chmod 755 "$TARGET"


                                          Or just make a file call title somewhere in your path, or global path, and paste the two lines between EOF.






                                          share|improve this answer



















                                          • 11





                                            "Yuk with all those aliases." Enters answer no one can possible remember or type by hand.

                                            – Dan
                                            Jan 14 '16 at 18:09






                                          • 1





                                            @Dan not saying this is great, just that there's no need to remember that since it's just creating a script called title in /usr/bin.

                                            – Emile Bergeron
                                            Jan 9 '17 at 21:43











                                          • @EmileBergeron thx, although it seems you (we) are in a minority. The answer was only 1 line, the rest is for lazy people.

                                            – Orwellophile
                                            Jan 10 '17 at 7:09














                                          -1












                                          -1








                                          -1







                                          Yuk, all those aliases and functions. Easier solution (if you are root), paste this into a terminal:



                                          TARGET=/usr/bin/title
                                          sudo tee "$TARGET" <<'EOF'
                                          #!/usr/bin/env bash
                                          echo -ne "33]0;$*07"
                                          EOF
                                          sudo chmod 755 "$TARGET"


                                          Or just make a file call title somewhere in your path, or global path, and paste the two lines between EOF.






                                          share|improve this answer













                                          Yuk, all those aliases and functions. Easier solution (if you are root), paste this into a terminal:



                                          TARGET=/usr/bin/title
                                          sudo tee "$TARGET" <<'EOF'
                                          #!/usr/bin/env bash
                                          echo -ne "33]0;$*07"
                                          EOF
                                          sudo chmod 755 "$TARGET"


                                          Or just make a file call title somewhere in your path, or global path, and paste the two lines between EOF.







                                          share|improve this answer












                                          share|improve this answer



                                          share|improve this answer










                                          answered Jun 29 '15 at 13:35









                                          OrwellophileOrwellophile

                                          39337




                                          39337








                                          • 11





                                            "Yuk with all those aliases." Enters answer no one can possible remember or type by hand.

                                            – Dan
                                            Jan 14 '16 at 18:09






                                          • 1





                                            @Dan not saying this is great, just that there's no need to remember that since it's just creating a script called title in /usr/bin.

                                            – Emile Bergeron
                                            Jan 9 '17 at 21:43











                                          • @EmileBergeron thx, although it seems you (we) are in a minority. The answer was only 1 line, the rest is for lazy people.

                                            – Orwellophile
                                            Jan 10 '17 at 7:09














                                          • 11





                                            "Yuk with all those aliases." Enters answer no one can possible remember or type by hand.

                                            – Dan
                                            Jan 14 '16 at 18:09






                                          • 1





                                            @Dan not saying this is great, just that there's no need to remember that since it's just creating a script called title in /usr/bin.

                                            – Emile Bergeron
                                            Jan 9 '17 at 21:43











                                          • @EmileBergeron thx, although it seems you (we) are in a minority. The answer was only 1 line, the rest is for lazy people.

                                            – Orwellophile
                                            Jan 10 '17 at 7:09








                                          11




                                          11





                                          "Yuk with all those aliases." Enters answer no one can possible remember or type by hand.

                                          – Dan
                                          Jan 14 '16 at 18:09





                                          "Yuk with all those aliases." Enters answer no one can possible remember or type by hand.

                                          – Dan
                                          Jan 14 '16 at 18:09




                                          1




                                          1





                                          @Dan not saying this is great, just that there's no need to remember that since it's just creating a script called title in /usr/bin.

                                          – Emile Bergeron
                                          Jan 9 '17 at 21:43





                                          @Dan not saying this is great, just that there's no need to remember that since it's just creating a script called title in /usr/bin.

                                          – Emile Bergeron
                                          Jan 9 '17 at 21:43













                                          @EmileBergeron thx, although it seems you (we) are in a minority. The answer was only 1 line, the rest is for lazy people.

                                          – Orwellophile
                                          Jan 10 '17 at 7:09





                                          @EmileBergeron thx, although it seems you (we) are in a minority. The answer was only 1 line, the rest is for lazy people.

                                          – Orwellophile
                                          Jan 10 '17 at 7:09


















                                          draft saved

                                          draft discarded




















































                                          Thanks for contributing an answer to Super User!


                                          • 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%2fsuperuser.com%2fquestions%2f419775%2fwith-bash-iterm2-how-to-name-tabs%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

                                          flock() on closed filehandle LOCK_FILE at /usr/bin/apt-mirror

                                          Mangá

                                          Eduardo VII do Reino Unido