rfswift completion
Generate and install shell completion for bash, zsh and fish.
Shell completion lets you press Tab to complete rfswift commands, flags, container names and image names. rfswift completion installs it for your shell. It covers the whole v4 command tree, including the package names of rfswift env install.
If you installed RF Swift from a Linux package (deb, rpm, pacman), bash, zsh and fish completion is already installed.
rfswift completion # detects your shell and installs completionAfter installing, reload your shell (source ~/.bashrc, or open a new terminal) before Tab works.
Synopsis
rfswift completion # detect the shell and install
rfswift completion bash
rfswift completion zsh
rfswift completion fish
rfswift completion powershellrfswift completion bash|zsh|fish --install writes the script into your platform’s completion folder for you.
Examples
Without an argument, RF Swift detects your shell and installs the script:
rfswift completion
# Detected shell: bash
# Installing completion script to /etc/bash_completion.d/rfswift
# ✓ Completion script installed successfullyOr name the shell yourself:
rfswift completion bash
rfswift completion zsh
rfswift completion fish
rfswift completion powershellWhere the scripts go
Bash
System-wide (needs sudo): /etc/bash_completion.d/rfswift. For your user only: ~/.bash_completion.d/rfswift or ~/.bash_completion.
Make sure your ~/.bashrc loads it:
[[ -f ~/.bash_completion ]] && source ~/.bash_completionZsh
Usual locations:
~/.zsh/completion/_rfswift
~/.oh-my-zsh/completions/_rfswift
/usr/local/share/zsh/site-functions/_rfswift
${fpath[1]}/_rfswiftMake sure your ~/.zshrc adds the folder and starts the completion system:
fpath=(~/.zsh/completion $fpath)
autoload -Uz compinit
compinitFish
~/.config/fish/completions/rfswift.fish. Fish loads it automatically; nothing else to set up.
PowerShell
Find your profile, then load the completion script from it:
# Check profile path
echo $PROFILE
# Typical locations:
# Windows PowerShell:
# ~\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
# PowerShell Core:
# ~\Documents\PowerShell\Microsoft.PowerShell_profile.ps1. "C:\Path\To\CompletionScripts\rfswift.ps1"What completes
Commands and command groups:
rfswift <Tab>
# Shows: container, image, env, config, host, usb, audit, ...Subcommands:
rfswift image <Tab>
# Shows: local, remote, pullFlags:
rfswift container create -<Tab>
# Shows: -i, -n, -b, -p, -d, etc.Container names:
rfswift container shell -c <Tab>
# Shows: container1, container2, container3, etc.Image names:
rfswift container create -i <Tab>
# Shows: penthertz/rfswift_resolute:sdr_full, penthertz/rfswift_resolute:wifi, etc.Completion only offers what makes sense at that point: container names from your containers, image names from your local images, and common values for flags.
Troubleshooting
Tab does nothing
Check that the completion file exists and that your shell loads it, then reload your shell.
Bash:
ls -la ~/.bash_completion.d/rfswift
ls -la ~/.bash_completion
grep bash_completion ~/.bashrc
echo '[[ -f ~/.bash_completion ]] && source ~/.bash_completion' >> ~/.bashrc
source ~/.bashrcZsh:
ls -la ~/.zsh/completion/_rfswift
echo $fpath
cat >> ~/.zshrc << 'EOF'
fpath=(~/.zsh/completion $fpath)
autoload -Uz compinit
compinit
EOF
source ~/.zshrcFish:
ls -la ~/.config/fish/completions/rfswift.fish
fish_update_completions
exec fish“Permission denied” when installing
The system-wide folder needs root. Check it, then either install for your user only or use sudo:
ls -ld /etc/bash_completion.d
rfswift completion bash # installs to ~/.bash_completion.d/
sudo rfswift completion bash # system-wideCompletion still shows old commands
Clear the cached completion, install it again and reload.
Bash:
complete -r rfswift
rfswift completion bash
source ~/.bashrcZsh:
rm -f ~/.zcompdump*
rfswift completion zsh
autoload -Uz compinit
compinit
source ~/.zshrcFish:
rm -rf ~/.cache/fish/
rfswift completion fish
exec fishAnother tool’s completion gets in the way
Find which completion is active and whether several rfswift binaries are installed, remove the conflicting one, and install again:
complete -p rfswift # Bash
which -a rfswift # Check multiple installations
rm /path/to/conflicting/completion
rfswift completionYour shell isn’t detected
Name the shell yourself, or set SHELL:
rfswift completion bash
export SHELL=/bin/bash
rfswift completionRelated
- update: refresh completion after an update
- container install