Skip to content

Instantly share code, notes, and snippets.

@fberger
Created August 20, 2010 21:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fberger/541224 to your computer and use it in GitHub Desktop.
Save fberger/541224 to your computer and use it in GitHub Desktop.
function export_file {
line=$1
file=$(echo $line | awk '{print $3}')
prefix=$(echo $line | cut -d':' -f1)
eval "export f${counter}=${file}"
echo "${prefix}: f${counter} ${file}"
let counter=$counter+1
}
counter=0
while [ "0" -eq $(eval "test \$f${counter}"; echo $?) ]; do
echo "resetting f${counter}"
eval "unset f${counter}"
let counter=$counter+1
done
counter=0
IFS=$'\n'
for line in $(git status); do
if [[ $line == *"modified:"* ]]; then
export_file $line
elif [[ $line == *"deleted:"* ]]; then
export_file $line
else
echo $line
fi
done
unset IFS
@fberger
Copy link
Author

fberger commented Aug 20, 2010

  • Copy gist to a file in ~/bin/gitstat.sh
  • Create alias: alias gst='source ~/bin/gitstat.sh'

When invoked, it creates shell variables for all modified and deleted files in a git status command.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment