_nl() { 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="nl" ;; *) ;; esac done case "${cmd}" in nl) opts="-b -d -f -h -i -l -n -p -s -v -w -V --help --body-numbering --section-delimiter --footer-numbering --header-numbering --line-increment --join-blank-lines --number-format --no-renumber --number-separator --starting-line-number --number-width --version" if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 fi case "${prev}" in --body-numbering) COMPREPLY=($(compgen -f "${cur}")) return 0 ;; -b) COMPREPLY=($(compgen -f "${cur}")) return 0 ;; --section-delimiter) COMPREPLY=($(compgen -f "${cur}")) return 0 ;; -d) COMPREPLY=($(compgen -f "${cur}")) return 0 ;; --footer-numbering) COMPREPLY=($(compgen -f "${cur}")) return 0 ;; -f) COMPREPLY=($(compgen -f "${cur}")) return 0 ;; --header-numbering) COMPREPLY=($(compgen -f "${cur}")) return 0 ;; -h) COMPREPLY=($(compgen -f "${cur}")) return 0 ;; --line-increment) COMPREPLY=($(compgen -f "${cur}")) return 0 ;; -i) COMPREPLY=($(compgen -f "${cur}")) return 0 ;; --join-blank-lines) COMPREPLY=($(compgen -f "${cur}")) return 0 ;; -l) COMPREPLY=($(compgen -f "${cur}")) return 0 ;; --number-format) COMPREPLY=($(compgen -W "ln rn rz" -- "${cur}")) return 0 ;; -n) COMPREPLY=($(compgen -W "ln rn rz" -- "${cur}")) return 0 ;; --number-separator) COMPREPLY=($(compgen -f "${cur}")) return 0 ;; -s) COMPREPLY=($(compgen -f "${cur}")) return 0 ;; --starting-line-number) COMPREPLY=($(compgen -f "${cur}")) return 0 ;; -v) COMPREPLY=($(compgen -f "${cur}")) return 0 ;; --number-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 _nl -o nosort -o bashdefault -o default nl else complete -F _nl -o bashdefault -o default nl fi