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)No line break with colored git branch in bash prompt

What is the intuition for higher homotopy groups not vanishing?

Align the contents of a numerical matrix when you have minus signs

Is "repository" pronounced /rɪˈpɒzɪt(ə)ri/ or ri-ˈpä-zə-ˌtȯr-ē or /rəˈpäzəˌtôrē/?

Why aren't there any women super Grandmasters (GMs)?

Why would word of Princess Leia's capture generate sympathy for the Rebellion in the Senate?

Do higher dimensions have axes?

What are my hardware upgrade optoins for a late 2009 iMac?

Will copper pour help on my single-layer PCB?

What's the largest an Earth-like planet can be and support Earth's biosphere?

Why are flying carpets banned while flying brooms are not?

Making a Dataset that emulates `ls -tlra`?

A spacecraft is travelling at X units per hour. But relative to what exactly? Does it depend on orbit? How?

Weight functions in graph algorithms

Equality of complex numbers in general

Parser for STL stereolithography data files

What is a Kravchuk transform and how is it related to Fourier transforms?

Locked-up DOS computer beeped on keypress. What mechanism caused that?

Which family is it?

I want light controlled by one switch, not two

Inscriptio Labyrinthica

When we are talking about black hole evaporation - what exactly happens?

How should I interpret a promising preprint that was never published in a peer-reviewed journal?

What's a German word for »Sandbagger«?

Should I work for free if client's requirement changed



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)No line break with colored git branch in bash prompt






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








17















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






























    17















    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


























      17












      17








      17


      3






      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 Mar 26 at 15:43







      Afshin

















      asked Mar 26 at 7:58









      AfshinAfshin

      7512 bronze badges




      7512 bronze badges




















          1 Answer
          1






          active

          oldest

          votes


















          24














          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




















          • 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
            Mar 27 at 7:27














          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









          24














          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




















          • 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
            Mar 27 at 7:27
















          24














          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




















          • 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
            Mar 27 at 7:27














          24












          24








          24







          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 Mar 28 at 19:02

























          answered Mar 26 at 8:53









          dessertdessert

          28k6 gold badges83 silver badges115 bronze badges




          28k6 gold badges83 silver badges115 bronze badges







          • 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
            Mar 27 at 7:27













          • 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
            Mar 27 at 7:27








          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
          Mar 27 at 7:27






          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
          Mar 27 at 7:27


















          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

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

          Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript