ニッキ

plenvのzsh補完書いた

[]plenvのzsh補完書いた

perlbrewでもrbenvみたいに.perl-versionとかサポートしないかなーって思っていたらtokuhiromさんがplenvというrbenvインスパイアなツールを作っていた (http://blog.64p.org/entry/2013/01/21/134639) ので早速インストールしてみた。


zshで補完できる出来るように補完スクリプト書いたので公開しておきます。


plenv exec|which で補完するのは.plenv/shims以下の実行権限のあるファイルだけにしているけどこれで合ってるのかな?

[zsh] compinit

[] compinitのセキュリティオプション

.zshrcに補完のために以下の設定をする。

autoload -U compinit;

compinit

ここでセキュリティ警告が出る場合があります。

Ignore insecure directories and continue [ny]?

こんなの。

これを回避するには上記の設定を以下のようにします。

autoload -U compinit;

compinit -u

で、-uオプションは何か。というか設定して一年位してやっと調べる気になった。

man zshcompsys に載ってました。

zshオプションって manではinlineで書いてあるので読みにくい。。。

前略

compinit

中略

For security reasons compinit also checks if the completion system would use files not owned by root

or by the current user, or files in directories that are world- or group-writable or that are not

owned by root or by the current user. If such files or directories are found, compinit will ask if

the completion system should really be used. To avoid these tests and make all files found be used

without asking, use the option -u, and to make compinit silently ignore all insecure files and direc-

tories use the option -i. This security check is skipped entirely when the -C option is given.

後略

拙訳

セキュリティのために、compinitは以下のことをチェックします。

・補完システムが使用するファイルの所有者がroot現在ユーザ以外であるか

ファイルが入っているディレクトリ

パーミッション:誰でも書き込み可能もしくはグループ書き込み可能か

rootもしくは現在ユーザ以外が所有しているか

以上のようなファイルディレクトリ発見すると、compinitが補完システムを使用

するか聞いてきます。関連して以下のオプションがあります。

-u : 上記のテストを避けて、すべての発見したファイルを警告なしに使用する

-i : すべての安全でないファイルディレクトリを無視する

-C : セキュリティチェック全体をスキップする

ということでした。