jupyter_core icon indicating copy to clipboard operation
jupyter_core copied to clipboard

Complete notebook files in ZSH completion

Open flying-sheep opened this issue 8 years ago • 5 comments

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

flying-sheep avatar Sep 02 '16 08:09 flying-sheep

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

rolweber avatar Jul 05 '17 07:07 rolweber

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.

flying-sheep avatar Jul 05 '17 07:07 flying-sheep

Has any progress been made on this issue?

jpweytjens avatar May 20 '18 12:05 jpweytjens

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

takluyver avatar May 21 '18 17:05 takluyver

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.

jpweytjens avatar Apr 17 '19 08:04 jpweytjens