add 'sudo apt-get install package' to history when command not found

Bug #1184565 reported by Gerhard Burger
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
command-not-found
New
Undecided
Unassigned

Bug Description

This is not a bug but a feature request. I find it slightly annoying that when I try to execute a command I get for example

    The program 'latexmk' is currently not installed. You can install it by typing:
    sudo apt-get install latexmk

Of course if I want to use it, and it is only in one package, the next step is to install it, by typing 'sudo apt-get install latexmk'

If you could add

   history -s 'sudo apt-get install latexmk'

to the command not found handler, a fake entry would be added to the bash history, and I could install the package by pressing Up and then Enter, which is so much more convenient and cool ;)

Revision history for this message
Gerhard Burger (burger.ga) wrote :

also it is a lot less intrusive and not as controversial as the changes proposed in https://bugs.launchpad.net/command-not-found/+bug/880616

description: updated
Revision history for this message
voltlick (luke-stanley) wrote :

command-not-found.pl may be the file in question that needs modifying.

Revision history for this message
Gerhard Burger (burger.ga) wrote : Re: [Bug 1184565] Re: add 'sudo apt-get install package' to history when command not found

I think you mean /usr/lib/command-not-found
I'll see if I can get it too work myself, then I'll upload a patch...

On Fri, Jun 14, 2013 at 1:02 PM, voltlick <email address hidden>wrote:

> command-not-found.pl may be the file in question that needs modifying.
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1184565
>
> Title:
> add 'sudo apt-get install package' to history when command not found
>
> Status in command-not-found handler:
> New
>
> Bug description:
> This is not a bug but a feature request. I find it slightly annoying
> that when I try to execute a command I get for example
>
> The program 'latexmk' is currently not installed. You can install it
> by typing:
> sudo apt-get install latexmk
>
> Of course if I want to use it, and it is only in one package, the next
> step is to install it, by typing 'sudo apt-get install latexmk'
>
> If you could add
>
> history -s 'sudo apt-get install latexmk'
>
> to the command not found handler, a fake entry would be added to the
> bash history, and I could install the package by pressing Up and then
> Enter, which is so much more convenient and cool ;)
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/command-not-found/+bug/1184565/+subscriptions
>

Revision history for this message
Gerhard Burger (burger.ga) wrote :

or /usr/lib/python3/dist-packages/CommandNotFound/CommandNotFound.py

On Sun, Jun 16, 2013 at 1:08 PM, Gerhard Burger <email address hidden> wrote:

> I think you mean /usr/lib/command-not-found
> I'll see if I can get it too work myself, then I'll upload a patch...
>
>
> On Fri, Jun 14, 2013 at 1:02 PM, voltlick <email address hidden>wrote:
>
>> command-not-found.pl may be the file in question that needs modifying.
>>
>> --
>> You received this bug notification because you are subscribed to the bug
>> report.
>> https://bugs.launchpad.net/bugs/1184565
>>
>> Title:
>> add 'sudo apt-get install package' to history when command not found
>>
>> Status in command-not-found handler:
>> New
>>
>> Bug description:
>> This is not a bug but a feature request. I find it slightly annoying
>> that when I try to execute a command I get for example
>>
>> The program 'latexmk' is currently not installed. You can install
>> it by typing:
>> sudo apt-get install latexmk
>>
>> Of course if I want to use it, and it is only in one package, the next
>> step is to install it, by typing 'sudo apt-get install latexmk'
>>
>> If you could add
>>
>> history -s 'sudo apt-get install latexmk'
>>
>> to the command not found handler, a fake entry would be added to the
>> bash history, and I could install the package by pressing Up and then
>> Enter, which is so much more convenient and cool ;)
>>
>> To manage notifications about this bug go to:
>> https://bugs.launchpad.net/command-not-found/+bug/1184565/+subscriptions
>>
>
>

Revision history for this message
Gerhard Burger (burger.ga) wrote :

You can set this bug to Won't fix, the desired behaviour is already available by exporting COMMAND_NOT_FOUND_INSTALL_PROMPT

However this behaviour is currently broken because of some python2 code that no longer works (bug 1073919), I attached a branch to that bug which solves the issue.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.