![zsh의 특정 디렉토리에 대한 사용자 정의 파일 이름 완성을 작성하는 방법은 무엇입니까?](https://linux55.com/image/81276/zsh%EC%9D%98%20%ED%8A%B9%EC%A0%95%20%EB%94%94%EB%A0%89%ED%86%A0%EB%A6%AC%EC%97%90%20%EB%8C%80%ED%95%9C%20%EC%82%AC%EC%9A%A9%EC%9E%90%20%EC%A0%95%EC%9D%98%20%ED%8C%8C%EC%9D%BC%20%EC%9D%B4%EB%A6%84%20%EC%99%84%EC%84%B1%EC%9D%84%20%EC%9E%91%EC%84%B1%ED%95%98%EB%8A%94%20%EB%B0%A9%EB%B2%95%EC%9D%80%20%EB%AC%B4%EC%97%87%EC%9E%85%EB%8B%88%EA%B9%8C%3F.png)
제목 앞에 날짜가 있는 파일 이름은 탭 완성이 어렵다는 것을 알았습니다. 이 디렉토리에 대한 사용자 정의 완성 기능을 작성하고 싶습니다. 기본 완성 문자 대신 완성 문자를 사용하도록 지정하려면 어떻게 해야 합니까?
답변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
}
문서: