compgen like a boss

I’ve traditionally used the apropos command to find new commands. But you can also use the compgen command, which looks at the completion matches for given words, to find a list of commands that you can run, simply use compgen with a -c option:

compgen -c

You can parse information for a single command:

compgen -c | grep apropos

You can also use -a for aliases, -b for bash built-ins and -k for bash keys, as well as `-A function` for functions. You can then string ‘em together:

compgen -abckA function

I won’t paste the output but I’ll let you pipe it to grep to compgen like a boss. Enjoy!

Comments are closed.