Skip to content

Shell completion

Generate shell completion scripts for command auto-completion.

Synopsis

dr self completion <shell> 

説明

The self completion command generates shell completion scripts that enable auto-completion for the DataRobot CLI. 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.

使用状況

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):

source <(dr self completion bash) 

Zsh

Setup:

First, ensure completion is enabled:

# Add to ~/.zshrc if not present
autoload -U compinit
compinit 

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):

source <(dr self completion zsh) 

Fish

# Install completion
dr self completion fish > ~/.config/fish/completions/dr.fish

# Reload Fish
source ~/.config/fish/config.fish 

Temporary (current session only):

dr self completion fish | source 

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):

dr self completion powershell | Out-String | Invoke-Expression 

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>
login      logout     set-url

$ dr templates <Tab>
clone      list       setup      status 

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:

# Template names (when connected to DataRobot)
$ dr templates clone <Tab>
python-streamlit  react-frontend  fastapi-backend

# Task names (when in a template directory)
$ dr run <Tab>
build  dev  deploy  lint  test 

トラブルシューティング

Completions not working

Bash:

  1. Verify bash-completion is installed:

    # macOS
    brew list bash-completion@2
    
    # Linux
    dpkg -l | grep bash-completion 
    

  2. Check if completion script exists:

    ls -l /etc/bash_completion.d/dr 
    

  3. Ensure .bashrc sources completions:

    grep bash_completion ~/.bashrc 
    

  4. Reload shell:

    source ~/.bashrc 
    

Zsh:

  1. Verify compinit is called:

    grep compinit ~/.zshrc 
    

  2. Check fpath includes completion directory:

    echo $fpath 
    

  3. Clear completion cache:

    rm -f ~/.zcompdump*
    compinit 
    

  4. Reload shell:

    exec zsh 
    

Fish:

  1. Check completion file:

    ls -l ~/.config/fish/completions/dr.fish 
    

  2. Verify Fish recognizes it:

    complete -C dr 
    

  3. Reload Fish:

    source ~/.config/fish/config.fish 
    

PowerShell:

  1. Check execution policy:
    Get-ExecutionPolicy 
    

If restricted:

Set-ExecutionPolicy RemoteSigned -Scope CurrentUser 

  1. Verify profile loads completion:

    cat $PROFILE 
    

  2. Reload profile:

    . $PROFILE 
    

アクセスが拒否されました

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: 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:

$ dr templates <Tab>
clone   (Clone a template repository)
list    (List available templates)
setup   (Interactive template setup wizard)
status  (Show current template status) 

Dynamic completion

Some completions are generated dynamically:

# Template names from DataRobot API
dr templates clone <Tab>

# Task names from current Taskfile
dr run <Tab>

# Available shells
dr self completion <Tab> 

高度な設定

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