shell completion

Getting tab completions for pdftl in your shell

Details

To set up basic tab completion for pdftl for bash, zsh or powershell:

Completion in bash

$ source <(pdftl --completion bash)

Bash hint: For improved completion behaviour in bash and other readline-enabled software, add the line

set skip-completed-text on

to ~/.inputrc (or create that file if it does not exist). Then

pdftl in.pdf render<LEFT><LEFT><TAB>

should complete correctly to render rather than renderer (with unwanted trailing characters er after the cursor).

Completion in zsh

% source <(pdftl --completion zsh)

Completion in powershell

PS > pdftl --completion powershell | Out-String | Invoke-Expression

Guessing your shell

A bare

pdftl --completion

will try to guess your shell. This might not work, so be careful.

Caching

The first time you use completion, a cache file is generated to speed up future runs, which means the first run might feel a bit slow.

The cache file lives in your user cache directory.

Notes

  • ensure that pdftl is in your PATH if you want to use completion.

  • pdftk --completion will attempt to guess your shell and output appropriate code for you to source from the shell. It might fail, or be wrong.

Examples

output bash completion code. This must be sourced from bash.

pdftl --completion bash

output zsh completion code. This must be sourced from zsh.

pdftl --completion zsh

output powershell completion code. This must be sourced from powershell.

pdftl --completion powershell

attempt to guess your shell and output appropriate completion code.

pdftl --completion

Source: pdftl.cli.completion_setup

Read online: https://pdftl.readthedocs.io/en/stable/general/shell_completion.html

Type: HelpTopic