问题描述
如果您尝试执行未安装的程序,您将收到一条消息
The program 'x' is currently not installed. You can install it by typing:
sudo apt-get install x
而不是让您为您安装程序,您必须键入实际命令。如何改变这种行为?
最佳方法
负责此行为的包是 command-not-found 包,它已经包含了所需的行为,尽管它在默认情况下是禁用的。您可以通过将以下行添加到您的 ~/.bashrc
来启用它
export COMMAND_NOT_FOUND_INSTALL_PROMPT=1
现在行为更改为
The program 'x' is currently not installed. You can install it by typing:
sudo apt-get install x
Do you want to install it? (N/y)
注意:\n如果您收到有关 python 崩溃的消息(特别是 AttributeError: 'str' object has no attribute 'decode'
),这是 bug 1073919 。 Raring 和 Saucy 的修复程序已经可用。或者(仅限高级用户),您可以更改文件 /usr/lib/python3/dist-packages/CommandNotFound/CommandNotFound.py
,请参阅附加到错误报告的差异以了解需要更改的行。
编辑:修复现在在 Raring (SRU) 的 0.3ubuntu7.1 版本和 Saucy 的 0.3ubuntu8 版本中发布。