#compdef license-tool _license-tool_files() { # system dir local system_dir="/usr/share/license-tool/" for file in "${system_dir}"**(N); do compadd -X "[system]" "${file#"${system_dir}"}" done # user dir if [[ -v XDG_CONFIG_HOME ]]; then local user_dir="${XDG_CONFIG_HOME}/license-tool/" else local user_dir="${HOME}/.config/license-tool/" fi for file in "${user_dir}"**(N); do compadd -X "[user]" "${file#"${user_dir}"}" done } _arguments \ '-h[print help]' \ '-o[output file]:output:_files' \ ':license:_license-tool_files'