我发现标题前面带有日期的文件名很难用制表符补全。我想为这些目录编写自定义完成函数。如何指定应使用补全符而不是默认补全符?
答案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
}
文档: