Slamd64

Please see www.slamd64.com for information on Slamd64.

Twitter

RSS Feed Available

permalink :: trackback

Command-Not-Found on Slackware
(posted by Fred Emmott at 2008-02-11 15:47:47)

Command-Not-Found is a program on Ubuntu that suggests a package to install if a command doesn't exist. Benji has recently got something similar working on OpenSUSE, so I decided to try to do it on Slackware :) My solution requires you to download MANIFEST.bz2 for your version of Slackware, and set $MANIFEST to the path of MANIFEST.bz2.

export PROMPT_COMMAND='
if [ $? -eq 127 ]; then
(
    history -a; 
    COMMAND=$(tail -n 1 $HISTFILE);
    LINE=$(bzgrep -m1 -n bin/$COMMAND$ $MANIFEST | cut -f1 -d:)
    if [ "$LINE" != "" ]; then
        PACKAGE=$(echo $SQL | bzcat $MANIFEST | head -n $LINE | tac | grep -m1 "Package" | rev | cut -f1,2 -d/ | rev)
    fi
    PACKAGE=${PACKAGE:="-"};
    if [ $PACKAGE != "-" ]; then 
        echo $COMMAND is not installed; Try installing $PACKAGE.
    fi;
)
fi'

Example:

fred@typhon:~$ kopete
-bash: kopete: command not found
kopete is not installed; Try installing kde/kdenetwork-3.5.8-i486-1.tgz.
fred@typhon:~$ foo
-bash: foo: command not found
fred@typhon:~$  

Trackbacks

No trackbacks for this post

Comments

Neato

Posted at 2008-02-11 15:57:30 GMT +0000 by "Anonymous"

Thanks! :-)

Good old MANIFEST.bz2

Posted at 2008-02-11 17:20:07 GMT +0000 by "Randomsel"

That's really neat! Never would have thought of doing it. Now to write a little which "improvement" script...

send it to pat

Posted at 2008-02-11 21:53:32 GMT +0000 by "Anonymous"

take it one step further and present at to patrick vorkerling or a t least announce it at aols/linuxquestions. could be useful for a few people

Submit a comment

Drink brewed from grapes:
Name:
Subject:
Message:

Valid XHTML Valid CSS