Skip to content
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

cannot source autocompletions in zsh #67

Closed
mayel opened this issue Feb 20, 2022 · 2 comments
Closed

cannot source autocompletions in zsh #67

mayel opened this issue Feb 20, 2022 · 2 comments

Comments

@mayel
Copy link

mayel commented Feb 20, 2022

Expected Behavior

Auto-completions are sourced into the shell.

Actual Behavior

And error message appears and auto-completions are not sourced.

Steps to Reproduce the Problem

Here are different attempts and their results:

~ > source <(jj debug completion --zsh)

_arguments:comparguments:325: can only be called from completion function

~ > source (jj debug completion --zsh)

zsh: unknown file attribute: j

~ > source $(jj debug completion --zsh)

source: no such file or directory: #compdef

~ > source jj debug completion --zsh

/Users/me/.cargo/bin/jj:2: parse error near `)'

~ > jj debug completion --zsh | source

source: not enough arguments

Specifications

  • Version: latest git
  • Platform: zsh on macOS on Silicon with rust nightly via rustup via homebrew
@martinvonz
Copy link
Owner

Jujutsu gets its completion script from Clap. See if clap-rs/clap#2488 has some useful information about sourcing the zsh script. There were a few steps mentioned there, which involved removing the last line of the script. Maybe those steps are what's needed? I'm not at a computer so I can't test it myself.

@mayel
Copy link
Author

mayel commented Feb 20, 2022

Thanks!

First tried using $fpath by putting fpath="jj debug completion --zsh":$fpath in ~/.zshrc and then when I typed jj and [tab] I got -zsh:1: _main_complete: function definition file not found

I then put this instead, with which autocompletions are working:

autoload -U compinit
compinit
source <(jj debug completion --zsh | sed '$d') # can also be `head -n -1` or whatever as long as the last line is removed
compdef _jj jj

martinvonz added a commit that referenced this issue Feb 27, 2022
Setting up completion is particularly non-obvious for Zsh, so let's
provide the exact command(s) for each supported shell.

Closes #67.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants