Skip to content

Instantly share code, notes, and snippets.

@lazywithclass
Created July 24, 2011 19:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lazywithclass/1102981 to your computer and use it in GitHub Desktop.
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)
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