_od() { local i cur prev opts cmd COMPREPLY=() if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then cur="$2" else cur="${COMP_WORDS[COMP_CWORD]}" fi prev="$3" cmd="" opts="" for i in "${COMP_WORDS[@]:0:COMP_CWORD}" do case "${cmd},${i}" in ",$1") cmd="od" ;; *) ;; esac done case "${cmd}" in od) opts="-A -j -N -S -a -b -c -d -D -o -I -L -i -l -x -h -O -s -X -H -e -f -F -t -v -w -V --help --address-radix --skip-bytes --read-bytes --endian --strings --format --output-duplicates --width --traditional --version" if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 fi case "${prev}" in --address-radix) COMPREPLY=($(compgen -f "${cur}")) return 0 ;; -A) COMPREPLY=($(compgen -f "${cur}")) return 0 ;; --skip-bytes) COMPREPLY=($(compgen -f "${cur}")) return 0 ;; -j) COMPREPLY=($(compgen -f "${cur}")) return 0 ;; --read-bytes) COMPREPLY=($(compgen -f "${cur}")) return 0 ;; -N) COMPREPLY=($(compgen -f "${cur}")) return 0 ;; --endian) COMPREPLY=($(compgen -W "big little" -- "${cur}")) return 0 ;; --strings) COMPREPLY=($(compgen -f "${cur}")) return 0 ;; -S) COMPREPLY=($(compgen -f "${cur}")) return 0 ;; --format) COMPREPLY=($(compgen -f "${cur}")) return 0 ;; -t) COMPREPLY=($(compgen -f "${cur}")) return 0 ;; --width) COMPREPLY=($(compgen -f "${cur}")) return 0 ;; -w) COMPREPLY=($(compgen -f "${cur}")) return 0 ;; *) COMPREPLY=() ;; esac COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 ;; esac } if [[ "${BASH_VERSINFO[0]}" -eq 4 && "${BASH_VERSINFO[1]}" -ge 4 || "${BASH_VERSINFO[0]}" -gt 4 ]]; then complete -F _od -o nosort -o bashdefault -o default od else complete -F _od -o bashdefault -o default od fi