Created
July 24, 2011 19:26
-
-
Save lazywithclass/1102981 to your computer and use it in GitHub Desktop.
Append c to a command and see its output copyed in the clipboard (xclip needed)
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
command_not_found_handle() { | |
if [ $(echo $1 | cut -d' ' -f1 | grep ".*c$") ]; then | |
echo "copying $(echo $1 | sed 's/^\([a-z][a-z]*\)c.*/\1/') results in your clipboard..." | |
exec $(echo $1 | sed 's/^\([a-z][a-z]*\)c.*/\1/') | copy | |
#just pasted the body of the system-wide function to handle c-n-f | |
#if the command-not-found package is installed, use it | |
elif [ -x /usr/lib/command-not-found -o -x /usr/share/command-not-found ]; then | |
# check because c-n-f could've been removed in the meantime | |
if [ -x /usr/lib/command-not-found ]; then | |
/usr/bin/python /usr/lib/command-not-found -- $1 | |
return $? | |
elif [ -x /usr/share/command-not-found ]; then | |
/usr/bin/python /usr/share/command-not-found -- $1 | |
return $? | |
else | |
return 127 | |
fi | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment