-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
should completion.* be split up? #3457
Comments
Along such change, if accepted, one could perhaps re-organise the
These could then be installed like so:
|
The completion for fzf itself hasn't been maintained for years, so it's missing a lot of new options, I'm planning to remove it completely as I don't see myself working on it in the near future.
Even if I decide to provide completion for fzf itself, I'll probably take a different approach to support not only bash but also zsh and fish using something like https://github.com/spf13/cobra/ |
Hmm, that would be a pity. One should then rather try to get it into bash-completion? At least to have something that works until any other approach would be working. |
man fzf
)Info
Problem / Steps to reproduce
I wonder whether the
completion.*
should/could be split up, at least in the bash case.Some background:
I've stumbled over Debian bug #1013356, where the problem is that
fzf
’s shell function for**<TAB>
completion aren’t loaded properly.The reason is that
completion.bash
is installed into/usr/share/bash-completion/completions/fzf
, which is then however only loaded on-demand (per shell session), which bash-completion only does, when completingfzf
like in:Also, AFAIU, the
completion.*
ship currently code for two kinds of completions:a. completing options for
fzf
itself (e.g.fzf --height
)b. completing other stuff (e.g. hostnames in
ssh **<TAB>
, etc.)And AFAIU, there's no dependency on bash-completion.
Without any bigger changes to infrastructure (on the distro side), I'd see basically the following solutions for the Debian issue:
/usr/share/fzf/shell/completion.bash
(I, personally don't like if Debian would place it as/usr/share/doc/fzf/examples/completion.*
, which it does right now for the other shell scripts fromfzf
)/etc/profile.d/
/etc/bash_completion.d/
/etc/bash.bashrc.d
or something like that(1) has the disadvantage that
fzf
’s completions (both, (a) and (b)) wouldn't work out of the box anymore. But has the advantage hat a (non-root) user can easily disable them (by not manually sourcing them) and easily use e.g. alternative solutions like lincheney/fzf-tab-completion.(2) Would require an additional check in all the files, whether the right shell (e.g. bash or zsh) is active. The check for interactiveness alone wouldn't suffice. Also, it’s (at least in Debian) again not easily possible for a (non-root) user to disable loading of them.
(3) Would require no additional checks like in (2). But it's only somewhat easy for a (non-root) user to disable loading it (IIRC one could set
BASH_COMPLETION_COMPAT_DIR
or so - but via that, only disable loading all files in/etc/bash_completion.d/
, not just e.g.fzf
).(4) At least in Debian, a counterpart mechanism to
/etc/profile.d/
- but just forbashrc
doesn’t even exist.All these would in principle be on the distro side, but there's one thing that might be done on the
fzf
side:If a distro does any of the above both, (a) and (b) (and the functions for those), will always be loaded, right?
For (b) there's no real way around that, but for (a) (i.e. the completion of
fzf
itselef) this shouldn't be necessary. It would be nice, if for that the on-demand loading provided by bash-completion’s/usr/share/bash-completion/completions/fzf
could be used, so that_fzf_opts_completion
would only be loaded, if someone actually tries to completefzf
(itself).For (a), there are probably also no alternative implementations, so there's no real need for a (non-root) user to be able to disable loading the completions for that.
So long story short, what would you think about splitting up
completion.bash
?This could also have more benefits than just keeping the shell environment a bit smaller when
fzf
itself is not completed:As
completion.*
grow, it might make sense to split things up anyway (similar as bash-completion is split up):__fzf_list_hosts()
,_fzf_host_completion()
,__fzf_defc()
and_fzf_setup_completion()
, etc._fzf_complete_ssh()
, which then also set up the actual completion (via the generic__fzf_defc()
and_fzf_setup_completion()
). This could also make it easier for users to selectively not load fzf-completions for certain programs.Cheers,
Chris.
The text was updated successfully, but these errors were encountered: