dr self completion - Shell completion
Generate shell completion scripts for command auto-completion.
Quick start
For most users, setting up shell completion is a single command:
# Generate and install completion for your shell
# Bash (Linux)
dr self completion bash | sudo tee /etc/bash_completion.d/dr
# Zsh
dr self completion zsh > "${fpath[1]}/_dr"
# Fish
dr self completion fish > ~/.config/fish/completions/dr.fish
After installation, reload your shell to activate completions.
[!NOTE] First time? If you're new to the CLI, start with the Quick start for step-by-step setup instructions.
Synopsis
# Generate script for a shell (redirect to install)
dr self completion <shell>
# Interactive install or uninstall
dr self completion install [shell]
dr self completion uninstall [shell]
Supported shells: bash, zsh, fish, powershell.
Description
The self completion command generates shell completion scripts that enable auto-completion for the DataRobot CLI. You can either pass a shell name to output a script (then redirect to a file or pipe as needed), or use the install and uninstall subcommands for interactive setup. Completions provide command, subcommand, and flag suggestions when you press Tab.
Supported shells
bash—Bourne Again Shell.zsh—Z Shell.fish—Friendly Interactive Shell.powershell—PowerShell.
Install and uninstall subcommands
For interactive setup without manually choosing paths:
dr self completion install [shell]—detects your shell (or use optionalbash,zsh,fish,powershell), generates the script, and writes it to the appropriate location for your OS. Use--forceto overwrite existing files.dr self completion uninstall [shell]—removes previously installed completion files.
See the Shell completions guide for step-by-step instructions.
Usage
Bash
Linux:
# Install system-wide
dr self completion bash | sudo tee /etc/bash_completion.d/dr
# Reload shell
source ~/.bashrc
macOS:
# Install via Homebrew's bash-completion
brew install bash-completion@2
dr self completion bash > $(brew --prefix)/etc/bash_completion.d/dr
# Reload shell
source ~/.bash_profile
Temporary (current session only):
Zsh
Setup:
First, ensure completion is enabled:
Installation:
# Option 1: User completions directory
mkdir -p ~/.zsh/completions
dr self completion zsh > ~/.zsh/completions/_dr
echo 'fpath=(~/.zsh/completions $fpath)' >> ~/.zshrc
# Option 2: System directory
dr self completion zsh > "${fpath[1]}/_dr"
# Clear cache and reload
rm -f ~/.zcompdump
source ~/.zshrc
Temporary (current session only):
Fish
# Install completion
dr self completion fish > ~/.config/fish/completions/dr.fish
# Reload Fish
source ~/.config/fish/config.fish
Temporary (current session only):
PowerShell
Persistent:
# Generate completion script
dr self completion powershell > dr.ps1
# Add to PowerShell profile
Add-Content $PROFILE ". C:\path\to\dr.ps1"
# Reload profile
. $PROFILE
Temporary (current session only):
Examples
Generate completion script
# View the generated script
dr self completion bash
# Save to a file
dr self completion bash > dr-completion.bash
# Save for all shells
dr self completion bash > dr-completion.bash
dr self completion zsh > dr-completion.zsh
dr self completion fish > dr-completion.fish
dr self completion powershell > dr-completion.ps1
Install for multiple shells
If you use multiple shells:
# Bash
dr self completion bash > ~/.bash_completions/dr
# Zsh
dr self completion zsh > ~/.zsh/completions/_dr
# Fish
dr self completion fish > ~/.config/fish/completions/dr.fish
Update completions
After updating the CLI:
# Bash
dr self completion bash | sudo tee /etc/bash_completion.d/dr
# Zsh
dr self completion zsh > ~/.zsh/completions/_dr
rm -f ~/.zcompdump
exec zsh
# Fish
dr self completion fish > ~/.config/fish/completions/dr.fish
Completion behavior
Command completion
$ dr <Tab>
auth completion dotenv run templates version
$ dr auth <Tab>
check login logout set-url
$ dr templates <Tab>
list setup
Flag completion
$ dr run --<Tab>
--concurrency --dir --exit-code --help
--list --parallel --silent --watch
--yes
$ dr --<Tab>
--debug --help --verbose
Argument completion
Some commands support argument completion:
Troubleshooting
Completions not working
Bash:
- Verify bash-completion is installed:
- Check if completion script exists:
- Ensure .bashrc sources completions:
- Reload shell:
Zsh:
- Verify compinit is called:
- Check fpath includes completion directory:
- Clear completion cache:
- Reload shell:
Fish:
- Check completion file:
- Verify Fish recognizes it:
- Reload Fish:
PowerShell:
- Check execution policy:
If restricted:
- Verify profile loads completion:
- Reload profile:
Permission denied
Use user-level installation instead of system-wide:
# Bash - user level
mkdir -p ~/.bash_completions
dr self completion bash > ~/.bash_completions/dr
echo 'source ~/.bash_completions/dr' >> ~/.bashrc
# Zsh - user level
mkdir -p ~/.zsh/completions
dr self completion zsh > ~/.zsh/completions/_dr
echo 'fpath=(~/.zsh/completions $fpath)' >> ~/.zshrc
Outdated completions
After updating the CLI, regenerate completions:
# Bash
dr self completion bash | sudo tee /etc/bash_completion.d/dr
source ~/.bashrc
# Zsh
dr self completion zsh > ~/.zsh/completions/_dr
rm -f ~/.zcompdump
exec zsh
# Fish
dr self completion fish > ~/.config/fish/completions/dr.fish
Completion features
Intelligent suggestions
Completions are context-aware:
# Only shows valid subcommands
dr auth <Tab>
# Shows: check login logout set-url (not other commands)
# Only shows valid flags
dr run --l<Tab>
# Shows: --list (not all flags)
Description support
In Fish and PowerShell, completions include descriptions:
Dynamic completion
Some completions are generated dynamically:
Advanced configuration
Custom completion scripts
You can extend or modify generated completions:
# Generate base completion
dr self completion bash > ~/dr-completion-custom.bash
# Edit to add custom logic
vim ~/dr-completion-custom.bash
# Source your custom version
source ~/dr-completion-custom.bash
Completion performance
For faster completions, especially with dynamic suggestions:
# Cache template list
dr templates list > ~/.dr-templates-cache
# Use cached list in custom completion script
See also
- Shell completion guide—detailed setup instructions.
- Quick start—initial setup.
- Command completion is powered by Cobra.