command-not-found效果和ubuntu上的效果差别很大
Tofloor
poster avatar
chuqq
deepin
2018-02-02 05:54
Author
本帖最后由 chuqq 于 2018-2-1 21:59 编辑

希望达到的效果是:
root@TestServer:~# sendemail
程序“sendemail”尚未安装。 您可以使用以下命令安装:
apt-get install sendemail




我通过如下方式安装command-not-found:
$ sudo apt install command-not-found
// 省略部分输出
The system-wide cache is empty. You may want to run 'apt-file update'
as root to update the cache.
正在设置 command-not-found (0.2.38-4) ...
You need to run 'update-command-not-found' as root to update the cache.

然后我:
$ sudo apt-file update
$ sudo update-command-not-found

最后效果:
$ sendmail
The program 'sendmail' is currently not installed.  To run 'sendmail' please ask your administrator to install the package 'citadel-mta'
sendmail: command not found


问题:为什么效果和ubuntu上的command-not-found差距这么大?


Reply Favorite View the author
All Replies
avatar
scanf
deepin
2018-02-02 06:24
#1
本帖最后由 scanf 于 2018-2-2 09:48 编辑

try this:
  1. sudo apt-get install command-not-found -y
  2. sudo update-command-not-found
Copy the Code

Reply View the author
avatar
jingle
deepin
2018-02-02 16:55
#2
执行了还是提示
  1. root@jingle:/home/jingle# sendeamil
  2. Could not find the database of available applications, run update-command-not-found as root to fix this
  3. sendeamil: command not found
Copy the Code
Reply View the author
Comments
scanf
2018-02-02 17:50
试下4楼,少了一个步骤。
avatar
scanf
deepin
2018-02-02 17:49
#3
本帖最后由 scanf 于 2018-2-2 09:52 编辑

update:

在.bashrc中添加:
  1. if [ -x /usr/bin/command-not-found ]; then
  2.     function command_not_found_handle {
  3.         /usr/bin/command-not-found $1
  4.         return $?
  5.     }
  6. fi
Copy the Code
Reply View the author
Comments
jingle
2018-02-02 19:05
依旧不行 source了
avatar
chuqq
deepin
2018-02-02 17:51
#4

我主贴中写了,通过如下方式可以工作,但是提示信息和ubuntu差的较多,而且没有中文化,猜测是不是debian的包和ubuntu的工作效果还是有些差异:

$ sudo apt-file update
$ sudo update-command-not-found

$ sendmail
The program 'sendmail' is currently not installed.  To run 'sendmail' please ask your administrator to install the package 'citadel-mta'
sendmail: command not found
Reply View the author
avatar
scanf
deepin
2018-02-02 17:59
#5
https://bbs.deepin.org/post/152784
我主贴中写了,通过如下方式可以工作,但是提示信息和ubuntu差的较多,而且没有中文化,猜测是不是debian ...

1. 包在仓库中的位置不同吧,所以提示需要安装的package不同;
2. 提示效果其实可以定制的,不过要修改源码(是python脚本吧?在哪里?)。
Reply View the author
avatar
scanf
deepin
2018-02-02 20:48
#6

work for me, refer:
  1. https://linux.byexamples.com/archives/276/cli-magic-command-not-found-suggest-what-to-apt-get/
Copy the Code
Reply View the author
avatar
153******45
deepin
2018-02-03 06:55
#7
本帖最后由 a996535783 于 2018-2-2 23:03 编辑


从Ubuntu源找最新版本安装吧,debian这边好久不更新了
不要加源下载所有包手动安装,在把附件解压放到/usr/share/locale/zh_CN/LC_MESSAGES就好了
command-not-found.mo.zip
Reply View the author
avatar
chuqq
deepin
2018-02-03 16:10
#8
https://bbs.deepin.org/post/152784
从Ubuntu源找最新版本安装吧,debian这边好久不更新了
不要加源下载所有包手动安装,在把附件解压放到/usr ...

赞!多谢!

这样一看,还是觉得ubuntu用得更顺手一点。。
Reply View the author
avatar
jingle
deepin
2018-02-05 17:29
#9
https://bbs.deepin.org/post/152784
从Ubuntu源找最新版本安装吧,debian这边好久不更新了
不要加源下载所有包手动安装,在把附件解压放到/usr ...

是我的姿势不对
sendmail
Could not find the database of available applications, run update-command-not-found as root to fix this
sendmail: command not found
还是不行
Reply View the author
avatar
153******45
deepin
2018-02-05 17:50
#10
本帖最后由 a996535783 于 2018-2-5 09:56 编辑
jingle 发表于 2018-2-5 09:29
是我的姿势不对
sendmail
Could not find the database of available applications, run update-command- ...

你要安装ubuntu源里的包,版本是0.3,deepin源里的版本太低了,一共四个包,全安上,不要改etc文件夹的配置文件,保持deepin的默认,让后把楼上的附件替换就有中文提示了



Reply View the author
Comments
jingle
2018-02-05 18:03
多谢
avatar
scanf
deepin
2018-04-05 23:27
#11
问题解决了。
1. 首先安装 command-not-found 包.
  1. sudo apt-get install command-not-found -y
  2. sudo update-command-not-found
Copy the Code
2. 在 ~/.bashrc 中添加如下代码.
  1. if [ -x /usr/bin/command-not-found ]; then
  2.     function command_not_found_handle {
  3.         /usr/bin/command-not-found $1
  4.         return $?
  5.     }
  6. fi
Copy the Code
3. 修改 /usr/share/command-not-found/CommandNotFound/CommandNotFound.py 脚本.

4. 效果.
之前:

之后:

Reply View the author