1#! /bin/bash 2# Completion for bash: 3# 4# (1) install this file, 5# 6# (2) load the script, and 7# . ~/.profile.d/rb_optparse.bash 8# 9# (3) define completions in your .bashrc, 10# rb_optparse command_using_optparse_1 11# rb_optparse command_using_optparse_2 12 13_rb_optparse() { 14 COMPREPLY=($("${COMP_WORDS[0]}" "--*-completion-bash=${COMP_WORDS[COMP_CWORD]}")) 15 return 0 16} 17 18rb_optparse () { 19 [ $# = 0 ] || complete -o default -F _rb_optparse "$@" 20} 21