Created
October 27, 2022 13:40
-
-
Save shollingsworth/f14360abac01cebbdd6befa3234c9d85 to your computer and use it in GitHub Desktop.
List git modified files for use in something like vim.
This file contains 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
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
"""List git modified files for use in something like vim.""" | |
import subprocess | |
def main(): | |
"""Run main function.""" | |
edit_keys = { | |
"A", | |
"M", | |
"?", | |
} | |
out = subprocess.check_output( | |
[ | |
"git", | |
"status", | |
"--short", | |
] | |
).decode("utf-8") | |
for line in out.split("\n"): | |
if not line.strip(): | |
continue | |
spl = line[0:3] | |
comp = set(spl) | |
r = line[3:] | |
if comp.intersection(edit_keys): | |
print(r.strip()) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment