📢 Webサイト閉鎖と移転のお知らせ
このWebサイトは2026年9月に閉鎖いたします。
新しい記事は移転先で追加しております。(旧サイトでは記事を追加しておりません)
| 238行目: | 238行目: | ||
complete -c <コマンド> -e | complete -c <コマンド> -e | ||
</syntaxhighlight> | </syntaxhighlight> | ||
<br><br> | |||
== 補完と関数の組み合わせ == | |||
以下の例では、Systemdバージョンに応じて、異なる補完を提供している。<br> | |||
<br> | |||
<syntaxhighlight lang="fish"> | |||
set -l systemd_version (systemctl --version | string match "systemd*" | string replace -r "\D*(\d+)\D.*" '$1') | |||
if test $systemd_version -gt 208 2>/dev/null | |||
set commands $commands cat | |||
if test $systemd_version -gt 217 2>/dev/null | |||
set commands $commands edit | |||
end | |||
end | |||
</syntaxhighlight> | |||
<br><br> | |||
== 外部コマンドの使用 == | |||
<u>/<Fishのインストールディレクトリ>/share/fish/functions</u>ディレクトリに定義した関数を使用して、動的に補完候補を生成することができる。<br> | |||
<br><br> | <br><br> | ||