If you got that message in ubuntu after running a non-existing command from bash, your system is probably using command_not_found_handle
function. You can see it in /etc/bash.bashrc
.
A trivial hacking may be an option:
I just created a script named cnfh
:
#!/bin/bash
# if the command-not-found package is installed, use it
if [ -x /usr/lib/command-not-found -o -x /usr/share/command-not-found/command-not-found ]; then
function command_not_found_handle {
# check because c-n-f could've been removed in the meantime
if [ -x /usr/lib/command-not-found ]; then
/usr/lib/command-not-found -- "$1"
return $?
elif [ -x /usr/share/command-not-found/command-not-found ]; then
/usr/share/command-not-found/command-not-found -- "$1"
return $?
else
printf "%s: command not found\n" "$1" >&2
return 127
fi
}
fi
"$@"
RET_VAL=$?
if [ $RET_VAL -eq 127 ]; then
OUT=$(command_not_found_handle "$@" 2>&1)
$(echo $OUT |sed -n 's/.*\(apt-get install .\+\)$/\1/p')
fi
Then run td command using this script:
# ./cnfh td
Using Ubuntu 14.04.2 LTS. I hope that helps.
sudo apt-get install textdraw
, nottd
. up arrow will only give me thetd