[gdal-dev] Any way to get an autocompletion for ogr/gdal utilities?
Markus Neteler
neteler at osgeo.org
Thu Feb 3 02:02:25 PST 2022
Hi Thomas,
On Wed, Feb 2, 2022 at 11:59 PM Thomas Gratier
<osgeo.mailinglist at gmail.com> wrote:
>
> Hello,
>
> On Linux, when I type `ogr` in a command line, and on the keyboard type on "tab" key, I get all binaries starting with `ogr` e.g
>
> > ogr2ogr ogrinfo ogrlineref ogrmerge.py ogrtindex
>
> When using command line like git, I type `git commit --` then use again the tab key and it returns something like below
>
> > --ahead-behind --date= --include --no-verify --reedit-message= --status
> > --all --dry-run --interactive --null --reset-author --template=
> > --amend --edit --long --only --reuse-message= --untracked-files
> > --author= --file= --message= --patch --short --verbose
> > --branch --fixup= --no-edit --porcelain --signoff --verify
> > --cleanup= --gpg-sign --no-post-rewrite --quiet --squash=
>
> So, I do expect a way to get autocompletion or choice when I do something like `ogr2ogr -` followed by typing on tab key.
>
> Is there an existing script or a tip I'm not aware? Or do I need to work to create it to get something similar to git command where there is a script to add autocompletion?
AFAIK this requires bash/zsh completion support.
E.g., for core Git, on my Fedora box it is defined in
/usr/share/bash-completion/completions/git
and part of the package:
rpm -qf /usr/share/bash-completion/completions/git
git-core-2.34.1-1.fc35.x86_64
Likewise, there is
/usr/share/bash-completion/completions/ogr2ogr
/usr/share/bash-completion/completions/ogrinfo
/usr/share/bash-completion/completions/ogrlineref
/usr/share/bash-completion/completions/ogrmerge.py
/usr/share/bash-completion/completions/ogrtindex
...
Here it works:
ogrinfo --<tab>
--config --format --help-general --locale --pause
--debug --formats --license --optfile --version
Maybe you package installation is incomplete?
Best,
Markus
--
Markus Neteler, PhD
https://www.mundialis.de - free data with free software
https://grass.osgeo.org
https://courses.neteler.org/blog
More information about the gdal-dev
mailing list