Created
July 30, 2018 09:48
-
-
Save pasora/ceede95bda219738c68d95f95bda52b5 to your computer and use it in GitHub Desktop.
This is a script performing git status -> git diff -> git add.
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/bash | |
for f in $(git status | gawk 'BEGIN{staged=0}{if(staged){if(/modified:/){print gensub(/.*modified:[ \\t]*(.*)/,"\\1","g",$0)}}if(/^Changes not staged for commit:$/){staged=1}}') | |
do | |
clear | |
git status | |
echo "Target file: ${f}" | |
# git diff | |
while | |
echo "See diff? (y/n/q)" | |
read ans | |
do | |
case ${ans} in | |
y) | |
git diff ${f} | |
break;; | |
n) | |
break;; | |
q) | |
exit 0;; | |
*) | |
esac | |
done | |
# git add | |
while | |
echo "Stage ${f}? (y/n/q)" | |
read ans | |
do | |
case ${ans} in | |
y) | |
git add ${f} | |
break;; | |
n) | |
break;; | |
q) | |
exit 0;; | |
*) | |
esac | |
done | |
done | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment