tmux not colorizing PS1 prompt

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












5















I recently decided to change my PS1 variable to accommodate some pretty Solarized colors for my terminal viewing pleasure. When not in a tmux session, everything is great! Rainbows, ponies, unicorns and a distinguishable prompt! Cool!



The problem is within tmux, however. I've verified that the value of PS1 is what I expect it to be and the same as it is when tmux isn't running, namely [33]0;w07][[]]u[]@[[]]h[]:[]W[]$ [].



All of my aliases, etc. in my .bash_profile are also functioning as expected. tmux is also displaying colors without incident, as echo -ne "33[1;33m hi" behaves as expected as does gls --color.



The current relevant line in my .bash_profile is export PS1="[33]0;w07][[]]u[]@[[]]h[]:[]W[]$ []", although originally I was sourcing a script located in a .bash_prompt file to handle some conditionals, etc. I tried reverting to the simpler version.



Executing bash will cause the prompt to colorize, but must be done in each pane. export PS1=[that long string I've already posted] will not.



My .tmux.conf is as follows:



set-option -g default-command "reattach-to-user-namespace -l /usr/local/bin/bash"
set -g default-terminal "xterm-256color"
set-window-option -g automatic-rename on
bind '"' split-window -c "#pane_current_path"
bind % split-window -h -c "#pane_current_path"
bind c new-window -c "#pane_current_path"


Relevant portions of .bash_profile:



export TERM="xterm-256color"
if which tmux >/dev/null 2>&1; then
test -z "$TMUX" && (tmux attach || tmux new-session)
fi


I'm using macOS Sierra, iTerm 2, I've tried both the current homebrew version of bash and the system bash (it's currently using the homebrew), tmux 2.4.



I also placed touch testing_touch_from_bash_profile in my .bash_profile while in a tmux session with two panes, killed one pane, opened a pane and verified that the file was in fact created.



echo $TERM returns xterm-256color.



I've ensured that when exiting tmux to test settings changes that I've exited tmux and that no tmux process is currently running on the system via ps -ax | grep tmux.



Oddly, sourcing the .bash_prompt script also changes the color so long as I do it within each tmux pane.



I've looked at https://stackoverflow.com/questions/21005966/tmux-prompt-not-following-normal-bash-prompt-ps1-w and tried adding the --login flag after the bash call in the first line of my .tmux.conf. Launching tmux with tmux new bash will cause the first pane to colorize, but subsequent panes will not.



The $PS1 variable is being honored for seemingly all aspects except colorizing any of the fields.



Anyone have any ideas?










share|improve this question
























  • Try single quotes

    – Kevin
    Apr 22 '17 at 5:24






  • 4





    The PS1 setting you posted doesn't have any command to change colors. Post an actual setting that does work outside tmux. Also, you should set PS1 in .bashrc, not in .bash_profile: .bash_profile might not get executed at all, and the settings might be overridden later.

    – Gilles
    Apr 22 '17 at 21:42















5















I recently decided to change my PS1 variable to accommodate some pretty Solarized colors for my terminal viewing pleasure. When not in a tmux session, everything is great! Rainbows, ponies, unicorns and a distinguishable prompt! Cool!



The problem is within tmux, however. I've verified that the value of PS1 is what I expect it to be and the same as it is when tmux isn't running, namely [33]0;w07][[]]u[]@[[]]h[]:[]W[]$ [].



All of my aliases, etc. in my .bash_profile are also functioning as expected. tmux is also displaying colors without incident, as echo -ne "33[1;33m hi" behaves as expected as does gls --color.



The current relevant line in my .bash_profile is export PS1="[33]0;w07][[]]u[]@[[]]h[]:[]W[]$ []", although originally I was sourcing a script located in a .bash_prompt file to handle some conditionals, etc. I tried reverting to the simpler version.



Executing bash will cause the prompt to colorize, but must be done in each pane. export PS1=[that long string I've already posted] will not.



My .tmux.conf is as follows:



set-option -g default-command "reattach-to-user-namespace -l /usr/local/bin/bash"
set -g default-terminal "xterm-256color"
set-window-option -g automatic-rename on
bind '"' split-window -c "#pane_current_path"
bind % split-window -h -c "#pane_current_path"
bind c new-window -c "#pane_current_path"


Relevant portions of .bash_profile:



export TERM="xterm-256color"
if which tmux >/dev/null 2>&1; then
test -z "$TMUX" && (tmux attach || tmux new-session)
fi


I'm using macOS Sierra, iTerm 2, I've tried both the current homebrew version of bash and the system bash (it's currently using the homebrew), tmux 2.4.



I also placed touch testing_touch_from_bash_profile in my .bash_profile while in a tmux session with two panes, killed one pane, opened a pane and verified that the file was in fact created.



echo $TERM returns xterm-256color.



I've ensured that when exiting tmux to test settings changes that I've exited tmux and that no tmux process is currently running on the system via ps -ax | grep tmux.



Oddly, sourcing the .bash_prompt script also changes the color so long as I do it within each tmux pane.



I've looked at https://stackoverflow.com/questions/21005966/tmux-prompt-not-following-normal-bash-prompt-ps1-w and tried adding the --login flag after the bash call in the first line of my .tmux.conf. Launching tmux with tmux new bash will cause the first pane to colorize, but subsequent panes will not.



The $PS1 variable is being honored for seemingly all aspects except colorizing any of the fields.



Anyone have any ideas?










share|improve this question
























  • Try single quotes

    – Kevin
    Apr 22 '17 at 5:24






  • 4





    The PS1 setting you posted doesn't have any command to change colors. Post an actual setting that does work outside tmux. Also, you should set PS1 in .bashrc, not in .bash_profile: .bash_profile might not get executed at all, and the settings might be overridden later.

    – Gilles
    Apr 22 '17 at 21:42













5












5








5








I recently decided to change my PS1 variable to accommodate some pretty Solarized colors for my terminal viewing pleasure. When not in a tmux session, everything is great! Rainbows, ponies, unicorns and a distinguishable prompt! Cool!



The problem is within tmux, however. I've verified that the value of PS1 is what I expect it to be and the same as it is when tmux isn't running, namely [33]0;w07][[]]u[]@[[]]h[]:[]W[]$ [].



All of my aliases, etc. in my .bash_profile are also functioning as expected. tmux is also displaying colors without incident, as echo -ne "33[1;33m hi" behaves as expected as does gls --color.



The current relevant line in my .bash_profile is export PS1="[33]0;w07][[]]u[]@[[]]h[]:[]W[]$ []", although originally I was sourcing a script located in a .bash_prompt file to handle some conditionals, etc. I tried reverting to the simpler version.



Executing bash will cause the prompt to colorize, but must be done in each pane. export PS1=[that long string I've already posted] will not.



My .tmux.conf is as follows:



set-option -g default-command "reattach-to-user-namespace -l /usr/local/bin/bash"
set -g default-terminal "xterm-256color"
set-window-option -g automatic-rename on
bind '"' split-window -c "#pane_current_path"
bind % split-window -h -c "#pane_current_path"
bind c new-window -c "#pane_current_path"


Relevant portions of .bash_profile:



export TERM="xterm-256color"
if which tmux >/dev/null 2>&1; then
test -z "$TMUX" && (tmux attach || tmux new-session)
fi


I'm using macOS Sierra, iTerm 2, I've tried both the current homebrew version of bash and the system bash (it's currently using the homebrew), tmux 2.4.



I also placed touch testing_touch_from_bash_profile in my .bash_profile while in a tmux session with two panes, killed one pane, opened a pane and verified that the file was in fact created.



echo $TERM returns xterm-256color.



I've ensured that when exiting tmux to test settings changes that I've exited tmux and that no tmux process is currently running on the system via ps -ax | grep tmux.



Oddly, sourcing the .bash_prompt script also changes the color so long as I do it within each tmux pane.



I've looked at https://stackoverflow.com/questions/21005966/tmux-prompt-not-following-normal-bash-prompt-ps1-w and tried adding the --login flag after the bash call in the first line of my .tmux.conf. Launching tmux with tmux new bash will cause the first pane to colorize, but subsequent panes will not.



The $PS1 variable is being honored for seemingly all aspects except colorizing any of the fields.



Anyone have any ideas?










share|improve this question
















I recently decided to change my PS1 variable to accommodate some pretty Solarized colors for my terminal viewing pleasure. When not in a tmux session, everything is great! Rainbows, ponies, unicorns and a distinguishable prompt! Cool!



The problem is within tmux, however. I've verified that the value of PS1 is what I expect it to be and the same as it is when tmux isn't running, namely [33]0;w07][[]]u[]@[[]]h[]:[]W[]$ [].



All of my aliases, etc. in my .bash_profile are also functioning as expected. tmux is also displaying colors without incident, as echo -ne "33[1;33m hi" behaves as expected as does gls --color.



The current relevant line in my .bash_profile is export PS1="[33]0;w07][[]]u[]@[[]]h[]:[]W[]$ []", although originally I was sourcing a script located in a .bash_prompt file to handle some conditionals, etc. I tried reverting to the simpler version.



Executing bash will cause the prompt to colorize, but must be done in each pane. export PS1=[that long string I've already posted] will not.



My .tmux.conf is as follows:



set-option -g default-command "reattach-to-user-namespace -l /usr/local/bin/bash"
set -g default-terminal "xterm-256color"
set-window-option -g automatic-rename on
bind '"' split-window -c "#pane_current_path"
bind % split-window -h -c "#pane_current_path"
bind c new-window -c "#pane_current_path"


Relevant portions of .bash_profile:



export TERM="xterm-256color"
if which tmux >/dev/null 2>&1; then
test -z "$TMUX" && (tmux attach || tmux new-session)
fi


I'm using macOS Sierra, iTerm 2, I've tried both the current homebrew version of bash and the system bash (it's currently using the homebrew), tmux 2.4.



I also placed touch testing_touch_from_bash_profile in my .bash_profile while in a tmux session with two panes, killed one pane, opened a pane and verified that the file was in fact created.



echo $TERM returns xterm-256color.



I've ensured that when exiting tmux to test settings changes that I've exited tmux and that no tmux process is currently running on the system via ps -ax | grep tmux.



Oddly, sourcing the .bash_prompt script also changes the color so long as I do it within each tmux pane.



I've looked at https://stackoverflow.com/questions/21005966/tmux-prompt-not-following-normal-bash-prompt-ps1-w and tried adding the --login flag after the bash call in the first line of my .tmux.conf. Launching tmux with tmux new bash will cause the first pane to colorize, but subsequent panes will not.



The $PS1 variable is being honored for seemingly all aspects except colorizing any of the fields.



Anyone have any ideas?







bash osx tmux prompt






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited May 23 '17 at 12:40









Community

1




1










asked Apr 22 '17 at 1:03









J. SagurtonJ. Sagurton

3116




3116












  • Try single quotes

    – Kevin
    Apr 22 '17 at 5:24






  • 4





    The PS1 setting you posted doesn't have any command to change colors. Post an actual setting that does work outside tmux. Also, you should set PS1 in .bashrc, not in .bash_profile: .bash_profile might not get executed at all, and the settings might be overridden later.

    – Gilles
    Apr 22 '17 at 21:42

















  • Try single quotes

    – Kevin
    Apr 22 '17 at 5:24






  • 4





    The PS1 setting you posted doesn't have any command to change colors. Post an actual setting that does work outside tmux. Also, you should set PS1 in .bashrc, not in .bash_profile: .bash_profile might not get executed at all, and the settings might be overridden later.

    – Gilles
    Apr 22 '17 at 21:42
















Try single quotes

– Kevin
Apr 22 '17 at 5:24





Try single quotes

– Kevin
Apr 22 '17 at 5:24




4




4





The PS1 setting you posted doesn't have any command to change colors. Post an actual setting that does work outside tmux. Also, you should set PS1 in .bashrc, not in .bash_profile: .bash_profile might not get executed at all, and the settings might be overridden later.

– Gilles
Apr 22 '17 at 21:42





The PS1 setting you posted doesn't have any command to change colors. Post an actual setting that does work outside tmux. Also, you should set PS1 in .bashrc, not in .bash_profile: .bash_profile might not get executed at all, and the settings might be overridden later.

– Gilles
Apr 22 '17 at 21:42










2 Answers
2






active

oldest

votes


















3














Your PS1 also gives me black and white output.



However switching back to mine gives me color, so you should be able to figure out the different, I use



$ echo $PS1
[33[01;31m]t [33[01;32m]durrantm [33[02;36m]h [33[01;34m]`pwd | sed "s#(/[^/]1,/[^/]1,/[^/]1,/).*(/[^/]1,/[^/]1,)/0,1#1_2#g"` [33[00;33m]$(git_branch)[33[00m]n$


git_branch is a bash function I have which is:



git_branch () sed -e '/^[^*]/d' -e 's/* (.*)/1/'



Yours vs. Mine:



enter image description here



This works the same on OSX and Ubuntu






share|improve this answer
































    0














    My solution to this problem was setting



    force_color_prompt=yes



    in my .bashrc. Now my tmux prompt has color.






    share|improve this answer






















      Your Answer








      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "106"
      ;
      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: false,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      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%2funix.stackexchange.com%2fquestions%2f360545%2ftmux-not-colorizing-ps1-prompt%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      3














      Your PS1 also gives me black and white output.



      However switching back to mine gives me color, so you should be able to figure out the different, I use



      $ echo $PS1
      [33[01;31m]t [33[01;32m]durrantm [33[02;36m]h [33[01;34m]`pwd | sed "s#(/[^/]1,/[^/]1,/[^/]1,/).*(/[^/]1,/[^/]1,)/0,1#1_2#g"` [33[00;33m]$(git_branch)[33[00m]n$


      git_branch is a bash function I have which is:



      git_branch () sed -e '/^[^*]/d' -e 's/* (.*)/1/'



      Yours vs. Mine:



      enter image description here



      This works the same on OSX and Ubuntu






      share|improve this answer





























        3














        Your PS1 also gives me black and white output.



        However switching back to mine gives me color, so you should be able to figure out the different, I use



        $ echo $PS1
        [33[01;31m]t [33[01;32m]durrantm [33[02;36m]h [33[01;34m]`pwd | sed "s#(/[^/]1,/[^/]1,/[^/]1,/).*(/[^/]1,/[^/]1,)/0,1#1_2#g"` [33[00;33m]$(git_branch)[33[00m]n$


        git_branch is a bash function I have which is:



        git_branch () sed -e '/^[^*]/d' -e 's/* (.*)/1/'



        Yours vs. Mine:



        enter image description here



        This works the same on OSX and Ubuntu






        share|improve this answer



























          3












          3








          3







          Your PS1 also gives me black and white output.



          However switching back to mine gives me color, so you should be able to figure out the different, I use



          $ echo $PS1
          [33[01;31m]t [33[01;32m]durrantm [33[02;36m]h [33[01;34m]`pwd | sed "s#(/[^/]1,/[^/]1,/[^/]1,/).*(/[^/]1,/[^/]1,)/0,1#1_2#g"` [33[00;33m]$(git_branch)[33[00m]n$


          git_branch is a bash function I have which is:



          git_branch () sed -e '/^[^*]/d' -e 's/* (.*)/1/'



          Yours vs. Mine:



          enter image description here



          This works the same on OSX and Ubuntu






          share|improve this answer















          Your PS1 also gives me black and white output.



          However switching back to mine gives me color, so you should be able to figure out the different, I use



          $ echo $PS1
          [33[01;31m]t [33[01;32m]durrantm [33[02;36m]h [33[01;34m]`pwd | sed "s#(/[^/]1,/[^/]1,/[^/]1,/).*(/[^/]1,/[^/]1,)/0,1#1_2#g"` [33[00;33m]$(git_branch)[33[00m]n$


          git_branch is a bash function I have which is:



          git_branch () sed -e '/^[^*]/d' -e 's/* (.*)/1/'



          Yours vs. Mine:



          enter image description here



          This works the same on OSX and Ubuntu







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Apr 22 '17 at 1:26

























          answered Apr 22 '17 at 1:19









          Michael DurrantMichael Durrant

          15.9k44117183




          15.9k44117183























              0














              My solution to this problem was setting



              force_color_prompt=yes



              in my .bashrc. Now my tmux prompt has color.






              share|improve this answer



























                0














                My solution to this problem was setting



                force_color_prompt=yes



                in my .bashrc. Now my tmux prompt has color.






                share|improve this answer

























                  0












                  0








                  0







                  My solution to this problem was setting



                  force_color_prompt=yes



                  in my .bashrc. Now my tmux prompt has color.






                  share|improve this answer













                  My solution to this problem was setting



                  force_color_prompt=yes



                  in my .bashrc. Now my tmux prompt has color.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Jan 9 at 14:24









                  PankiPanki

                  603311




                  603311



























                      draft saved

                      draft discarded
















































                      Thanks for contributing an answer to Unix & Linux Stack Exchange!


                      • 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%2funix.stackexchange.com%2fquestions%2f360545%2ftmux-not-colorizing-ps1-prompt%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 to check contact read email or not when send email to Individual?

                      Displaying single band from multi-band raster using QGIS

                      How many registers does an x86_64 CPU actually have?