title: Enable autocomplete for parsed arguments in getopts
body: <p>I have a bash script that uses <code>getopts</code> to parse command line arguments. One of the arguments, <code>-l &lt;name&gt;</code> is directed to an <code>if</code> statement that determines certain settings. Is it possible to have autocomplete work in the command line for entering the <code>&lt;name&gt;</code> parameter?</p>
  <p>Here is the command line parsing part (<code>getopts</code>) of my script:</p>
  <pre><code>while getopts 'l:r:m:?h' c
  do
    case $c in
      l) 
          library=$OPTARG 
          ;;
      r)  
          rename_config=$OPTARG 
          ;;
      m)  
          align_mm=$OPTARG
          ;;  
      h|?) usage 
          ;;
    esac
  done
  </code></pre>
  <p>The library option (<code>-l</code>) refers to this part of the script:</p>
  <pre><code>if [ $library = &quot;bassik&quot; ];
      then
          read_mod=&quot;clip&quot;
          clip_seq=&quot;GTTTAAGAGCTAAGCTGGAAACAGCATAGCAA&quot;
          echo &quot;Bassik library selected&quot;
  elif [ $library = &quot;moffat_tko1&quot; ];
      then
          read_mod=&quot;trim&quot;
          sg_length=20    
          echo &quot;Moffat TKO1 library selected&quot;
  elif [ $library = &quot;sabatini&quot; ];
      then
          read_mod=&quot;trim&quot;
          sg_length=20    
          echo &quot;Sabatini library selected&quot;
  fi
  </code></pre>
  <p>The part where the auto-completion should work are for &quot;bassik&quot;, &quot;moffat_tko1&quot;, and &quot;sabatini&quot; parameters.
  So far, I have tried just hitting <code>&lt;TAB&gt;</code> right after <code>./script.sh -l</code>, but that does not work. I have googled it, but could not find anything that fits my situation (not sure also how to call this, new to bash).</p>