「Fishの基礎 - 補完」の版間の差分

ナビゲーションに移動 検索に移動
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>


案内メニュー