发现bash很“聪明”的提示你一些东西
比如我们键入
代码: 全选
irb
代码: 全选
The program 'irb' is currently not installed. You can install it by typing:
sudo apt-get install irb
代码: 全选
irb
代码: 全选
The program 'irb' is currently not installed. You can install it by typing:
sudo apt-get install irb
man bash 写了:If the name is neither a shell function nor a builtin, and contains no
slashes, bash searches each element of the PATH for a directory
containing an executable file by that name. Bash uses a hash table to
remem‐ ber the full pathnames of executable files (see hash under
SHELL BUILTIN COMMANDS below). A full search of the directories in
PATH is performed only if the command is not found in the hash table.
If the search is unsuccessful, the shell searches for a defined shell
function named command_not_found_handle. If that function exists, it
is invoked with the original command and the original command's
arguments as its argu‐ ments, and the function's exit status
becomes the exit status of the shell. If that function is not
defined, the shell prints an error message and returns an exit status
of 127.
代码: 全选
typeset -f command_not_found_handle
command_not_found_handle ()
{
if [ -x /usr/lib/command-not-found ]; then
/usr/bin/python /usr/lib/command-not-found -- $1;
return $?;
else
if [ -x /usr/share/command-not-found ]; then
/usr/bin/python /usr/share/command-not-found -- $1;
return $?;
else
return 127;
fi;
fi
}
代码: 全选
tlcr: 0 庚寅年八月十三日 17:14:51 ~
● grep -A2 apt-file ~/.zshrc
apt-file()
{
sudo apt-file "$@"
if [ "$1" = update ] ; then
sudo apt-file search bin/ > "$HOME/.share/programsList"
fi
}
tlcr: 0 庚寅年八月十三日 17:14:55 ~
● which command_not_found_handler
command_not_found_handler () {
local l="$(grep /$1$ < $HOME/.share/programsList)"
if [ "$l" ]
then
echo "下列软件包含有命令 $1 :"
echo "$l" | awk '{print "\033[0;1;32m" $1 "\t\t\033[31m /" $2}'
else
echo "未搜索到含有命令 $1 的软件包"
fi
return 127
}
tlcr: 0 庚寅年八月十三日 17:15:09 ~
●
代码: 全选
] ls -ld //