Skip to content

Instantly share code, notes, and snippets.

@manno
Created April 28, 2022 09:10
Show Gist options
  • Save manno/c31a2109699a12029f55f3e42c302d37 to your computer and use it in GitHub Desktop.
Save manno/c31a2109699a12029f55f3e42c302d37 to your computer and use it in GitHub Desktop.
Start nvim with file names from commit
#!/bin/sh
case "$1" in
-h|help|usage|--help)
echo "$0 [head|modified|commit ref]"
echo
echo "examples:"
echo " $0 # edit files from HEAD commit"
echo " $0 -m # edit modified files"
echo " $0 -c HEAD~2 # edit files from commit"
echo " $0 -c abc123 # edit files from commit"
echo " $0 -c :/fix # edit files from commit"
;;
modified|m|-m)
nvim $(git ls-files --modified)
;;
commit|c|-c)
nvim $(git diff-tree --no-commit-id --name-only -r "$2")
;;
*|head|h|-h)
nvim $(git diff-tree --no-commit-id --name-only -r HEAD)
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment