Last active
August 28, 2025 01:14
-
-
Save chapmanjacobd/5ecb8be86f83dcfdcd043cf3b68b0b27 to your computer and use it in GitHub Desktop.
Select only specific files by their git status
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function untracked -w 'git status' | |
| git status --porcelain --short $argv | awk 'substr($0, 1, 2) == "??" {print substr($0, 4)}' | string unescape --style=script | |
| end | |
| function added -w 'git status' | |
| git status --porcelain --short $argv | awk 'substr($0, 1, 1) == "A" && substr($0, 2, 1) == " " {print substr($0, 4)}' | string unescape --style=script | |
| end | |
| function deleted -w 'git status' | |
| git status --porcelain --short $argv | awk 'substr($0, 1, 1) == " " && substr($0, 2, 1) == "D" {print substr($0, 4)}' | string unescape --style=script | |
| end | |
| function deleted.staged -w 'git status' | |
| git status --porcelain --short $argv | awk 'substr($0, 1, 1) == "D" && substr($0, 2, 1) == " " {print substr($0, 4)}' | string unescape --style=script | |
| end | |
| function modified -w 'git status' | |
| git status --porcelain --short $argv | awk 'substr($0, 1, 1) == " " && substr($0, 2, 1) == "M" {print substr($0, 4)}' | string unescape --style=script | |
| end | |
| function modified.staged -w 'git status' | |
| git status --porcelain --short $argv | awk 'substr($0, 1, 1) == "M" && substr($0, 2, 1) == " " {print substr($0, 4)}' | string unescape --style=script | |
| end | |
| function renamed -w 'git status' | |
| git status --porcelain --short $argv | awk '/^R/ {print $NF}' | string unescape --style=script | |
| end | |
| function unmerged -w 'git status' | |
| git status --porcelain --short $argv | awk '$1 ~ /^(DD|AU|UD|UA|DU|AA|UU)/ {print substr($0, 4)}' | string unescape --style=script | |
| end | |
| function changedtype -w 'git status' | |
| git status --porcelain --short $argv | awk 'substr($0, 1, 1) == " " && substr($0, 2, 1) == "T" {print substr($0, 4)}' | string unescape --style=script | |
| end | |
| function changedtype.staged -w 'git status' | |
| git status --porcelain --short $argv | awk 'substr($0, 1, 1) == "T" && substr($0, 2, 1) == " " {print substr($0, 4)}' | string unescape --style=script | |
| end | |
| funcsave untracked added deleted deleted.staged modified modified.staged renamed unmerged changedtype changedtype.staged |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is so that you can run something like
or
But maybe you already use Magit, etc