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












13















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





























    13















    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



























      13












      13








      13


      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 11 hours ago







      Afshin

















      asked 19 hours ago









      AfshinAfshin

      959




      959






















          1 Answer
          1






          active

          oldest

          votes


















          18














          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



          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
            2 mins 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









          18














          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



          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
            2 mins ago
















          18














          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



          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
            2 mins ago














          18












          18








          18







          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



          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



          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 8 hours ago









          Digital Trauma

          2,076619




          2,076619










          answered 18 hours ago









          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
            2 mins 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
            2 mins 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
          2 mins 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
          2 mins 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

          He _____ here since 1970 . Answer needed [closed]What does “since he was so high” mean?Meaning of “catch birds for”?How do I ensure “since” takes the meaning I want?“Who cares here” meaningWhat does “right round toward” mean?the time tense (had now been detected)What does the phrase “ring around the roses” mean here?Correct usage of “visited upon”Meaning of “foiled rail sabotage bid”It was the third time I had gone to Rome or It is the third time I had been to Rome

          Bunad

          Færeyskur hestur Heimild | Tengill | Tilvísanir | LeiðsagnarvalRossið - síða um færeyska hrossið á færeyskuGott ár hjá færeyska hestinum