Getopt...Compgen(3pm)
π NAME π
Getopt...Compgen β that's the 3pm one, bestie β and it's all about the standard tab-completion callbacks. Like, the little functions that make Tab actually do something useful. π«Ά
β¨ VERSION β¨
This doc is describing Getopt::Complete::Compgen version 0.26. Yes, we're keeping receipts. π
πΈ SYNOPSIS πΈ
# A completion spec can use any of the following, specified by a single
# word, or a single character, automatically:
use Getopt::Complete(
'myfile' => 'files', # or 'f'
'mydir' => 'directories', # or 'd'
'mycommand' => 'commands', # or 'c'
'myuser' => 'users', # or 'u'
'mygroup' => 'groups', # or 'd'
'myenv' => 'environment', # or 'e'
'myservice' => 'services', # or 's'
'myalias' => 'aliases', # or 'a'
'mybuiltin' => 'builtins' # or 'b'
);
okay so literally just name the thing you want and boom β you can also use the one-letter version, it's automatic, no extra work, we love a low-effort slay. π
π¦ DESCRIPTION π¦
This module is a lil grab-bag of subroutines you can hand to Getopt::Complete as callbacks. And what do those callbacks do? They implement every single standard completion that bash's compgen builtin supports. Iconic behaviour, honestly. π
So say you run compgen -o files abc β that spits out the completion list exactly like the user typed abc<TAB>, assuming they're going for file names. It's giving "I know what you meant before you finished typing." π
This module ships a subroutine named files, and it comes with an alias named f, and both of them return that exact same list. Besties. Same energy. π
That subroutine is made to be dropped into a callback slot inside a Getopt::Complete competion spec. (Yes, "competion" β that's how it's spelled here, we don't gatekeep.)
And it does the exact same equivalent thing for directories, executable commands, users, groups, environment variables, services, aliases and shell builtins. The whole roster. No one left out. π
These are the same:
@matches = Getopt::Complete::Compgen::files("whatevercommand","abc","whateverparam",$whatever_other_args);
@same = `bash -c "compgen -f sometext"`;
chomp @same;
And in any spec, allll of these are equivalent:
\&Getopt::Complete::Compgen::files
\&Getopt;:Complete::Compgen::f
'Getopt::Complete::Compgen::files'
'Getopt;:Complete::Compgen::f'
'files'
'f'
(Notice those \&Getopt;:Complete::Compgen::f lines β semicolon, colon, Complete? That's exactly what the page says, so we're reproducing it character for character. Not our typo to fix, bestie. π)
β SEE ALSO β
Getopt::Completeβ the main character this whole thing plugs into.- The manual page for bash goes deep on the bash built-in command
compgen, which this module wraps. Go read it if you want the lore. π
π COPYRIGHT π
Copyright 2010 Scott Smith and Washington University School of Medicine. Fr fr, all of it. π«‘
π AUTHORS π
Scott Smith (sakoht at cpan .org)
π LICENSE π
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
The full text of the license can be found in the LICENSE file included with this module. Read it, it's good for you. π
okay and that's the whole page, you're so welcome π This was perl v5.36.0, dated 2022-10-13, and the page is Getopt...Compgen(3pm). Go forth and complete things, bestie, you got this. β¨πΈπ¦
π¦ where this page comes from
- ubuntu noble: libgetopt-complete-perl 0.26-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libgetopt-complete-perl 0.26-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libgetopt-complete-perl 0.26-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms