Last active
December 16, 2015 17:19
-
-
Save mortehu/5469769 to your computer and use it in GitHub Desktop.
Fix spelling mistakes in bash command lines
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
# BEGIN: Put this in ~/.bashrc | |
function err_handle { | |
if [ "$?" != 0 ] | |
then | |
if echo "$previous_command" | grep -q '\<hlep\>' | |
then | |
NEW_COMMAND="$(echo "$previous_command" | sed 's/\<hlep\>/help/g')" | |
echo -ne "Command failed. Retry with '$NEW_COMMAND' (y/n)? " | |
read p | |
if [ "$p" = "y" ] | |
then | |
eval $NEW_COMMAND | |
fi | |
fi | |
fi | |
} | |
trap 'err_handle' ERR | |
trap 'previous_command=$this_command; this_command=$BASH_COMMAND' DEBUG | |
# END: Put this in ~/.bashrc | |
# Example: | |
/bin/ls --hlep |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment