Created
April 18, 2014 20:51
-
-
Save papaben/11063860 to your computer and use it in GitHub Desktop.
My typical answer when git asks, "Did you mean?"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## | |
# "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 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is neat!
One question, why not just do
declare last=$@
instead of the wholewhile
loop with theshift
bit?