If you want to customize the completion on a per-script basis, then one way to approach this problem would be to use bash_completion with a custom completion function. This function could parse the given perl script for completion hints which could be passed to compgen (a bash builtin).

I haven't worked with bash_completion enough to provide a working example unfortunately. One potential shortcoming would be that you need to tell bash when to run this completion code. This is typically done by specifying the completion logic for a given command. (e.g. perl is handled by the _perl function).

Example code with completion config in comments

#!/usr/bin/perl #complete -G '*.bak'
And awk to extract it:
awk 'NR == 1 {next} /^\#complete/ {print} /^[^#]/ {exit}' $filename
Explanation of the awk:
  1. NR == 1 {next}
    Skip the first record
  2. /^\#complete/ {print}
    Print any lines that start with #complete
  3. /^^#/ {exit}
    Stop processing when a non-comment line is reached

In reply to Re^2: (OT) Bash Tabbing by imp
in thread (OT) Bash Tabbing by qbxk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.