LoginSignup
0
2

More than 5 years have passed since last update.

Prezto の command-not-found なる module を使ってみた。

Last updated at Posted at 2016-12-05

Prezto という Zsh plugin を使っています。 Install 方法は

zplugprezto を install してみた。
http://qiita.com/ticonz/items/fae0d576b3bb00857b50

に書きました。

$HOME/.zplug/repos/sorin-ionescu/prezto/modules ( ただしこの directory は上の記事の方法で install したときのもの。標準とは異なる ) を見ると、いろいろと module が用意されています。今回はそのうち command-not-found なるものを使ってみました。

導入

次の方法 0 、 1 のどちらでも大丈夫です。

方法 0

.zshrc

if [[ -s "${ZDOTDIR:-$HOME}/.zplug/repos/sorin-ionescu/prezto/modules/command-not-found/init.zsh" ]]; then
  source "${ZDOTDIR:-$HOME}/.zplug/repos/sorin-ionescu/prezto/modules/command-not-found/init.zsh"
fi

と書きます。

方法 1

上の記事の方法で zplug を install した場合、 .zshrc

source ~/.zplug/init.zsh

zplug "sorin-ionescu/prezto"

zplug load --verbose

があるはずです。これの zplug "sorin-ionescu/prezto" の次の行に

zplug "modules/command-not-found", from:prezto

を加えます。

この方法はコメントで教えていただきました。ありがとうございます。

機能

未 install の command を Zsh で打つと、 install 方法が表示されるようになります。

例 0

$ tcsh

の結果

before

zsh: command not found: tcsh

after

The program 'tcsh' is currently not installed. You can install it by typing:
sudo apt install tcsh
zsh: command not found: tcsh

例 1

$ qmail

の結果

before

zsh: command not found: qmail

after

No command 'qmail' found, did you mean:
 Command 'dmail' from package 'uw-mailutils' (universe)
 Command 'qail' from package 'qmail' (universe)
 Command 'kmail' from package 'kmail' (universe)
 Command 'mail' from package 'mailutils' (universe)
 Command 'tmail' from package 'uw-mailutils' (universe)
 Command 'cmail' from package 'xboard' (universe)
 Command 'rmail' from package 'masqmail' (universe)
 Command 'rmail' from package 'postfix' (main)
 Command 'rmail' from package 'exim4-daemon-light' (main)
 Command 'rmail' from package 'exim4-daemon-heavy' (main)
 Command 'rmail' from package 'rmail' (universe)
 Command 'rmail' from package 'courier-mta' (universe)
 Command 'wmail' from package 'wmail' (universe)
zsh: command not found: qmail

所感

これは便利だと思います。 command not found と言われた後、ぐぐったり apt-cache search で探す手間が省けます。

0
2
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2