Colorize bash output?

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











up vote
0
down vote

favorite












I keep all my git repositories in a single folder, and sometimes I want to get a quick status check on all of them, mostly to make sure I'm not leaving the office without pushing any commits.



I wrote a bash script to do that:



for dir in *; do if [[ -d $dir ]]; then echo "checking " $dir; cd $dir; git status; cd ../; fi; done



Which, not for nothing, revealed that I have a couple of untracked files hanging out in one repository that I hadn't realized were not properly tracked. I'm realizing that for this script to be truly awesome, it should highlight the repositories with unstaged changes or unpushed commits, because right now they don't really stand out.



Here's some sample output:



checking repository_one
On branch master
Your branch is up to date with 'origin/master'.

Untracked files:
(use "git add <file>..." to include in what will be committed)

imgs/one.jpg
imgs/two.jpg

nothing added to commit but untracked files present (use "git add" to track)
checking repostory_three
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
(use "git push" to publish your local commits)

Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)

modified: modified_thing.md

no changes added to commit (use "git add" and/or "git commit -a")
checking repository_four
On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean
checking repository_five
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
(use "git push" to publish your local commits)

nothing to commit, working tree clean


In my terminal, the untracked files and unstaged changes appear in red, but the rest is grey. I'd also love to highlight "Your branch is ahead of 'origin/master' by 1 commit." so I don't leave without pushing it. Can I do that in the script somewhere? Or in my theme? Anywhere?



Is there a better (or different) way to quickly scan for unstaged changes and branches that are ahead by a commit?









share

























    up vote
    0
    down vote

    favorite












    I keep all my git repositories in a single folder, and sometimes I want to get a quick status check on all of them, mostly to make sure I'm not leaving the office without pushing any commits.



    I wrote a bash script to do that:



    for dir in *; do if [[ -d $dir ]]; then echo "checking " $dir; cd $dir; git status; cd ../; fi; done



    Which, not for nothing, revealed that I have a couple of untracked files hanging out in one repository that I hadn't realized were not properly tracked. I'm realizing that for this script to be truly awesome, it should highlight the repositories with unstaged changes or unpushed commits, because right now they don't really stand out.



    Here's some sample output:



    checking repository_one
    On branch master
    Your branch is up to date with 'origin/master'.

    Untracked files:
    (use "git add <file>..." to include in what will be committed)

    imgs/one.jpg
    imgs/two.jpg

    nothing added to commit but untracked files present (use "git add" to track)
    checking repostory_three
    On branch master
    Your branch is ahead of 'origin/master' by 1 commit.
    (use "git push" to publish your local commits)

    Changes not staged for commit:
    (use "git add <file>..." to update what will be committed)
    (use "git checkout -- <file>..." to discard changes in working directory)

    modified: modified_thing.md

    no changes added to commit (use "git add" and/or "git commit -a")
    checking repository_four
    On branch master
    Your branch is up to date with 'origin/master'.

    nothing to commit, working tree clean
    checking repository_five
    On branch master
    Your branch is ahead of 'origin/master' by 1 commit.
    (use "git push" to publish your local commits)

    nothing to commit, working tree clean


    In my terminal, the untracked files and unstaged changes appear in red, but the rest is grey. I'd also love to highlight "Your branch is ahead of 'origin/master' by 1 commit." so I don't leave without pushing it. Can I do that in the script somewhere? Or in my theme? Anywhere?



    Is there a better (or different) way to quickly scan for unstaged changes and branches that are ahead by a commit?









    share























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I keep all my git repositories in a single folder, and sometimes I want to get a quick status check on all of them, mostly to make sure I'm not leaving the office without pushing any commits.



      I wrote a bash script to do that:



      for dir in *; do if [[ -d $dir ]]; then echo "checking " $dir; cd $dir; git status; cd ../; fi; done



      Which, not for nothing, revealed that I have a couple of untracked files hanging out in one repository that I hadn't realized were not properly tracked. I'm realizing that for this script to be truly awesome, it should highlight the repositories with unstaged changes or unpushed commits, because right now they don't really stand out.



      Here's some sample output:



      checking repository_one
      On branch master
      Your branch is up to date with 'origin/master'.

      Untracked files:
      (use "git add <file>..." to include in what will be committed)

      imgs/one.jpg
      imgs/two.jpg

      nothing added to commit but untracked files present (use "git add" to track)
      checking repostory_three
      On branch master
      Your branch is ahead of 'origin/master' by 1 commit.
      (use "git push" to publish your local commits)

      Changes not staged for commit:
      (use "git add <file>..." to update what will be committed)
      (use "git checkout -- <file>..." to discard changes in working directory)

      modified: modified_thing.md

      no changes added to commit (use "git add" and/or "git commit -a")
      checking repository_four
      On branch master
      Your branch is up to date with 'origin/master'.

      nothing to commit, working tree clean
      checking repository_five
      On branch master
      Your branch is ahead of 'origin/master' by 1 commit.
      (use "git push" to publish your local commits)

      nothing to commit, working tree clean


      In my terminal, the untracked files and unstaged changes appear in red, but the rest is grey. I'd also love to highlight "Your branch is ahead of 'origin/master' by 1 commit." so I don't leave without pushing it. Can I do that in the script somewhere? Or in my theme? Anywhere?



      Is there a better (or different) way to quickly scan for unstaged changes and branches that are ahead by a commit?









      share













      I keep all my git repositories in a single folder, and sometimes I want to get a quick status check on all of them, mostly to make sure I'm not leaving the office without pushing any commits.



      I wrote a bash script to do that:



      for dir in *; do if [[ -d $dir ]]; then echo "checking " $dir; cd $dir; git status; cd ../; fi; done



      Which, not for nothing, revealed that I have a couple of untracked files hanging out in one repository that I hadn't realized were not properly tracked. I'm realizing that for this script to be truly awesome, it should highlight the repositories with unstaged changes or unpushed commits, because right now they don't really stand out.



      Here's some sample output:



      checking repository_one
      On branch master
      Your branch is up to date with 'origin/master'.

      Untracked files:
      (use "git add <file>..." to include in what will be committed)

      imgs/one.jpg
      imgs/two.jpg

      nothing added to commit but untracked files present (use "git add" to track)
      checking repostory_three
      On branch master
      Your branch is ahead of 'origin/master' by 1 commit.
      (use "git push" to publish your local commits)

      Changes not staged for commit:
      (use "git add <file>..." to update what will be committed)
      (use "git checkout -- <file>..." to discard changes in working directory)

      modified: modified_thing.md

      no changes added to commit (use "git add" and/or "git commit -a")
      checking repository_four
      On branch master
      Your branch is up to date with 'origin/master'.

      nothing to commit, working tree clean
      checking repository_five
      On branch master
      Your branch is ahead of 'origin/master' by 1 commit.
      (use "git push" to publish your local commits)

      nothing to commit, working tree clean


      In my terminal, the untracked files and unstaged changes appear in red, but the rest is grey. I'd also love to highlight "Your branch is ahead of 'origin/master' by 1 commit." so I don't leave without pushing it. Can I do that in the script somewhere? Or in my theme? Anywhere?



      Is there a better (or different) way to quickly scan for unstaged changes and branches that are ahead by a commit?







      bash shell-script git





      share












      share










      share



      share










      asked 4 mins ago









      Amanda

      396113




      396113

























          active

          oldest

          votes











          Your Answer








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

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

          else
          createEditor();

          );

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



          );













           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f479032%2fcolorize-bash-output%23new-answer', 'question_page');

          );

          Post as a guest



































          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f479032%2fcolorize-bash-output%23new-answer', 'question_page');

          );

          Post as a guest













































































          Popular posts from this blog

          How to check contact read email or not when send email to Individual?

          Displaying single band from multi-band raster using QGIS

          How many registers does an x86_64 CPU actually have?