Prerequisites

Python 3.7 or later is required.

There are no other absolute requirements, but there are some prerequisites that are helpful for autocompletion of command-line arguments:

First, the bash shell is required for the autocompletion feature to work at all. Some other shells may be able to make use of bash autocompletions through a compatibility feature (e.g. “bashcompinit” in zsh) but that is untested.

Having a recent version of bash also helps to avoid a couple of annoying issues:

  • If you don’t have bash 5 or later, double-quoting a placeholder value on the command line will break autocompletions for all subsequent arguments.

  • If you don’t have bash 4 or later, the lack of the compopt builtin will cause filename completions for directory paths (e.g. when composing the file argument to import/export) to be awkward… you’ll get a trailing space instead of a trailing slash. Other quirks are also possible, and in general this code is not often tested with bash versions older than 4.0.

If you need to update bash, the process will be specific to your operating system. macOS is likely to have an extremely old version of bash by default, and an update is definitely recommended in that case; FYI one solution for updating bash on macOS is to use the homebrew package manager. On Linux systems, if you are able to get at least bash 4 from your official OS repositories, that’s probably good enough; installing some newer-than-approved version of bash in a Linux system is doable but also potentially a source of future problems.

Finally, version 2.2 or later of the “bash-completion” package is a nice-to-have. This package does not enable the basic autocompletion feature – that’s intrinsically part of the bash shell – but it builds on it. If a recent-enough version of bash-completion is present, chaintool can use it to allow autocompletions to be enabled immediately for a newly created “shortcut” script, without requiring you to open a new shell.

The process of getting or updating bash-completion will again be something specific to your system. You can use your package manager to check whether you have bash-completion installed (and which version). Also if you use chaintool x completions to interactively configure the completions feature, it can walk you through a method of checking whether a recent-enough version of bash-completion is installed and in use by your shell.