Skip to content

Instantly share code, notes, and snippets.

@dorentus
Created February 3, 2013 09:53
Show Gist options
  • Save dorentus/4701106 to your computer and use it in GitHub Desktop.
Save dorentus/4701106 to your computer and use it in GitHub Desktop.
WAAAAAAAAAAAAAAAAAAAAAAAGH! for bash
type old_command_not_found_handle 2>/dev/null | grep -q 'is a function' > /dev/null
if [ $? -ne 0 ]; then
eval "$(echo "old_command_not_found_handle()"; declare -f command_not_found_handle | tail -n +2)"
fi
command_not_found_handle () {
if [[ ! "$1" ]] ; then
old_command_not_found_handle $@
return $?
fi
n=$1
if echo $n| perl -ne 'exit(/^waa+gh!?$/i ? 0:1)' ; then
if which lolcat > /dev/null; then
n=$(echo $n | lolcat -f)
fi
echo $n
return 0
else
old_command_not_found_handle $@
return $?
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment