Skip to content

Instantly share code, notes, and snippets.

@coogie
Last active October 23, 2015 13:41
Show Gist options
  • Save coogie/1ef7fb2d7fffd4c727bd to your computer and use it in GitHub Desktop.
Save coogie/1ef7fb2d7fffd4c727bd to your computer and use it in GitHub Desktop.
A bash command for re-running git command typos with their intended command
function rerun() {
passedParams=($@)
heldParams=${passedParams[@]:2}
declare last=''
while [[ $# > 0 ]]; do
last="$last $1"
shift
done
declare suggestion="$($last 2>&1)"
declare intended=$(echo "$suggestion" | grep -A 1 'Did you mean' | tail -1)
git $intended $heldParams
}
alias idid='rerun $(history -p !!)'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment