테스트.zsh:
#!/usr/bin/env zsh
for f in ${fpath}; do
echo ${f}
done
산출:
/usr/local/share/zsh/site-functions
/usr/share/zsh/functions/Calendar
/usr/share/zsh/functions/Completion
/usr/share/zsh/functions/Completion/AIX
/usr/share/zsh/functions/Completion/BSD
/usr/share/zsh/functions/Completion/Base
/usr/share/zsh/functions/Completion/Cygwin
/usr/share/zsh/functions/Completion/Darwin
/usr/share/zsh/functions/Completion/Debian
/usr/share/zsh/functions/Completion/Linux
/usr/share/zsh/functions/Completion/Mandriva
/usr/share/zsh/functions/Completion/Redhat
/usr/share/zsh/functions/Completion/Solaris
/usr/share/zsh/functions/Completion/Unix
/usr/share/zsh/functions/Completion/X
/usr/share/zsh/functions/Completion/Zsh
/usr/share/zsh/functions/Exceptions
/usr/share/zsh/functions/MIME
/usr/share/zsh/functions/Misc
/usr/share/zsh/functions/Newuser
/usr/share/zsh/functions/Prompts
/usr/share/zsh/functions/TCP
/usr/share/zsh/functions/VCS_Info
/usr/share/zsh/functions/VCS_Info/Backends
/usr/share/zsh/functions/Zftp
/usr/share/zsh/functions/Zle
명령줄 출력에는 몇 가지 추가 항목이 있지만 다음과 같습니다.
╭─ting@core ~/code/autojump ‹install-zsh-local*›
╰─➤ echo $fpath
/home/ting/code/oh-my-zsh/plugins/git
/home/ting/code/oh-my-zsh/functions
/home/ting/code/oh-my-zsh/completions
/usr/local/share/zsh/site-functions
/usr/share/zsh/functions/Calendar
/usr/share/zsh/functions/Completion
/usr/share/zsh/functions/Completion/AIX
/usr/share/zsh/functions/Completion/BSD
/usr/share/zsh/functions/Completion/Base
/usr/share/zsh/functions/Completion/Cygwin
/usr/share/zsh/functions/Completion/Darwin
/usr/share/zsh/functions/Completion/Debian
/usr/share/zsh/functions/Completion/Linux
/usr/share/zsh/functions/Completion/Mandriva
/usr/share/zsh/functions/Completion/Redhat
/usr/share/zsh/functions/Completion/Solaris
/usr/share/zsh/functions/Completion/Unix
/usr/share/zsh/functions/Completion/X
/usr/share/zsh/functions/Completion/Zsh
/usr/share/zsh/functions/Exceptions
/usr/share/zsh/functions/MIME
/usr/share/zsh/functions/Misc
/usr/share/zsh/functions/Newuser
/usr/share/zsh/functions/Prompts
/usr/share/zsh/functions/TCP
/usr/share/zsh/functions/VCS_Info
/usr/share/zsh/functions/VCS_Info/Backends
/usr/share/zsh/functions/Zftp
/usr/share/zsh/functions/Zle
스크립트가 시스템 대신 사용자의 fpath에 액세스하도록 하려면 어떻게 해야 합니까?
답변1
fpath
사용자가 키-값 구성 파일의 간단한 할당을 통해 설정되지 않고 잠재적으로 복잡한 스크립트를 통해 설정되기 때문에 실제로 그렇게 할 수 없습니다 . 예를 들어 my는 fpath
zsh 버전과 시스템에 존재하는 디렉터리에 따라 달라집니다. 사용자의 를 얻을 수 있지만 ~/.zshrc
이는 다양한 다른 작업을 수행할 수 있습니다(특히 zsh가 터미널에서 실행되지 않으면 작동하지 않을 수 있으며 내용을 인쇄할 수 있습니다. 그렇지 않으면 셸이 대화형이라고 가정합니다).
zsh source ~/.zshenv
이므로 사용자는 fpath
거기에서 설정하는 것이 좋습니다.