Skip to content

rbx completions

Generate a shell completion script. --env and --place complete with the names in the rbxplace.toml of whatever directory you are standing in, so a new env completes without regenerating anything.

rbx completions bash       -o ~/.local/share/bash-completion/completions/rbx
rbx completions zsh        -o "${fpath[1]}/_rbx"
rbx completions fish       -o ~/.config/fish/completions/rbx.fish

PowerShell has no completion directory, so the script goes in a file of its own next to your profile, and the profile loads it:

$f = Join-Path (Split-Path $PROFILE) rbx-completions.ps1
rbx completions powershell -o $f
Add-Content $PROFILE ". `"$f`""

Never -o $PROFILE. -o replaces the file it writes to, so that would erase everything else in your profile. The last line above runs once; regenerating later is the middle line alone.

-o is --output; without it the script goes to stdout, which is what you want for piping into a file yourself.

Shell Where it goes Then
bash ~/.local/share/bash-completion/completions/rbx New shell, or source the file. Needs bash-completion installed
zsh any directory on $fpath, named _rbx New shell, or compinit. ${fpath[1]} is usually writable; if not, pick your own and add it to fpath in .zshrc before compinit
fish ~/.config/fish/completions/rbx.fish Picked up immediately
powershell rbx-completions.ps1 next to $PROFILE, dot-sourced from it New session, or . $PROFILE

The values are not baked in

When you press TAB the script runs rbx env list --names or rbx env list --place-names in the current directory and offers what comes back. Those two listings are a supported surface for exactly this reason: one bare value per line, no colors, no headers, and they will not grow columns.

So a completion script generated once keeps working as rbxplace.toml changes, and it completes different names in different projects without knowing anything about either.

What it does when there is nothing to complete

Outside a project, or with a file that does not parse, both complete to nothing and print nothing. The completion discards the command's stderr and ignores its exit status, so a broken rbxplace.toml never lands in the middle of a half-typed line.

One exception: bash 3.2, the version macOS ships, has no compopt and falls back to offering file names.

--place is completed across every env

The completion does not read the --env you already typed, so when envs hold different places, some of what is offered belongs to another env. The command you run says so if the place is not in the env.

Turning the dynamic part off

rbx completions bash --no-dynamic

A script that never starts a subprocess, and completes --env with file names. Worth having where a completion must not run a program: a locked-down shell, or a machine where rbx is slow to start because it lives on a network drive.

See also

  • rbx env: the file these names come from, and the two listings the script calls