Change Cygwin Prompt












17















The default cygwin prompt of "user@computer path n $" is too long for me. I would like to keep the path.



I want it to become:



path $



Is there a config file I can modify to do this?










share|improve this question

























  • Possible duplicate of Is it possible to change my terminal window prompt text?

    – phuclv
    Sep 8 '18 at 9:08











  • How to change the format of the bash prompt?

    – phuclv
    Sep 8 '18 at 9:09
















17















The default cygwin prompt of "user@computer path n $" is too long for me. I would like to keep the path.



I want it to become:



path $



Is there a config file I can modify to do this?










share|improve this question

























  • Possible duplicate of Is it possible to change my terminal window prompt text?

    – phuclv
    Sep 8 '18 at 9:08











  • How to change the format of the bash prompt?

    – phuclv
    Sep 8 '18 at 9:09














17












17








17


6






The default cygwin prompt of "user@computer path n $" is too long for me. I would like to keep the path.



I want it to become:



path $



Is there a config file I can modify to do this?










share|improve this question
















The default cygwin prompt of "user@computer path n $" is too long for me. I would like to keep the path.



I want it to become:



path $



Is there a config file I can modify to do this?







cygwin






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jul 17 '09 at 1:05







Cristian

















asked Jul 17 '09 at 0:59









CristianCristian

228149




228149













  • Possible duplicate of Is it possible to change my terminal window prompt text?

    – phuclv
    Sep 8 '18 at 9:08











  • How to change the format of the bash prompt?

    – phuclv
    Sep 8 '18 at 9:09



















  • Possible duplicate of Is it possible to change my terminal window prompt text?

    – phuclv
    Sep 8 '18 at 9:08











  • How to change the format of the bash prompt?

    – phuclv
    Sep 8 '18 at 9:09

















Possible duplicate of Is it possible to change my terminal window prompt text?

– phuclv
Sep 8 '18 at 9:08





Possible duplicate of Is it possible to change my terminal window prompt text?

– phuclv
Sep 8 '18 at 9:08













How to change the format of the bash prompt?

– phuclv
Sep 8 '18 at 9:09





How to change the format of the bash prompt?

– phuclv
Sep 8 '18 at 9:09










5 Answers
5






active

oldest

votes


















26














The PS1 environment variable controls the prompt:



PS1='w $ '


For more information on this and other prompt configuration topics, type man bash (assuming bash is your shell) and see the "PROMPTING" section.



To make this change permanent, edit your ~/.bashrc file to add the above line.






share|improve this answer





















  • 1





    ~/.bashrc does not get executed for a login shell. update ~/.bash_profile instead. I use the following prompt string, which has some other useful information, not just the path: PS1='[e[32m]t [e[33m]w [e[31m]! [e[0m]$ '

    – bobmcn
    Aug 26 '09 at 20:16











  • Don't forget that normally .profile sources .bashrc, so that in effect, a login shell is initialized with the same stuff than a non-login shell plus what's in .profile. If that's the case, putting your new prompt in .bashrc kills two birds with one stone.

    – user290253
    Jan 15 '14 at 14:06



















1














A login shell is one whose first character of argument zero is a -, or one started with the --login option.
When bash is invoked as an interactive login shell, or as a non-interactive shell with the --login option, it first reads and executes commands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable. The --noprofile option may be used when the shell is started to inhibit this behavior
When an interactive shell that is not a login shell is started, bash reads and executes commands from ~/.bashrc, if that file exists.



So it depends...i dont't use the --login, so i must add it to ~/.bashrc






share|improve this answer































    1














    Not sure why having less context is better than having more...
    The fact that there is a new line in the prompt means the length of the prompt should not be an issue, but try this:



    PS1='[e[1;33m]wn[e[1;36m]$[e[0m] '


    or



    export PS1='[e[1;33m]wn[e[1;36m]$[e[0m] '


    This gives you a coloured prompt:



    /full/path/to/current/folder
    $your command text here


    That way, you always see your full folder context but still get a full line to input text. (I left out the customary space following the '$' because it's coloured for clarity).



    Colours are:
    1. '/full/path/...' = yellow;
    2. '$' (on next line) = cyan;
    3. 'your command text...' = light grey.


    For those who DO want the 'user@hostname ' context too:



    PS1='[e[1;32m]u[e[1;35m]@[e[1;32m]h [e[1;33m]wn[e[1;36m]$[e[0m] '


    or



    export PS1='[e[1;32m]u[e[1;35m]@[e[1;32m]h [e[1;33m]wn[e[1;36m]$[e[0m] '


    This gives you a coloured prompt:



    user@hostname /full/path/to/current/folder
    $your command text here


    This is my preference.



    Colours are:
    1. 'user' = (light) green;
    2. '@' = pink;
    3. 'hostname' = (light) green;
    4. '/full/path/...' = yellow;
    5. '$' (on next line) = cyan;
    6. 'your command text...' = light grey.


    (No, there are no spelling mistakes in this post - Queen's English ;) )






    share|improve this answer































      1














      .bashrc didn't work for me. I added this to the end of /etc/profile and it worked:



      export PS1="[e[33m]w[e[0m] $ "


      I'm using Cygwin version 2.11.2 (latest version as of 2018-12-18).






      share|improve this answer































        0














        Put this in your ~/.bashrc. Gives a coloured prompt and keeps the status in a single line.



        export PS1="[e]0;wa]n[e[32m]u@h [e[33m]w[e[0m]$ "





        share|improve this answer























          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%2f6522%2fchange-cygwin-prompt%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          5 Answers
          5






          active

          oldest

          votes








          5 Answers
          5






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          26














          The PS1 environment variable controls the prompt:



          PS1='w $ '


          For more information on this and other prompt configuration topics, type man bash (assuming bash is your shell) and see the "PROMPTING" section.



          To make this change permanent, edit your ~/.bashrc file to add the above line.






          share|improve this answer





















          • 1





            ~/.bashrc does not get executed for a login shell. update ~/.bash_profile instead. I use the following prompt string, which has some other useful information, not just the path: PS1='[e[32m]t [e[33m]w [e[31m]! [e[0m]$ '

            – bobmcn
            Aug 26 '09 at 20:16











          • Don't forget that normally .profile sources .bashrc, so that in effect, a login shell is initialized with the same stuff than a non-login shell plus what's in .profile. If that's the case, putting your new prompt in .bashrc kills two birds with one stone.

            – user290253
            Jan 15 '14 at 14:06
















          26














          The PS1 environment variable controls the prompt:



          PS1='w $ '


          For more information on this and other prompt configuration topics, type man bash (assuming bash is your shell) and see the "PROMPTING" section.



          To make this change permanent, edit your ~/.bashrc file to add the above line.






          share|improve this answer





















          • 1





            ~/.bashrc does not get executed for a login shell. update ~/.bash_profile instead. I use the following prompt string, which has some other useful information, not just the path: PS1='[e[32m]t [e[33m]w [e[31m]! [e[0m]$ '

            – bobmcn
            Aug 26 '09 at 20:16











          • Don't forget that normally .profile sources .bashrc, so that in effect, a login shell is initialized with the same stuff than a non-login shell plus what's in .profile. If that's the case, putting your new prompt in .bashrc kills two birds with one stone.

            – user290253
            Jan 15 '14 at 14:06














          26












          26








          26







          The PS1 environment variable controls the prompt:



          PS1='w $ '


          For more information on this and other prompt configuration topics, type man bash (assuming bash is your shell) and see the "PROMPTING" section.



          To make this change permanent, edit your ~/.bashrc file to add the above line.






          share|improve this answer















          The PS1 environment variable controls the prompt:



          PS1='w $ '


          For more information on this and other prompt configuration topics, type man bash (assuming bash is your shell) and see the "PROMPTING" section.



          To make this change permanent, edit your ~/.bashrc file to add the above line.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Jul 17 '09 at 1:07

























          answered Jul 17 '09 at 1:01









          Greg HewgillGreg Hewgill

          4,88922127




          4,88922127








          • 1





            ~/.bashrc does not get executed for a login shell. update ~/.bash_profile instead. I use the following prompt string, which has some other useful information, not just the path: PS1='[e[32m]t [e[33m]w [e[31m]! [e[0m]$ '

            – bobmcn
            Aug 26 '09 at 20:16











          • Don't forget that normally .profile sources .bashrc, so that in effect, a login shell is initialized with the same stuff than a non-login shell plus what's in .profile. If that's the case, putting your new prompt in .bashrc kills two birds with one stone.

            – user290253
            Jan 15 '14 at 14:06














          • 1





            ~/.bashrc does not get executed for a login shell. update ~/.bash_profile instead. I use the following prompt string, which has some other useful information, not just the path: PS1='[e[32m]t [e[33m]w [e[31m]! [e[0m]$ '

            – bobmcn
            Aug 26 '09 at 20:16











          • Don't forget that normally .profile sources .bashrc, so that in effect, a login shell is initialized with the same stuff than a non-login shell plus what's in .profile. If that's the case, putting your new prompt in .bashrc kills two birds with one stone.

            – user290253
            Jan 15 '14 at 14:06








          1




          1





          ~/.bashrc does not get executed for a login shell. update ~/.bash_profile instead. I use the following prompt string, which has some other useful information, not just the path: PS1='[e[32m]t [e[33m]w [e[31m]! [e[0m]$ '

          – bobmcn
          Aug 26 '09 at 20:16





          ~/.bashrc does not get executed for a login shell. update ~/.bash_profile instead. I use the following prompt string, which has some other useful information, not just the path: PS1='[e[32m]t [e[33m]w [e[31m]! [e[0m]$ '

          – bobmcn
          Aug 26 '09 at 20:16













          Don't forget that normally .profile sources .bashrc, so that in effect, a login shell is initialized with the same stuff than a non-login shell plus what's in .profile. If that's the case, putting your new prompt in .bashrc kills two birds with one stone.

          – user290253
          Jan 15 '14 at 14:06





          Don't forget that normally .profile sources .bashrc, so that in effect, a login shell is initialized with the same stuff than a non-login shell plus what's in .profile. If that's the case, putting your new prompt in .bashrc kills two birds with one stone.

          – user290253
          Jan 15 '14 at 14:06













          1














          A login shell is one whose first character of argument zero is a -, or one started with the --login option.
          When bash is invoked as an interactive login shell, or as a non-interactive shell with the --login option, it first reads and executes commands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable. The --noprofile option may be used when the shell is started to inhibit this behavior
          When an interactive shell that is not a login shell is started, bash reads and executes commands from ~/.bashrc, if that file exists.



          So it depends...i dont't use the --login, so i must add it to ~/.bashrc






          share|improve this answer




























            1














            A login shell is one whose first character of argument zero is a -, or one started with the --login option.
            When bash is invoked as an interactive login shell, or as a non-interactive shell with the --login option, it first reads and executes commands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable. The --noprofile option may be used when the shell is started to inhibit this behavior
            When an interactive shell that is not a login shell is started, bash reads and executes commands from ~/.bashrc, if that file exists.



            So it depends...i dont't use the --login, so i must add it to ~/.bashrc






            share|improve this answer


























              1












              1








              1







              A login shell is one whose first character of argument zero is a -, or one started with the --login option.
              When bash is invoked as an interactive login shell, or as a non-interactive shell with the --login option, it first reads and executes commands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable. The --noprofile option may be used when the shell is started to inhibit this behavior
              When an interactive shell that is not a login shell is started, bash reads and executes commands from ~/.bashrc, if that file exists.



              So it depends...i dont't use the --login, so i must add it to ~/.bashrc






              share|improve this answer













              A login shell is one whose first character of argument zero is a -, or one started with the --login option.
              When bash is invoked as an interactive login shell, or as a non-interactive shell with the --login option, it first reads and executes commands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable. The --noprofile option may be used when the shell is started to inhibit this behavior
              When an interactive shell that is not a login shell is started, bash reads and executes commands from ~/.bashrc, if that file exists.



              So it depends...i dont't use the --login, so i must add it to ~/.bashrc







              share|improve this answer












              share|improve this answer



              share|improve this answer










              answered Mar 18 '13 at 9:53









              jr00njr00n

              111




              111























                  1














                  Not sure why having less context is better than having more...
                  The fact that there is a new line in the prompt means the length of the prompt should not be an issue, but try this:



                  PS1='[e[1;33m]wn[e[1;36m]$[e[0m] '


                  or



                  export PS1='[e[1;33m]wn[e[1;36m]$[e[0m] '


                  This gives you a coloured prompt:



                  /full/path/to/current/folder
                  $your command text here


                  That way, you always see your full folder context but still get a full line to input text. (I left out the customary space following the '$' because it's coloured for clarity).



                  Colours are:
                  1. '/full/path/...' = yellow;
                  2. '$' (on next line) = cyan;
                  3. 'your command text...' = light grey.


                  For those who DO want the 'user@hostname ' context too:



                  PS1='[e[1;32m]u[e[1;35m]@[e[1;32m]h [e[1;33m]wn[e[1;36m]$[e[0m] '


                  or



                  export PS1='[e[1;32m]u[e[1;35m]@[e[1;32m]h [e[1;33m]wn[e[1;36m]$[e[0m] '


                  This gives you a coloured prompt:



                  user@hostname /full/path/to/current/folder
                  $your command text here


                  This is my preference.



                  Colours are:
                  1. 'user' = (light) green;
                  2. '@' = pink;
                  3. 'hostname' = (light) green;
                  4. '/full/path/...' = yellow;
                  5. '$' (on next line) = cyan;
                  6. 'your command text...' = light grey.


                  (No, there are no spelling mistakes in this post - Queen's English ;) )






                  share|improve this answer




























                    1














                    Not sure why having less context is better than having more...
                    The fact that there is a new line in the prompt means the length of the prompt should not be an issue, but try this:



                    PS1='[e[1;33m]wn[e[1;36m]$[e[0m] '


                    or



                    export PS1='[e[1;33m]wn[e[1;36m]$[e[0m] '


                    This gives you a coloured prompt:



                    /full/path/to/current/folder
                    $your command text here


                    That way, you always see your full folder context but still get a full line to input text. (I left out the customary space following the '$' because it's coloured for clarity).



                    Colours are:
                    1. '/full/path/...' = yellow;
                    2. '$' (on next line) = cyan;
                    3. 'your command text...' = light grey.


                    For those who DO want the 'user@hostname ' context too:



                    PS1='[e[1;32m]u[e[1;35m]@[e[1;32m]h [e[1;33m]wn[e[1;36m]$[e[0m] '


                    or



                    export PS1='[e[1;32m]u[e[1;35m]@[e[1;32m]h [e[1;33m]wn[e[1;36m]$[e[0m] '


                    This gives you a coloured prompt:



                    user@hostname /full/path/to/current/folder
                    $your command text here


                    This is my preference.



                    Colours are:
                    1. 'user' = (light) green;
                    2. '@' = pink;
                    3. 'hostname' = (light) green;
                    4. '/full/path/...' = yellow;
                    5. '$' (on next line) = cyan;
                    6. 'your command text...' = light grey.


                    (No, there are no spelling mistakes in this post - Queen's English ;) )






                    share|improve this answer


























                      1












                      1








                      1







                      Not sure why having less context is better than having more...
                      The fact that there is a new line in the prompt means the length of the prompt should not be an issue, but try this:



                      PS1='[e[1;33m]wn[e[1;36m]$[e[0m] '


                      or



                      export PS1='[e[1;33m]wn[e[1;36m]$[e[0m] '


                      This gives you a coloured prompt:



                      /full/path/to/current/folder
                      $your command text here


                      That way, you always see your full folder context but still get a full line to input text. (I left out the customary space following the '$' because it's coloured for clarity).



                      Colours are:
                      1. '/full/path/...' = yellow;
                      2. '$' (on next line) = cyan;
                      3. 'your command text...' = light grey.


                      For those who DO want the 'user@hostname ' context too:



                      PS1='[e[1;32m]u[e[1;35m]@[e[1;32m]h [e[1;33m]wn[e[1;36m]$[e[0m] '


                      or



                      export PS1='[e[1;32m]u[e[1;35m]@[e[1;32m]h [e[1;33m]wn[e[1;36m]$[e[0m] '


                      This gives you a coloured prompt:



                      user@hostname /full/path/to/current/folder
                      $your command text here


                      This is my preference.



                      Colours are:
                      1. 'user' = (light) green;
                      2. '@' = pink;
                      3. 'hostname' = (light) green;
                      4. '/full/path/...' = yellow;
                      5. '$' (on next line) = cyan;
                      6. 'your command text...' = light grey.


                      (No, there are no spelling mistakes in this post - Queen's English ;) )






                      share|improve this answer













                      Not sure why having less context is better than having more...
                      The fact that there is a new line in the prompt means the length of the prompt should not be an issue, but try this:



                      PS1='[e[1;33m]wn[e[1;36m]$[e[0m] '


                      or



                      export PS1='[e[1;33m]wn[e[1;36m]$[e[0m] '


                      This gives you a coloured prompt:



                      /full/path/to/current/folder
                      $your command text here


                      That way, you always see your full folder context but still get a full line to input text. (I left out the customary space following the '$' because it's coloured for clarity).



                      Colours are:
                      1. '/full/path/...' = yellow;
                      2. '$' (on next line) = cyan;
                      3. 'your command text...' = light grey.


                      For those who DO want the 'user@hostname ' context too:



                      PS1='[e[1;32m]u[e[1;35m]@[e[1;32m]h [e[1;33m]wn[e[1;36m]$[e[0m] '


                      or



                      export PS1='[e[1;32m]u[e[1;35m]@[e[1;32m]h [e[1;33m]wn[e[1;36m]$[e[0m] '


                      This gives you a coloured prompt:



                      user@hostname /full/path/to/current/folder
                      $your command text here


                      This is my preference.



                      Colours are:
                      1. 'user' = (light) green;
                      2. '@' = pink;
                      3. 'hostname' = (light) green;
                      4. '/full/path/...' = yellow;
                      5. '$' (on next line) = cyan;
                      6. 'your command text...' = light grey.


                      (No, there are no spelling mistakes in this post - Queen's English ;) )







                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered Jan 16 '17 at 9:49









                      skeetastaxskeetastax

                      714




                      714























                          1














                          .bashrc didn't work for me. I added this to the end of /etc/profile and it worked:



                          export PS1="[e[33m]w[e[0m] $ "


                          I'm using Cygwin version 2.11.2 (latest version as of 2018-12-18).






                          share|improve this answer




























                            1














                            .bashrc didn't work for me. I added this to the end of /etc/profile and it worked:



                            export PS1="[e[33m]w[e[0m] $ "


                            I'm using Cygwin version 2.11.2 (latest version as of 2018-12-18).






                            share|improve this answer


























                              1












                              1








                              1







                              .bashrc didn't work for me. I added this to the end of /etc/profile and it worked:



                              export PS1="[e[33m]w[e[0m] $ "


                              I'm using Cygwin version 2.11.2 (latest version as of 2018-12-18).






                              share|improve this answer













                              .bashrc didn't work for me. I added this to the end of /etc/profile and it worked:



                              export PS1="[e[33m]w[e[0m] $ "


                              I'm using Cygwin version 2.11.2 (latest version as of 2018-12-18).







                              share|improve this answer












                              share|improve this answer



                              share|improve this answer










                              answered Dec 18 '18 at 21:23









                              SamuelSamuel

                              1135




                              1135























                                  0














                                  Put this in your ~/.bashrc. Gives a coloured prompt and keeps the status in a single line.



                                  export PS1="[e]0;wa]n[e[32m]u@h [e[33m]w[e[0m]$ "





                                  share|improve this answer




























                                    0














                                    Put this in your ~/.bashrc. Gives a coloured prompt and keeps the status in a single line.



                                    export PS1="[e]0;wa]n[e[32m]u@h [e[33m]w[e[0m]$ "





                                    share|improve this answer


























                                      0












                                      0








                                      0







                                      Put this in your ~/.bashrc. Gives a coloured prompt and keeps the status in a single line.



                                      export PS1="[e]0;wa]n[e[32m]u@h [e[33m]w[e[0m]$ "





                                      share|improve this answer













                                      Put this in your ~/.bashrc. Gives a coloured prompt and keeps the status in a single line.



                                      export PS1="[e]0;wa]n[e[32m]u@h [e[33m]w[e[0m]$ "






                                      share|improve this answer












                                      share|improve this answer



                                      share|improve this answer










                                      answered May 13 '16 at 13:51









                                      SandeepSandeep

                                      1011




                                      1011






























                                          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%2f6522%2fchange-cygwin-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

                                          Terni

                                          A new problem with tex4ht and tikz

                                          Sun Ra