ntu/completions/ntu.bash

40 lines
1.1 KiB
Bash

# Bash completion for ntu (NameToUnix)
_ntu_completion() {
local cur prev opts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
# All available options
opts="--recursive --conf --dry-run --no-changes --quiet --force --exclude --verbose --modify-root --special --no-color --help --version -r -n -q -f -e -v -h -V"
# Handle options that require arguments
case "${prev}" in
-e|--exclude)
# Suggest glob patterns
COMPREPLY=( $(compgen -W '"*.tmp" "*.log" "*.bak" "*.swp" "*~"' -- ${cur}) )
return 0
;;
--conf)
# Suggest files for config option
COMPREPLY=( $(compgen -f -- ${cur}) )
return 0
;;
*)
;;
esac
# If current word starts with -, complete with options
if [[ ${cur} == -* ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
fi
# Otherwise complete with directories and files
COMPREPLY=( $(compgen -f -- ${cur}) )
return 0
}
# Register completion function
complete -F _ntu_completion ntu