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

Complete notebook files in ZSH completion #86

Open
flying-sheep opened this issue Sep 2, 2016 · 5 comments
Open

Complete notebook files in ZSH completion #86

flying-sheep opened this issue Sep 2, 2016 · 5 comments

Comments

@flying-sheep
Copy link

flying-sheep commented Sep 2, 2016

Hi, I’m trying to get jupyter notebook <tab> to show me both subcommands and notebook files as options here.

sadly i don’t seem to get what’s going on. whatever i tried, it throws errors at some point.

can somebody explain how it works? my progress:

  • ${(P)subcmd}} means “expand to the value of the variable named $subcmd”. i.e. if subcmd=notebook, it expands to $notebook, which is previously set to the output of $(jupyter notebook --help-all | grep … | sed …)

    so ${(P)subcmd}} aka $notebook (in one branch) holds the _arguments-formatted options to the notebook subcommand

  • _${subcmd}_cmds aka _notebook_cmds (in one branch) holds _describe output.

below my most recent attempts:

  1. eval-string

    _alternative \
      'notebook:notebook:_files -g "*.ipynb"' \
      "subcommands:subcommands:{_${subcmd}_cmds && echo ${(P)subcmd}}" && ret=0

    at some point it prints the stuff instead of using it… do i have to do this? is there a better way? _alternative … "subcommands:subcommands:{$(_${subcmd}_cmds && echo ${(P)subcmd})}"

  2. function

    _cmds_and_opts() {
        _${subcmd}_cmds
        echo ${(P)subcmd}
    }
    _alternative \
      'notebook:notebook:_files -g "*.ipynb"' \
      "subcommands:subcommands:_cmds_and_opts" && ret=0

    huh? can’t i redefine functions? or what’s wrong

@rolweber
Copy link
Contributor

rolweber commented Jul 5, 2017

This seems to be a zsh question, rather than a jupyter_core issue. I suggest to close this issue as off-topic.

@flying-sheep
Copy link
Author

flying-sheep commented Jul 5, 2017

this repo contains the ZSH file completions-zsh

this is a feature request for that file, therefore this issue was filed in the ideal place.

sorry if i didn’t make that clear: i want to improve the ZSH completions here.

@jpweytjens
Copy link

Has any progress been made on this issue?

@takluyver
Copy link
Member

Not as far as I known. Would you like to work on it?

@jpweytjens
Copy link

Not as far as I known. Would you like to work on it?

I don't have much spare time, by considering nobody else has replied, I'll take a crack at it.

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

4 participants