op CLI version
2.39.0 (macOS arm64, Homebrew 1password-cli cask)
Goal or desired behavior
op ships a Cobra completion script (op completion zsh|bash|fish; Homebrew installs it to share/zsh/site-functions/_op), but it only completes subcommand and flag names. Every positional argument and flag value I tried returns nothing. This issue lists the gaps, most important first.
1. Plugin names (the reason for this issue)
op plugin init <TAB> # any plugin in `op plugin list`
op plugin run -- <TAB> # any plugin in `op plugin list`
op plugin inspect <TAB> # configured plugins only (~/.config/op/plugins/*.json)
op plugin clear <TAB> # configured plugins only
op already knows both lists. A ValidArgsFunction on these four commands returning the executable field would fix all of them with no change to the generated shell scripts.
2. Static enums, no session needed
op completion <TAB> # bash zsh fish powershell
op --format <TAB> # json human-readable
op item create --category <TAB> # fixed category list
op item template get <TAB> # fixed template list
3. Values that need a signed-in session
op item get <TAB>
op vault get <TAB>
op document get <TAB>
op group get <TAB>
op user get <TAB>
op read op://<TAB>
op item list --vault <TAB>
op item list --categories <TAB>
op item list --tags <TAB>
op signin --account <TAB>
I understand these cost an API round trip and possibly a biometric prompt on a cold session, so they may not be worth it. Listing them for completeness.
Current behavior
Every one of the above completes to nothing, for registry and local-build plugins alike:
$ op __complete plugin init ''
:0
Completion ended with directive: ShellCompDirectiveDefault
$ op __complete plugin run -- ''
:0
Completion ended with directive: ShellCompDirectiveDefault
$ op __complete plugin inspect ''
:0
$ op __complete plugin clear ''
:0
$ op __complete completion ''
:0
$ op __complete --format ''
:0
$ op __complete item get ''
:0
For plugins specifically, you have to run op plugin list in another terminal and copy the name, or guess. With ~90 plugins in the registry, and op plugin init --help itself telling users to "run 'op plugin list'" to find the name, this is a small but constant paper cut.
Workaround for zsh users covering item 1: wrap the generated _op, handle the four plugin positions, and fall through to Cobra for everything else.
_op_with_plugins() {
if [[ $words[2] == plugin && $words[CURRENT-1] == (init|--|inspect|clear) ]]; then
local -a plugins
case $words[3] in
init|run) plugins=(${(f)"$(op plugin list --format=json 2>/dev/null | jq -r '.[].executable')"}) ;;
inspect|clear) plugins=(${XDG_CONFIG_HOME:-$HOME/.config}/op/plugins/*.json(N:t:r)) ;;
esac
_describe 'op plugin' plugins
return
fi
_op "$@"
# the generated _op re-runs `compdef _op op` when zsh autoloads it on its first call
compdef _op_with_plugins op
}
compdef _op_with_plugins op
op plugin list --format=json takes ~100 ms here, so it is fine to call at tab time.
Related: #433 (aliases in plugins.sh breaking completion for the wrapped tool) is a different gap; plugins.sh now emits shell functions, so that one looks addressed.
I'm aware this repo holds the plugin schemas and SDK rather than the op CLI source, but the issue template points CLI-side plugin functionality here, so filing it under op-cli. Happy to split items 2 and 3 into a separate report if they belong elsewhere.
op CLI version
2.39.0 (macOS arm64, Homebrew
1password-clicask)Goal or desired behavior
opships a Cobra completion script (op completion zsh|bash|fish; Homebrew installs it toshare/zsh/site-functions/_op), but it only completes subcommand and flag names. Every positional argument and flag value I tried returns nothing. This issue lists the gaps, most important first.1. Plugin names (the reason for this issue)
opalready knows both lists. AValidArgsFunctionon these four commands returning theexecutablefield would fix all of them with no change to the generated shell scripts.2. Static enums, no session needed
3. Values that need a signed-in session
I understand these cost an API round trip and possibly a biometric prompt on a cold session, so they may not be worth it. Listing them for completeness.
Current behavior
Every one of the above completes to nothing, for registry and local-build plugins alike:
For plugins specifically, you have to run
op plugin listin another terminal and copy the name, or guess. With ~90 plugins in the registry, andop plugin init --helpitself telling users to "run 'op plugin list'" to find the name, this is a small but constant paper cut.Workaround for zsh users covering item 1: wrap the generated
_op, handle the four plugin positions, and fall through to Cobra for everything else.op plugin list --format=jsontakes ~100 ms here, so it is fine to call at tab time.Related: #433 (aliases in
plugins.shbreaking completion for the wrapped tool) is a different gap;plugins.shnow emits shell functions, so that one looks addressed.I'm aware this repo holds the plugin schemas and SDK rather than the
opCLI source, but the issue template points CLI-side plugin functionality here, so filing it underop-cli. Happy to split items 2 and 3 into a separate report if they belong elsewhere.