From 9d5ec5e3bc01c6174dea048e118edee579c36565 Mon Sep 17 00:00:00 2001
From: nsfisis _composer 関数を定義しているファイルの冒頭にも書かれている。
# - @todo We don't complete custom commands (including script aliases). This is
-# easy to do in the general case, but it probably requires some clever caching
-# to avoid introducing a noticeable lag to every completion operation, due to
-# the way command resolution works and the fact that discovering custom
-# commands requires making slow calls to Composer
-
+ # - @todo We don't complete custom commands (including script aliases). This is
+# easy to do in the general case, but it probably requires some clever caching
+# to avoid introducing a noticeable lag to every completion operation, due to
+# the way command resolution works and the fact that discovering custom
+# commands requires making slow calls to Composer
~/.zshrc にすべて書く前提だが、autoload を設定するなどすれば別ファイルに分離できる (詳細な手順は割愛)。
compdef _my_composer composer composer.phar
-
+ compdef _my_composer composer composer.phar
compdef は Zsh が用意している関数で、第一引数に補完関数の名前、第二引数以降に補完を適用するコマンド名を並べる。この場合は、composer コマンドや composer.phar コマンドに対して _my_composer を使って補完をおこなうよう定義している。
@@ -149,10 +147,9 @@
次に _my_composer を定義する。基本的にはデフォルトの composer コマンドの補完関数 (つまり _composer 関数) を使い、それが何も返さなかった場合に限り、Zsh のファイル・ディレクトリ補完へフォールバックする。
function _my_composer() {
- _composer "$@" || _files "$@"
-}
-
+ function _my_composer() {
+ _composer "$@" || _files "$@"
+}
_composer コマンドは何も補完候補がなかったとき非ゼロな exit status で終了するので、そうであったなら _files を呼び出す。_files は、Zsh がデフォルトで用意しているファイル・ディレクトリの補完をおこなう関数である。
--
cgit v1.3-1-g0d28