oils-for-unix / oils

Oils is our upgrade path from bash to a better language and runtime. It's also for Python and JavaScript users who avoid shell!
http://www.oilshell.org/
Other
2.84k stars 157 forks source link

OSH should have completion logic for its own builtins, e.g. cd #369

Open jyn514 opened 5 years ago

jyn514 commented 5 years ago

Currently, cd <tab> autocompletes both files and directories. It would be nice to only autocomplete directories.

This looks like it has something to do with BuiltinFlags in frontend/args.py, but I couldn't figure out where the actions were being set.

andychu commented 5 years ago

I would like to change this, but FWIW if you do bash --norc you'll see that bash does the same thing.

The way it works is a bit silly -- it delegates completion to the separate bash-completion project, which registers a hook for cd that only completes dictories. And this logic isn't complete -- it misses all the flags.

Here is what I do:

https://github.com/oilshell/oil/wiki/How-To-Test-OSH

Basically use the oilshell/bash-completion fork and check out a specific branch.

I would like to make that easier, but I'm not really sure how. zsh and fish maintain a lot of completions in-tree, but I'm not sure I want to do that.


And yes, the flag specs using args.py should be able to generate completion logic somehow. That is an interesting problem!

Most systems don't work that way. That is, "pure declarative" command line syntax is not the state of the art! There are some threads on the #shell-autocompletion Zulip channel that mention this.