Results 1 to 4 of 4

Thread: Manual method to trigger command-not-found search

  1. #1
    Join Date
    Sep 2007
    Beans
    5

    Manual method to trigger command-not-found search

    I really like that in Ubuntu when you type in a command that's not on the system you get a message saying the package that provides that command. Unfortunately it also slows down my system, so I would like a way to trigger this manually. Something like search-command command-I-dont-have

    Is there any way to do this?

    I'm using Ubuntu 9.04 under andLinux but would also like to use this on a regular Ubuntu 9.04 install.

  2. #2
    Join Date
    Feb 2007
    Location
    Romania
    Beans
    Hidden!

    Re: Manual method to trigger command-not-found search

    Edit the /etc/bash.bashrc and comment out the command-not-found entry:
    Code:
    # if the command-not-found package is installed, use it
    #if [ -x /usr/lib/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/bin/python /usr/lib/command-not-found -- $1
    #                   return $?
    #                else
    #                   return 127
    #                fi
    #        }
    #fi
    Log out from the terminal and log back in.

    Edit your ~/.bashrc file and append it with:
    Code:
    if [ -x /usr/lib/command-not-found ]; then
            function cnf {
                    # check because c-n-f could've been removed in the meantime
                    if [ -x /usr/lib/command-not-found ]; then
                       /usr/bin/python /usr/lib/command-not-found -- $1
                       return $?
                    else
                       return 127
                    fi
            }
    fi
    source the file:
    Code:
    . ~/.bashrc
    usage:
    Code:
    cnf command-name
    Last edited by sisco311; January 19th, 2010 at 02:08 PM.

  3. #3
    Join Date
    Sep 2007
    Beans
    5

    Re: Manual method to trigger command-not-found search

    Thanks! This works perfectly. Hopefully it will be useful to others as well.

  4. #4
    Join Date
    Feb 2007
    Location
    Romania
    Beans
    Hidden!

    Re: Manual method to trigger command-not-found search

    Quote Originally Posted by bostonvaulter View Post
    Thanks! This works perfectly. Hopefully it will be useful to others as well.
    You are welcome!

    Please mark your thread as [SOLVED] by selecting Mark this thread as solved from the Thread tools.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •