# Bash completion for `gdal`

Added in version 3.11.

If Bash is used as an interactive shell, users can benefit from completion, using the <TAB> key. Bash completion is enabled by first sourcing the `$install_prefix/share/bash-completion/completions/gdal` file, which should be automatically done on a number of binary distributions of GDAL.

That script can also be sourced when using zsh as a shell (starting with GDAL 3.11.1)

## Examples of completion

### Example 1: Listing sub-commands of "gdal":

    $ gdal <TAB><TAB>
    ==>
    convert   info      pipeline  raster    vector

### Example 2: Completion of a sub-command from its initial letters:

    $ gdal r<TAB>
    ==>
    $ gdal raster

### Example 3: Listing sub-commands of "gdal raster":

    $ gdal raster<TAB><TAB>
    ==>
    convert    edit       info       pipeline   reproject

### Example 4: Listing switches of "gdal raster"

    $ gdal raster -<TAB><TAB>
    ==>
    --approx-stats   -f               --help           --if             --json-usage     --min-max        --no-fl          --no-md          --oo             --stats
    --checksum       --format         --hist           --input          --list-mdd       --mm             --no-gcp         --no-nodata      --open-option    --subdataset
    --drivers        -h               -i               --input-format   --mdd            --no-ct          --no-mask        --of             --output-format  --version

### Example 5: Listing allowed values for a switch

    $ gdal raster info --of=<TAB><TAB>
    ==>
    json  text

### Example 6: Listing allowed creation options, restricted to those valid for the output format, once the output filename has been specified

    $ gdal raster convert in.tif out.tif --co <TAB><TAB>
    ==>
    ALPHA=                           ENDIANNESS=                      JXL_EFFORT=                      PIXELTYPE=                       SOURCE_PRIMARIES_RED=            TIFFTAG_TRANSFERRANGE_BLACK=
    BIGTIFF=                         GEOTIFF_KEYS_FLAVOR=             JXL_LOSSLESS=                    PREDICTOR=                       SOURCE_WHITEPOINT=               TIFFTAG_TRANSFERRANGE_WHITE=
    BLOCKXSIZE=                      GEOTIFF_VERSION=                 LZMA_PRESET=                     PROFILE=                         SPARSE_OK=                       TILED=
    [ ... snip ... ]

### Example 7: Listing known configuration options starting with AWS

    $ gdal --config AWS_<TAB><TAB>
    ==>
    AWS_ACCESS_KEY_ID=                       AWS_DEFAULT_REGION=                      AWS_REQUEST_PAYER=                       AWS_STS_ENDPOINT=
    AWS_CONFIG_FILE=                         AWS_HTTPS=                               AWS_ROLE_ARN=                            AWS_STS_REGION=
    AWS_CONTAINER_AUTHORIZATION_TOKEN=       AWS_MAX_KEYS=                            AWS_ROLE_SESSION_NAME=                   AWS_STS_REGIONAL_ENDPOINTS=
    AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE=  AWS_NO_SIGN_REQUEST=                     AWS_S3_ENDPOINT=                         AWS_TIMESTAMP=
    AWS_CONTAINER_CREDENTIALS_FULL_URI=      AWS_PROFILE=                             AWS_SECRET_ACCESS_KEY=                   AWS_VIRTUAL_HOSTING=
    AWS_DEFAULT_PROFILE=                     AWS_REGION=                              AWS_SESSION_TOKEN=                       AWS_WEB_IDENTITY_TOKEN_FILE=

### Example 8: Auto-completion of EPSG CRS codes

    $ gdal raster reproject --dst-crs EPSG:432<TAB>
    ==>
    4322 -- WGS 72                  4324 -- WGS 72BE                4326 -- WGS 84                  4327 -- WGS 84 (geographic 3D)  4328 -- WGS 84 (geocentric)     4329 -- WGS 84 (3D)

### Example 9: Auto-completion of filenames in a cloud storage (assuming credentials are properly set up)

    $ gdal raster info /vsis3/my_bucket/b<TAB><TAB>
    ==>
    /vsis3/my_bucket/byte.tif      /vsis3/my_bucket/byte2.tif