web-dev-qa-db-ja.com

コマンドが見つからない場合に推奨されるpacmanインストール行を取得する

Ubuntuで、インストールされていないがデータベースから認識しているアプリケーションに対してコマンドを入力すると、次のようなメッセージが表示されます。

~ $ kate
The program 'kate' is currently not installed.  You can install it by typing:
Sudo apt-get install kate

Arch Linuxで同様のメッセージを受け取る方法はありますか?

6

まったく同じものを探していて、ここで素晴らしい解決策を見つけました: https://bbs.archlinux.org/viewtopic.php?pid=874678#p874678

Pkgtoolsをインストールすると、より多くの情報が表示されます。

(2/2) installing pkgtools
- Make sure to run pkgfile --update before use
- pkgfile includes a "command not found" hook for both zsh and bash.

  This will automatically run pkgfile whenever you run
  a command which the Shell cannot find. If you want
  this functionality, set CMD_SEARCH_ENABLED to 1 in
  /etc/pkgtools/pkgfile.conf (or per-user by copying
  that file to ${XDG_CONFIG_HOME}/pkgtools/pkgfile.conf), then
  in your current Shell run:
  source /etc/profile

- An entry has been placed in /etc/cron.daily to run pkgfile --update
  If you do not want this functionality, set UPDATE_CRON=0 in /etc/pkgtools/pkgfile.conf
1
Edke

したがって、これはpythonの一部のようで、ubuntuでは次のようになります。
/usr/lib64/python2.7/dist-packages/CommandNotFound/CommandNotFound.py
次の関数で:

def advise(self, command, ignore_installed=False):
    " give advice where to find the given command to stderr "

これを実装するlaunchpadプロジェクトを見つけました: https://launchpad.net/command-not-found

お役に立てれば

2
madmaze