From 9d5ec5e3bc01c6174dea048e118edee579c36565 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sat, 7 Feb 2026 23:06:23 +0900 Subject: fix(style): fix codeblock style for rouge --- .../index.html | 23 ++++++++++------------ 1 file changed, 10 insertions(+), 13 deletions(-) (limited to 'services/nuldoc/public/blog/posts/2024-04-29') diff --git a/services/nuldoc/public/blog/posts/2024-04-29/zsh-file-completion-for-composer-custom-commands/index.html b/services/nuldoc/public/blog/posts/2024-04-29/zsh-file-completion-for-composer-custom-commands/index.html index 065a11da..118c0d58 100644 --- a/services/nuldoc/public/blog/posts/2024-04-29/zsh-file-completion-for-composer-custom-commands/index.html +++ b/services/nuldoc/public/blog/posts/2024-04-29/zsh-file-completion-for-composer-custom-commands/index.html @@ -15,7 +15,7 @@ 【Zsh】 Composer のカスタムコマンドに対する Zsh 補完で引数にファイルを補完させる|REPL: Rest-Eat-Program Loop - +
@@ -116,12 +116,11 @@ このことは、先ほどリンクを載せた _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
@@ -139,8 +138,7 @@ まずは、Zsh で補完関数を提供する場合のボイラープレートコードを書く。以下は ~/.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