Created
April 28, 2022 09:10
-
-
Save manno/c31a2109699a12029f55f3e42c302d37 to your computer and use it in GitHub Desktop.
Start nvim with file names from commit
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
#!/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