First, let me clear up a few misconceptions in your question.
- By and large, completion settings are distributed with your shell, not with individual programs. While individual programs could come bundled with completion settings, the same way they're bundled with desktop launchers and menu entries (at least in the major desktop distributions), in practice, in practice, application programmers don't write completion settings, shell developers do.
- Completion is generally tuned to complete everything that could be useful, not just the most common cases. For example, Inkscape can open JPEG files, even if it's usually not the best program for that, so
*.jpg
files are included in completions for inkscape
. Furthermore, by default, completion includes all files.
For bash, completion settings are distributed in the separate bash-completion package. As of version 2.1, it has no settings for gimp
, so completion of arguments to gimp
simply offers all files. For inkspace
, the completion function is aware of a few options, and completes a large set of image file extensions.
You can display or modify the completion settings in bash with the complete
builtin. For example:
$ complete -p inkscape
complete -F _inkscape inkscape
$ type _inkscape
_inkscape is a function
_inkscape ()
{
local cur;
COMPREPLY=();
cur=${COMP_WORDS[COMP_CWORD]};
if [[ "$cur" == -* ]]; then
COMPREPLY=($( compgen -W '-? --help --usage -V --version \
-z --without-gui -g --with-gui -f --file= -p --print= \
-e --export-png= -d --export-dpi= -a --export-area= \
-w --export-width= -h --export-height= -i --export-id= \
-j --export-id-only -t --export-use-hints -b --export-background= \
-y --export-background-opacity= -l --export-plain-svg= -s --slideshow' -- $cur ));
else
_filedir '@(ai|ani|bmp|cur|dia|eps|gif|ggr|ico|jpe|jpeg|jpg|pbm|pcx|pdf|pgm|png|ppm|pnm|ps|ras|sk|svg|svgz|targa|tga|tif|tiff|txt|wbmp|wmf|xbm|xpm)';
fi
}
$ complete -p gimp
complete -F _minimal gimp
If you don't like what the _inkscape
function does, write your own. For gimp
, bash knows of no completion; once you've tried completion at least once, it records _minimal
as the completion function. Define your own function (conventionally called _gimp
, but it isn't an obligation) if you want something different.
complete -F _gimp gimp
_gimp () {
_filedir '@(ai|ani|bmp|cur|gif|ggr|ico|jpe|jpeg|jpg|pbm|pcx|pgm|png|ppm|pnm|ras|sk|targa|tga|tif|tiff|wbmp|wmf|xbm|xpm)'
}
Zsh offers more sophisticated mechanisms such as completing a restricted set, but falling back on a broader set if there are no matches.