Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.