BTS

Message1631

Author mika
Recipients ft
Date 2008-10-27.21:38:57
Content
* Frank Terbeck <bts@bts.grml.org> [20081027 22:32]:

> I actually meant. How does command-not-found work? :-)

Ah, sorry. :)

,---- [ /etc/zsh_command_not_found ]
| # (c) Zygmunt Krynicki 2007,
| # Licensed under GPL, see COPYING for the whole text
| #
| # This script will look-up command in the database and suggest
| # installation of packages available from the repository
|
| function preexec() {
|         command="${1%% *}"
| }
|
| function precmd() {
|         (($?)) && [ -n "$command" ] && [ -x /usr/share/command-not-found/command-not-found ] && {
|                 whence -- "$command" >& /dev/null ||
|                         /usr/share/command-not-found/command-not-found -- "$command"
|                 unset command
|         }
| }
`----

So when sourcing this file and invoking a command which isn't
present it displays which Debian package might provide the command.

Demonstration (manually invoking
/usr/share/command-not-found/command-not-found though here):

% /usr/share/command-not-found/command-not-found nautilus
The program 'nautilus' is currently not installed.  To run 'nautilus' please ask your administrator to install the package 'nautilus
'

regards,
-mika-
History
Date User Action Args
2008-10-27 21:38:58mikasetrecipients: + ft
2008-10-27 21:38:58mikalinkissue564 messages
2008-10-27 21:38:57mikacreate