[Gllug] Grepping tab-completions

Tethys tet at createservices.com
Mon Jun 13 09:46:23 UTC 2005


Tom Schutzer-Weissmann writes:

>So what I'd like to do is pipe the names of all the commands
>available on my path that begin with 'k' through grep, but haven't a
>clue how.
>
>What's an easy way to search the path like this?

No easy way that I can think of. You can manually search your
path as others have suggested. Or you can open a large window,
start a command with k, double tab to get a list of completions
and cut and paste the output, which can be grepped separately.
Crude, but it'll work.

Or use this somewhat clunky abuse of programmable completion. Think
up an arbitrarily named command (here I've used "findcommand"). You
then tell bash that when it's completing arguments for that command,
to complete with commands (rather than the default filenames) and to
exclude anything that doesn't match the specified pattern:

	complete -X '!k*exec*' -A command findcommand

You'd then do:

	findcommand k<tab><tab>

to get a list of all commands starting with "k" and containing
the string "exec".

Tet
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug




More information about the GLLUG mailing list