Commands autocompletion in fish

Any fish users here? It seems that for most commands it gives a nice flag autocompletition + small description out of the box. it also allows to select interactively

❯ gcc --
--coverage  (This option is used to compile and link code instrumented for…)
--help  (Print text describing all the command line options instead of pre…)
--param  (In some places, GCC uses various constants to control the amount…)
--sysroot  (Use dir as the logical root directory for headers and libraries)
…and 2 more rows
❯ julia --
--banner                                       (Startup banner)
--bug-report                      (Launch a bug report session)
--check-bounds                             (Emit bounds checks)
--code-coverage              (Count executions of source lines)
--color                                            (Color text)
--compile                                        (JIT compiler)
--compiled-modules      (Incremental precompilation of modules)
--cpu-target                      (Limit usage of CPU features)
--depwarn              (Syntax and method deprecation warnings)
--eval                                          (Evaluate EXPR)
--handle-signals              (Julia's default signal handlers)
--help                                             (Print help)
--help-hidden                  (Print help of uncommon options)
--history-file                              (Load/Save history)
--home                       (Set location of julia executable)
--inline                                     (Control inlining)
--load                (Load FILE immediately on all processors)

not a biggie, but would be sweet to have similar support for chpl. Not opening an issue (yet) because I'm not sure if this is something that should be handled in some fish-dotfiles or in chapel. For other programs seems to work out of the box (without any tweaks after installing fish)

Hi Luca —

In reading your question, it's not clear to me whether you're already aware of this, but in case not: A few years back, @diten implemented chpl completion for bash, and it's been incredibly valuable to our team, so I think extending it to other popular/used shells would be attractive as well. See $CHPL_HOME/util/chpl-completion.bash for that support and test/chplenv/autocomplete/ for our testing that ensures it remains up-to-date.

I think a good goal in supporting additional shells would be to avoid the need to update two files, which might suggest... I'm not sure what since I don't know how fish works... but potentially some way of producing one file from the other or having them each be generated by a common script?

Best wishes,

1 Like

Thanks for the answer! I was not aware of the bash completion script. I tested it in a bash shell and it works (unsurprisingly).

I am not expert, but as far as I know, there is not a general bash -> fish transpiler, nor would it be easy to write one. Sure, in this case we don't want a general transpiler, but a script to translate a specific script, so probably there's some room for automation. My approach would be to first port it manually and then study how to automate the process. I'll try playing a little with it.

P.S.: Today I Learnt: the correct word is autocompletion and not autocompletition :smiley: feel free to correct my spelling mistake in the title if you want

1 Like

Hi Luca —

Makes sense... I think creating code clones is almost always a great first step toward understanding what would be necessary to eliminate them (and how worthwhile it would be). Let us know what you find.

My brain's fuzzy logic didn't even notice the mis-spelling in the title I think, but I'll look into editing it. :slight_smile: