How can I use the arrow sign in my bash prompt?How can I shorten my command line (bash) prompt?What does “$debian_chroot:+($debian_chroot)” do in my terminal prompt?How can I shorten my command line (bash) prompt?Changing behavior of bash prompt when functioning as rootbash prompt chenged itself to a plain “#”how to fix my keyboard after a bash script messed it upHow to add colored git branch to my bash prompt?Prompt doesn't update git branchtab completion missing, ll not found, logout not foundShell prompt customization and cmd behaviorWrapping lines bugs when trying to colour terminal PS1 (even when escaping non printing caracters)New user, broken bash prompt parsing?

Is it appropriate to ask a job candidate if we can record their interview?

Is HostGator storing my password in plaintext?

Avoiding estate tax by giving multiple gifts

System.debug(JSON.Serialize(o)) Not longer shows full string

Short story about space worker geeks who zone out by 'listening' to radiation from stars

How to pronounce the slash sign

How to Reset Passwords on Multiple Websites Easily?

I'm in charge of equipment buying but no one's ever happy with what I choose. How to fix this?

Is this apparent Class Action settlement a spam message?

Applicability of Single Responsibility Principle

How to safely derail a train during transit?

What is the intuitive meaning of having a linear relationship between the logs of two variables?

Why, precisely, is argon used in neutrino experiments?

What is the difference between "behavior" and "behaviour"?

What happens if you roll doubles 3 times then land on "Go to jail?"

Failed to fetch jessie backports repository

Gears on left are inverse to gears on right?

Was Spock the First Vulcan in Starfleet?

Why didn't Theresa May consult with Parliament before negotiating a deal with the EU?

How can I kill an app using Terminal?

Why not increase contact surface when reentering the atmosphere?

How to check is there any negative term in a large list?

Would this custom Sorcerer variant that can only learn any verbal-component-only spell be unbalanced?

How can I get through very long and very dry, but also very useful technical documents when learning a new tool?



How can I use the arrow sign in my bash prompt?


How can I shorten my command line (bash) prompt?What does “$debian_chroot:+($debian_chroot)” do in my terminal prompt?How can I shorten my command line (bash) prompt?Changing behavior of bash prompt when functioning as rootbash prompt chenged itself to a plain “#”how to fix my keyboard after a bash script messed it upHow to add colored git branch to my bash prompt?Prompt doesn't update git branchtab completion missing, ll not found, logout not foundShell prompt customization and cmd behaviorWrapping lines bugs when trying to colour terminal PS1 (even when escaping non printing caracters)New user, broken bash prompt parsing?













14















How can I use these red and green arrow signs in the bash prompt?



enter image description here



update 1



This is my .bashrc file



if [ "$color_prompt" = yes ]; then
PS1='$debian_chroot:+($debian_chroot)[33[01;32m][33[00m]
[33[01;34m]→ w[33[00m]$ '
else
PS1='$debian_chroot:+($debian_chroot)→ w$ '
fi
unset color_prompt force_color_prompt


I want this arrow to be colored as @dessert answered before
(turn red and green for false and true command )










share|improve this question




























    14















    How can I use these red and green arrow signs in the bash prompt?



    enter image description here



    update 1



    This is my .bashrc file



    if [ "$color_prompt" = yes ]; then
    PS1='$debian_chroot:+($debian_chroot)[33[01;32m][33[00m]
    [33[01;34m]→ w[33[00m]$ '
    else
    PS1='$debian_chroot:+($debian_chroot)→ w$ '
    fi
    unset color_prompt force_color_prompt


    I want this arrow to be colored as @dessert answered before
    (turn red and green for false and true command )










    share|improve this question


























      14












      14








      14


      2






      How can I use these red and green arrow signs in the bash prompt?



      enter image description here



      update 1



      This is my .bashrc file



      if [ "$color_prompt" = yes ]; then
      PS1='$debian_chroot:+($debian_chroot)[33[01;32m][33[00m]
      [33[01;34m]→ w[33[00m]$ '
      else
      PS1='$debian_chroot:+($debian_chroot)→ w$ '
      fi
      unset color_prompt force_color_prompt


      I want this arrow to be colored as @dessert answered before
      (turn red and green for false and true command )










      share|improve this question
















      How can I use these red and green arrow signs in the bash prompt?



      enter image description here



      update 1



      This is my .bashrc file



      if [ "$color_prompt" = yes ]; then
      PS1='$debian_chroot:+($debian_chroot)[33[01;32m][33[00m]
      [33[01;34m]→ w[33[00m]$ '
      else
      PS1='$debian_chroot:+($debian_chroot)→ w$ '
      fi
      unset color_prompt force_color_prompt


      I want this arrow to be colored as @dessert answered before
      (turn red and green for false and true command )







      bash bashrc prompt






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited yesterday







      Afshin

















      asked yesterday









      AfshinAfshin

      10010




      10010




















          1 Answer
          1






          active

          oldest

          votes


















          21














          You can use bash’s PROMPT_COMMAND to run a function which builds your prompt, e.g.:



          PROMPT_COMMAND=build_prompt

          build_prompt()
          EXIT=$? # save exit code of last command
          red='[e[0;31m]' # colors
          green='[e[0;32m]'
          cyan='[e[1;36m]'
          reset='[e[0m]'
          PS1='$debian_chroot:+($debian_chroot)' # begin prompt

          if [ $EXIT != 0 ]; then # add arrow color dependent on exit code
          PS1+="$red"
          else
          PS1+="$green"
          fi

          PS1+="→$reset $cyanw$reset $ " # construct rest of prompt



          Add this code to your ~/.bashrc file and open a new terminal or run . ~/.bashrc in an existing one for the changes to take effect. Note that I added the usual $ at the end, this prints $ normally and # if you’re root, thus preventing you from running commands as root unwittingly. The false command is a good way to test the non-zero exit code variant:



          result



          If you’re into prompt themeing you should definitely take a look at the zsh shell (package zsh), whose famous configuration framework Oh My Zsh alone comes with over hundred themes. Additionally there are many other plugins available, for example the Spaceship ZSH prompt.



          Links



          • How can I shorten my command line (bash) prompt?

          • Bash Prompt with Last Exit Code

          • Easy Bash PS1 Generator

          • Bash tips: Colors and formatting

          • What color codes can I use in my PS1 prompt?

          • What does "$debian_chroot:+($debian_chroot)" do in my terminal prompt?





          share|improve this answer

























          • Hey man. This idea is crazy fascinating. I came up with the exotic idea awhile back to use ϟ for my prompt instead of $ only when in a Unicode environment, which I'm frequently not.

            – Joshua
            yesterday






          • 1





            While this is a great plain-bash solution, you could take a look at zsh (as a replacement of bash) and especially the Spaceship prompt

            – Richard de Wit
            21 hours ago












          • @RicharddeWit Thats a nice find ! I was running on ZSH but never came across the "Spaceship" prompt. Sweet looking minimalistic prompt.

            – GoodSp33d
            19 hours ago











          • @RicharddeWit Thanks, I added that!

            – dessert
            19 hours ago










          Your Answer








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

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

          else
          createEditor();

          );

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



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1128757%2fhow-can-i-use-the-arrow-sign-in-my-bash-prompt%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          21














          You can use bash’s PROMPT_COMMAND to run a function which builds your prompt, e.g.:



          PROMPT_COMMAND=build_prompt

          build_prompt()
          EXIT=$? # save exit code of last command
          red='[e[0;31m]' # colors
          green='[e[0;32m]'
          cyan='[e[1;36m]'
          reset='[e[0m]'
          PS1='$debian_chroot:+($debian_chroot)' # begin prompt

          if [ $EXIT != 0 ]; then # add arrow color dependent on exit code
          PS1+="$red"
          else
          PS1+="$green"
          fi

          PS1+="→$reset $cyanw$reset $ " # construct rest of prompt



          Add this code to your ~/.bashrc file and open a new terminal or run . ~/.bashrc in an existing one for the changes to take effect. Note that I added the usual $ at the end, this prints $ normally and # if you’re root, thus preventing you from running commands as root unwittingly. The false command is a good way to test the non-zero exit code variant:



          result



          If you’re into prompt themeing you should definitely take a look at the zsh shell (package zsh), whose famous configuration framework Oh My Zsh alone comes with over hundred themes. Additionally there are many other plugins available, for example the Spaceship ZSH prompt.



          Links



          • How can I shorten my command line (bash) prompt?

          • Bash Prompt with Last Exit Code

          • Easy Bash PS1 Generator

          • Bash tips: Colors and formatting

          • What color codes can I use in my PS1 prompt?

          • What does "$debian_chroot:+($debian_chroot)" do in my terminal prompt?





          share|improve this answer

























          • Hey man. This idea is crazy fascinating. I came up with the exotic idea awhile back to use ϟ for my prompt instead of $ only when in a Unicode environment, which I'm frequently not.

            – Joshua
            yesterday






          • 1





            While this is a great plain-bash solution, you could take a look at zsh (as a replacement of bash) and especially the Spaceship prompt

            – Richard de Wit
            21 hours ago












          • @RicharddeWit Thats a nice find ! I was running on ZSH but never came across the "Spaceship" prompt. Sweet looking minimalistic prompt.

            – GoodSp33d
            19 hours ago











          • @RicharddeWit Thanks, I added that!

            – dessert
            19 hours ago















          21














          You can use bash’s PROMPT_COMMAND to run a function which builds your prompt, e.g.:



          PROMPT_COMMAND=build_prompt

          build_prompt()
          EXIT=$? # save exit code of last command
          red='[e[0;31m]' # colors
          green='[e[0;32m]'
          cyan='[e[1;36m]'
          reset='[e[0m]'
          PS1='$debian_chroot:+($debian_chroot)' # begin prompt

          if [ $EXIT != 0 ]; then # add arrow color dependent on exit code
          PS1+="$red"
          else
          PS1+="$green"
          fi

          PS1+="→$reset $cyanw$reset $ " # construct rest of prompt



          Add this code to your ~/.bashrc file and open a new terminal or run . ~/.bashrc in an existing one for the changes to take effect. Note that I added the usual $ at the end, this prints $ normally and # if you’re root, thus preventing you from running commands as root unwittingly. The false command is a good way to test the non-zero exit code variant:



          result



          If you’re into prompt themeing you should definitely take a look at the zsh shell (package zsh), whose famous configuration framework Oh My Zsh alone comes with over hundred themes. Additionally there are many other plugins available, for example the Spaceship ZSH prompt.



          Links



          • How can I shorten my command line (bash) prompt?

          • Bash Prompt with Last Exit Code

          • Easy Bash PS1 Generator

          • Bash tips: Colors and formatting

          • What color codes can I use in my PS1 prompt?

          • What does "$debian_chroot:+($debian_chroot)" do in my terminal prompt?





          share|improve this answer

























          • Hey man. This idea is crazy fascinating. I came up with the exotic idea awhile back to use ϟ for my prompt instead of $ only when in a Unicode environment, which I'm frequently not.

            – Joshua
            yesterday






          • 1





            While this is a great plain-bash solution, you could take a look at zsh (as a replacement of bash) and especially the Spaceship prompt

            – Richard de Wit
            21 hours ago












          • @RicharddeWit Thats a nice find ! I was running on ZSH but never came across the "Spaceship" prompt. Sweet looking minimalistic prompt.

            – GoodSp33d
            19 hours ago











          • @RicharddeWit Thanks, I added that!

            – dessert
            19 hours ago













          21












          21








          21







          You can use bash’s PROMPT_COMMAND to run a function which builds your prompt, e.g.:



          PROMPT_COMMAND=build_prompt

          build_prompt()
          EXIT=$? # save exit code of last command
          red='[e[0;31m]' # colors
          green='[e[0;32m]'
          cyan='[e[1;36m]'
          reset='[e[0m]'
          PS1='$debian_chroot:+($debian_chroot)' # begin prompt

          if [ $EXIT != 0 ]; then # add arrow color dependent on exit code
          PS1+="$red"
          else
          PS1+="$green"
          fi

          PS1+="→$reset $cyanw$reset $ " # construct rest of prompt



          Add this code to your ~/.bashrc file and open a new terminal or run . ~/.bashrc in an existing one for the changes to take effect. Note that I added the usual $ at the end, this prints $ normally and # if you’re root, thus preventing you from running commands as root unwittingly. The false command is a good way to test the non-zero exit code variant:



          result



          If you’re into prompt themeing you should definitely take a look at the zsh shell (package zsh), whose famous configuration framework Oh My Zsh alone comes with over hundred themes. Additionally there are many other plugins available, for example the Spaceship ZSH prompt.



          Links



          • How can I shorten my command line (bash) prompt?

          • Bash Prompt with Last Exit Code

          • Easy Bash PS1 Generator

          • Bash tips: Colors and formatting

          • What color codes can I use in my PS1 prompt?

          • What does "$debian_chroot:+($debian_chroot)" do in my terminal prompt?





          share|improve this answer















          You can use bash’s PROMPT_COMMAND to run a function which builds your prompt, e.g.:



          PROMPT_COMMAND=build_prompt

          build_prompt()
          EXIT=$? # save exit code of last command
          red='[e[0;31m]' # colors
          green='[e[0;32m]'
          cyan='[e[1;36m]'
          reset='[e[0m]'
          PS1='$debian_chroot:+($debian_chroot)' # begin prompt

          if [ $EXIT != 0 ]; then # add arrow color dependent on exit code
          PS1+="$red"
          else
          PS1+="$green"
          fi

          PS1+="→$reset $cyanw$reset $ " # construct rest of prompt



          Add this code to your ~/.bashrc file and open a new terminal or run . ~/.bashrc in an existing one for the changes to take effect. Note that I added the usual $ at the end, this prints $ normally and # if you’re root, thus preventing you from running commands as root unwittingly. The false command is a good way to test the non-zero exit code variant:



          result



          If you’re into prompt themeing you should definitely take a look at the zsh shell (package zsh), whose famous configuration framework Oh My Zsh alone comes with over hundred themes. Additionally there are many other plugins available, for example the Spaceship ZSH prompt.



          Links



          • How can I shorten my command line (bash) prompt?

          • Bash Prompt with Last Exit Code

          • Easy Bash PS1 Generator

          • Bash tips: Colors and formatting

          • What color codes can I use in my PS1 prompt?

          • What does "$debian_chroot:+($debian_chroot)" do in my terminal prompt?






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 19 hours ago

























          answered yesterday









          dessertdessert

          25.1k673106




          25.1k673106












          • Hey man. This idea is crazy fascinating. I came up with the exotic idea awhile back to use ϟ for my prompt instead of $ only when in a Unicode environment, which I'm frequently not.

            – Joshua
            yesterday






          • 1





            While this is a great plain-bash solution, you could take a look at zsh (as a replacement of bash) and especially the Spaceship prompt

            – Richard de Wit
            21 hours ago












          • @RicharddeWit Thats a nice find ! I was running on ZSH but never came across the "Spaceship" prompt. Sweet looking minimalistic prompt.

            – GoodSp33d
            19 hours ago











          • @RicharddeWit Thanks, I added that!

            – dessert
            19 hours ago

















          • Hey man. This idea is crazy fascinating. I came up with the exotic idea awhile back to use ϟ for my prompt instead of $ only when in a Unicode environment, which I'm frequently not.

            – Joshua
            yesterday






          • 1





            While this is a great plain-bash solution, you could take a look at zsh (as a replacement of bash) and especially the Spaceship prompt

            – Richard de Wit
            21 hours ago












          • @RicharddeWit Thats a nice find ! I was running on ZSH but never came across the "Spaceship" prompt. Sweet looking minimalistic prompt.

            – GoodSp33d
            19 hours ago











          • @RicharddeWit Thanks, I added that!

            – dessert
            19 hours ago
















          Hey man. This idea is crazy fascinating. I came up with the exotic idea awhile back to use ϟ for my prompt instead of $ only when in a Unicode environment, which I'm frequently not.

          – Joshua
          yesterday





          Hey man. This idea is crazy fascinating. I came up with the exotic idea awhile back to use ϟ for my prompt instead of $ only when in a Unicode environment, which I'm frequently not.

          – Joshua
          yesterday




          1




          1





          While this is a great plain-bash solution, you could take a look at zsh (as a replacement of bash) and especially the Spaceship prompt

          – Richard de Wit
          21 hours ago






          While this is a great plain-bash solution, you could take a look at zsh (as a replacement of bash) and especially the Spaceship prompt

          – Richard de Wit
          21 hours ago














          @RicharddeWit Thats a nice find ! I was running on ZSH but never came across the "Spaceship" prompt. Sweet looking minimalistic prompt.

          – GoodSp33d
          19 hours ago





          @RicharddeWit Thats a nice find ! I was running on ZSH but never came across the "Spaceship" prompt. Sweet looking minimalistic prompt.

          – GoodSp33d
          19 hours ago













          @RicharddeWit Thanks, I added that!

          – dessert
          19 hours ago





          @RicharddeWit Thanks, I added that!

          – dessert
          19 hours ago

















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Ask Ubuntu!


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

          But avoid


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

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

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




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1128757%2fhow-can-i-use-the-arrow-sign-in-my-bash-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

          Triangular numbers and gcdProving sum of a set is $0 pmod n$ if $n$ is odd, or $fracn2 pmod n$ if $n$ is even?Is greatest common divisor of two numbers really their smallest linear combination?GCD, LCM RelationshipProve a set of nonnegative integers with greatest common divisor 1 and closed under addition has all but finite many nonnegative integers.all pairs of a and b in an equation containing gcdTriangular Numbers Modulo $k$ - Hit All Values?Understanding the Existence and Uniqueness of the GCDGCD and LCM with logical symbolsThe greatest common divisor of two positive integers less than 100 is equal to 3. Their least common multiple is twelve times one of the integers.Suppose that for all integers $x$, $x|a$ and $x|b$ if and only if $x|c$. Then $c = gcd(a,b)$Which is the gcd of 2 numbers which are multiplied and the result is 600000?

          Ingelân Ynhâld Etymology | Geografy | Skiednis | Polityk en bestjoer | Ekonomy | Demografy | Kultuer | Klimaat | Sjoch ek | Keppelings om utens | Boarnen, noaten en referinsjes Navigaasjemenuwww.gov.ukOffisjele webside fan it regear fan it Feriene KeninkrykOffisjele webside fan it Britske FerkearsburoNederlânsktalige ynformaasje fan it Britske FerkearsburoOffisjele webside fan English Heritage, de organisaasje dy't him ynset foar it behâld fan it Ingelske kultuergoedYnwennertallen fan alle Britske stêden út 'e folkstelling fan 2011Notes en References, op dizze sideEngland

          Հադիս Բովանդակություն Անվանում և նշանակություն | Դասակարգում | Աղբյուրներ | Նավարկման ցանկ