-
Notifications
You must be signed in to change notification settings - Fork 189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ZSH completions when using glab plugin #122
Comments
Have not tested, but I would guess this is the same for all shells (except maybe Fish, Fish shell is pretty good about doing that kind of stuff by default) and all Shell Plugins. Maybe |
Some findings from looking into this a bit:
For these reasons, I think the best approach is to document it, rather than trying to set it automatically, because the Options for |
For ZSH we can do the following:
I no tested it yet for glab, but I did it for "doctl" and it works well |
I'd prefer not to I tried this for My interim solution has been to update the case "$line[1]" in
gh)
_gh
;;
esac This should work for Edit: the general solution for zsh looks to be as simple as replacing the lines above with: _dispatch "$curcontext" "$line[1]" |
@aaronkollasch's solution above works for me for % op plugin run glab #TAB
alias -- Create, list and delete aliases
api -- Make an authenticated request to GitLab API
... However % op plugin run -- glab #TAB
bin/ Desktop/ Downloads/
... zsh 5.9. |
@Forst I finally found the problem – there was an extra Adding the following lines before if [[ "$words[1]" == "--" ]]; then
shift words
fi I've also updated the gist. This should get things to work properly with |
Related: #433 |
The thing that works reliably for me is also monkey patching function _op_plugin_run_fix() {
for (( i=2; i < CURRENT; i++ )); do
if [[ ${words[i]} == -- ]]; then
shift $i words
(( CURRENT -= i ))
_normal
return
fi
done
# run original op completion
_op
}
function __load_op_completion() {
local op_completion_fn="$(op completion zsh)"
local fix_fn="$(which _op_plugin_run_fix)"
# replace all references to _op with _op_plugin_run_fix (except for the function definition)
local patched_op=$(sed -E -e 's/\b_op\b([^()]|$)/_op_plugin_run_fix\1/g' <<< $op_completion_fn)
echo -e "$patched_op\n\n$fix_fn"
}
eval "$(__load_op_completion)" The only problem with it is that I need to use |
Platform or tool
GitLab
Desired or expected behavior
Hi team, really enjoying the GitLab 1password plugin. https://developer.1password.com/docs/cli/shell-plugins/gitlab
One thing I noticed once I installed the glab shell plugin is that my completions stopped working, since
op
aliasesglab
I had to add
setopt completealiases
to my ~/.zshrc file so zsh does not expand aliases before performing completion.I was thinking if it would be worth mentioning here: https://developer.1password.com/docs/cli/shell-plugins/gitlab ?
Current behavior
Completions don't work by default with
zsh
+op
Relevant log output
No response
op CLI version
2.8.0-beta.10
The text was updated successfully, but these errors were encountered: