Last active
October 23, 2015 13:41
-
-
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
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
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