[issue564] support command-not-found within grml's zsh on request?
Michael Prokop
bts at bts.grml.org
Tue Nov 4 13:42:32 CET 2008
Michael Prokop <mika at grml.org> added the comment:
[...]
> > 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
> > }
> > }
> Okay, *if* we take a stab at this, I'm writing this from scratch.
> <yoda>This I don't like.</yoda>
Hehe ok :)
> > So when sourcing this file and invoking a command which isn't
> > present it displays which Debian package might provide the command.
> Might? So it's basically just guessing? Or does it actually consult
> the dpkg package database (which would be quite expensive, I think;
> .o( apt-file nautilus | grep bin/ | awk { whatever } )).
Might as in "if the command isn't in any Debian package it can't
help the user".
> > 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'
> Okay, I get the notion.
> However:
> a) How does that thing get it's data?
Via:
% file /var/cache/command-not-found/*
/var/cache/command-not-found/ftp.de.debian.org_debian_dists_unstable_contrib.db: GNU dbm 1.x or ndbm database, little endian
/var/cache/command-not-found/ftp.de.debian.org_debian_dists_unstable_main.db: GNU dbm 1.x or ndbm database, little endian
/var/cache/command-not-found/ftp.de.debian.org_debian_dists_unstable_non-free.db: GNU dbm 1.x or ndbm database, little endian
/var/cache/command-not-found/www.debian-multimedia.org_dists_sid_main.db: GNU dbm 1.x or ndbm database, little endian
/var/cache/command-not-found/www.informatik.uni-koeln.de_fai_download_dists_lenny_main.db: GNU dbm 1.x or ndbm database, little endian
AFAICS.
> b) How accurate are its predictions?
Very accurate AFAICS.
> c) How well does it perform, if it's really accurate?
% zsh -f
% source /etc/zsh_command_not_found
% nautilus
zsh: command not found: nautilus
The program 'nautilus' is currently not installed. To run 'nautilus' please ask your administrator to install the package 'nautilus
'
%
-> Works at least pretty well and fast on my system.
regards,
-mika-
----------
assignedto: ft
messages: 1627, 1628, 1629, 1630, 1631, 1636, 1637
nosy: ft, mika
priority: feature
status: chatting
title: support command-not-found within grml's zsh on request?
topic: configs, zsh
_____________________________________
GRML issue tracker <bts at bts.grml.org>
<http://bts.grml.org/grml/issue564>
_____________________________________
More information about the Bugs-changes
mailing list