Skip to content

Instantly share code, notes, and snippets.

@pasora
Created July 30, 2018 09:48
Show Gist options
  • Save pasora/ceede95bda219738c68d95f95bda52b5 to your computer and use it in GitHub Desktop.
Save pasora/ceede95bda219738c68d95f95bda52b5 to your computer and use it in GitHub Desktop.
This is a script performing git status -> git diff -> git add.
#!/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