Skip to content

Instantly share code, notes, and snippets.

@shollingsworth
Created October 27, 2022 13:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shollingsworth/f14360abac01cebbdd6befa3234c9d85 to your computer and use it in GitHub Desktop.
Save shollingsworth/f14360abac01cebbdd6befa3234c9d85 to your computer and use it in GitHub Desktop.
List git modified files for use in something like vim.
#!/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