# bash completion for mkhint # Install: sudo cp mkhint.bash-completion /etc/bash-completion.d/mkhint _mkhintfile_completions() { local cur prev repo_dir hint_dir _init_completion || return repo_dir="/var/lib/sbopkg/SBo-danix" hint_dir="/etc/slackrepo/SBo-danix/hintfiles" local all_flags="--version --hintfile --new --list --clean --delete --help" case "$prev" in --new|-n) local -a words=() while IFS= read -r f; do words+=("$(basename "${f%.info}")") done < <(find "$repo_dir" -mindepth 2 -maxdepth 2 -name "*.info" 2>/dev/null) COMPREPLY=($(compgen -W "${words[*]}" -- "$cur")) ;; --hintfile|-f|--delete|-d) local -a words=() for f in "$hint_dir"/*.hint; do [[ -f "$f" ]] && words+=("$(basename "${f%.hint}")") done COMPREPLY=($(compgen -W "${words[*]}" -- "$cur")) ;; --version|-v) # no completion, raw text ;; *) COMPREPLY=($(compgen -W "$all_flags" -- "$cur")) ;; esac } complete -F _mkhintfile_completions mkhintfile.sh mkhintfile