Last active
February 18, 2021 11:31
-
-
Save papaben/463d72bb4ea329754566fa82ef0c949e to your computer and use it in GitHub Desktop.
Run the git command you intended, `idid !!`
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 "!!"' | |
# Place this file in your $PATH | |
# TODO create this as a brew script | |
## | |
declare last='' | |
declare selection_ordinal='1' | |
# Select something other than the first suggestion? | |
if [[ "$1" =~ "-" ]]; then | |
selection_ordinal="${1#-}" | |
shift | |
fi | |
while [[ $# > 0 ]] | |
do | |
last="$last $1" | |
shift | |
done | |
declare suggestion="$($last 2>&1)" | |
declare intended=$(echo "$suggestion" | grep -A $selection_ordinal '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
Several folks use git autocorrect, but I don't trust that.
USAGE:
Parity with auto-correct
Choose non-default auto-correct suggestion