Created
January 11, 2015 04:59
-
-
Save g1eb/89a380f88bc4ce982f07 to your computer and use it in GitHub Desktop.
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
# Git wrapper with [y/N] prompt | |
g () { | |
out="$(script -q /dev/null command git "$@" 2>&1)"; out="${out//$'\r'}" | |
echo "$out" | |
if [[ "$out" == *"Did you mean this?"* ]]; then | |
cmd="${out##*$'\n'}"; cmd="${cmd//$'\t'}" | |
tput bold; read -r -p "[y/N]? " < /dev/tty res | |
if [[ $res =~ ^$|^([yY]|[yY][eE][sS])$ ]]; then | |
echo; command git $cmd | |
fi | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment