zshの特定のディレクトリのカスタムファイル名補完を作成する方法は?

zshの特定のディレクトリのカスタムファイル名補完を作成する方法は?

タイトルの前に日付があるファイル名はタブの完成が難しいことがわかりました。このディレクトリのカスタム補完機能を作成したいと思います。デフォルトの完成文字の代わりに完成文字を使用するように指定するにはどうすればよいですか?

ベストアンサー1

いいえ指定するしかし、パッチすることはできます。_path_files完全な機能これを達成するには:

# Load the `functions` table.
zmodload -Fa zsh/parameter p:functions

# Load the definition of _path_files.
autoload +X -Uz _path_files

# Make a copy of it.
functions[_original_path_files]=$functions[_path_files]

# Replace the original.
_path_files() {
  # `$words[CURRENT]` is the current word under completion.
  # `:a` turns it into an absolute path.
  if [[ $words[CURRENT]:a == <pattern that matches the dirs in question>/* ]]; then
    <your special completion function> "$@"
  else
    _original_path_files "$@"
  fi
}

文書:

おすすめ記事