Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7017435
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:54:49+00:00 2026-05-27T22:54:49+00:00

Is there either an existing command, or some trick or script that allows me

  • 0

Is there either an existing command, or some trick or script that allows me to show the status of the files shown in “ls”?

Something like the following:

$ git ls status #Command could be anything `lsg` is fine too, whatever.

app           contents modified
autotest      up-to-date
config        up-to-date
config.ru     staged
db            contents modified
doc           contents modified
Gemfile       modified
Gemfile.lock  modified
lib           up-to-date
log           up-to-date
public        up-to-date
Rakefile      up-to-date
README        up-to-date
script        up-to-date
spec          up-to-date
tmp           up-to-date
vendor        contents modidified
test.tmp      removed

In any way: having the git status information available in a directory listing.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T22:54:50+00:00Added an answer on May 27, 2026 at 10:54 pm

    Using the Git status short format information, here’s a Bash script that uses Awk and the column command to give you customized status output.

    #!/bin/bash
    git status --porcelain | \
        awk 'BEGIN {FS=" "}
    {
        xstat = substr($0, 1, 1);
        ystat = substr($0, 2, 1);
        f = substr($0, 4);
        ri = index(f, " -> ");
        if (ri > 0) f = substr(f, 1, ri);
        if (xstat == " " && ystat ~ "M|D") stat = "not updated";
        else if (xstat == "M" && ystat ~ " |M|D") stat = "updated in index";
        else if (xstat == "A" && ystat ~ " |M|D") stat = "added to index";
        else if (xstat == "D" && ystat ~ " |M") stat = "deleted from index";
        else if (xstat == "R" && ystat ~ " |M|D") stat = "renamed in index";
        else if (xstat == "C" && ystat ~ " |M|D") stat = "copied in index";
        else if (xstat ~ "M|A|R|C" && ystat == " ") stat = "index and work tree matches";
        else if (xstat ~ " |M|A|R|C" && ystat == "M") stat = "work tree changed since index";
        else if (xstat ~ " |M|A|R|C" && ystat == "D") stat = "deleted in work tree";
        else if (xstat == "D" && ystat == "D") stat = "unmerged, both deleted";
        else if (xstat == "A" && ystat == "U") stat = "unmerged, added by us";
        else if (xstat == "U" && ystat == "D") stat = "unmerged, deleted by them";
        else if (xstat == "U" && ystat == "A") stat = "unmerged, added by them";
        else if (xstat == "D" && ystat == "U") stat = "unmerged, deleted by us";
        else if (xstat == "A" && ystat == "A") stat = "unmerged, both added";
        else if (xstat == "U" && ystat == "U") stat = "unmerged, both modified";
        else if (xstat == "?" && ystat == "?") stat = "untracked";
        else if (xstat == "!" && ystat == "!") stat = "ignored";
        else stat = "unknown status";
        print f "   " stat;
    }' | \
        column -t -s "  "
    

    If you create an executable git-status-ls in a directory on your PATH ($HOME/bin should be a good place), you can type git status-ls in any Git repo. Or you could create a Git alias one-liner for this. You could also implement this using Perl, Python, C or whatever language you’re most comfortable with.


    Here’s a sample output:

    B                                renamed in index
    A                                untracked
    dont_delete_git_pre-commit_hook  untracked
    

    Just realized, tabs are displaying as spaces. In the Awk script print f " " stat; and in the column -t -s " " command, there is a tab (not spaces) between the double-quotes. You could use a separator other than tab.


    Noticed an issue with the status flags handling in the above script and corrected it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there an existing library that allows me to annotate a Java method as
I have a bash script that checks some log files created by a cron
Are there existing template extract libraries in either python or php? Perl has Template::Extract
I am running into a randomly occuring issue, and it looks like either there
I've got some code files that are used in two different projects (and solutions).
Hi out there in Stackland. I was wondering if there was either a function
What advantages are there for using either XSLT or Linq to XML for HTML
I want to allow users to either have there username field empty at any
There are multiple ways to fill an NSTableView up with data through either bindings,
Is there a way to coax either the h:outputLink or s:link tags into generating

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.