Skip to content

Instantly share code, notes, and snippets.

@papaben
Created April 18, 2014 20:51
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save papaben/11063860 to your computer and use it in GitHub Desktop.
Save papaben/11063860 to your computer and use it in GitHub Desktop.
My typical answer when git asks, "Did you mean?"
##
# "I did [mean that]"
# Re-run the suggested git command
# Intended to be run as 'idid !!'
##
function idid() {
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
}
@zeusdeux
Copy link

This is neat!

One question, why not just do declare last=$@ instead of the whole while loop with the shift bit?

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