Shell completion¶
Thumbforge can complete its commands, subcommands and options when you press Tab: thumbforge ba becomes thumbforge batch, thumbforge thumb ge becomes thumbforge thumb generate, and thumbforge --ver offers --verbose and --version. It works in bash, zsh, fish and PowerShell (PowerShell 7 and Windows PowerShell 5.1). Values such as video ids are not completed.
The thumbforge command must be on your PATH; Getting started covers that.
Install¶
Run this inside the shell you want completion in:
thumbforge --install-completion
Thumbforge learns which shell you are in from the process that started it, so there is no shell argument: run the command from bash to set up bash, from zsh to set up zsh, and so on. Writing a shell name after it does not select that shell. If you use both PowerShell 7 and Windows PowerShell, run it once in each; they keep separate profiles.
To see what would be installed without changing anything, run thumbforge --show-completion. It prints the script for the current shell, ready to copy into your own configuration.
What each shell gets¶
bash¶
- The script is written to
~/.bash_completions/thumbforge.shand asourceline for it is added to~/.bashrc, once, however often you run the command. - Reload: open a new terminal, or run
source ~/.bashrc. - Undo: delete the script and the
sourceline from~/.bashrc.
zsh¶
- The script is written to
~/.zfunc/_thumbforge. The linefpath+=~/.zfunc; autoload -Uz compinit; compinitis added to~/.zshrc, and so iszstyle ':completion:*' menu selectif that file has nozstyleline yet. - Reload: open a new terminal, or run
exec zsh. - Undo: delete
~/.zfunc/_thumbforge. The lines added to~/.zshrcare generic; remove them only if nothing else of yours relies on them.
fish¶
- The script is written to
~/.config/fish/completions/thumbforge.fish; nothing else changes. - Reload: open a new terminal, or run
exec fish. - Undo: delete that file.
PowerShell¶
- The script is appended to your profile, the file
$PROFILEnames (echo $PROFILEprints the path). The command also runsSet-ExecutionPolicy Unrestricted -Scope CurrentUserso the profile may load. If you would rather not change the execution policy, runthumbforge --show-completionand paste the output into your profile yourself. - The script binds
TabtoMenuComplete, so completion shows a menu of candidates for every command, not only Thumbforge. - Running the install again appends a second copy of the script; install once.
- Reload: open a new terminal, or run
. $PROFILE. - Undo: delete the block from
$PROFILE, fromImport-Module PSReadLinedown to theRegister-ArgumentCompleterline that namesthumbforge. The execution policy stays as it is.
Check that it works¶
In a new terminal, type thumbforge ba and press Tab: it completes to batch.
Thumbforge's completion was tested in bash, PowerShell 7 and Windows PowerShell 5.1. The zsh and fish scripts come from the same generator but have not been run in a live shell yet.