Skip to content

Instantly share code, notes, and snippets.

@romuloceccon
Last active August 29, 2015 14:16
Show Gist options
  • Select an option

  • Save romuloceccon/a79fb3a4ad73a0f306ac to your computer and use it in GitHub Desktop.

Select an option

Save romuloceccon/a79fb3a4ad73a0f306ac to your computer and use it in GitHub Desktop.
#!/bin/bash
IFS=$'\n'
for L in $(git status --porcelain $1); do
if [[ $L =~ ^\ M\ (.*)$ || $L =~ ^\ T\ (.*)$ || $L =~ ^\?\?\ (.*)$ ]] ; then
git add ${BASH_REMATCH[1]}
>&2 echo added ${BASH_REMATCH[1]}
elif [[ $L =~ ^\ D\ (.*)$ ]] ; then
git rm ${BASH_REMATCH[1]}
>&2 echo removed ${BASH_REMATCH[1]}
elif [[ $L =~ ^[ADMRT]\ ]] ; then
true
else
>&2 echo unknown action: $L
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment