Skip to content

Use shell functions instead of aliases to avoid interfering with shell completion #433

Description

@jimeh

op CLI version

2.24.0

Goal or desired behavior

I want to setup the homebrew shell plugin (as an example), and have shell completion work correctly for brew, and also my custom shell alias (alias br=brew).

This can be achieved by using a shell function in ~/.config/op/plugins.sh instead of an alias:

brew() { op plugin run -- brew "$@"; }

Current behavior

Currently when you run op plugin init brew, a shell alias is written to ~/.config/op/plugins.sh, for example:

alias brew="op plugin run -- brew"

This results in the brew command no longer having shell completions available on it, unless setopt completealiases is used. But that breaks completion for shorthand aliases like alias br=brew, because it will try to find completions for a command named br.

Hence the shell function approach is the only one that works correctly in both scenarios.

Relevant log output

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    op-cliFunctionality to be implemented in 1Password CLI. Needs to be done by 1Password Developers.

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions