fzf icon indicating copy to clipboard operation
fzf copied to clipboard

Kill command completion doesn't complete signal names

Open barlik opened this issue 7 years ago • 4 comments

  • Category
    • [x] Completion
  • OS
    • [x] Linux
  • Shell
    • [x] bash

I have standard bash completions installed (https://github.com/scop/bash-completion) and it includes a way to complete signal names for kill command by running:

kill -s <tab> -> a list of signals
kill -<tab> -> a list of signals

After adding fzf completions, this no longer works. Kill command completion from FZF package only completes PIDs and it doesn't fall-back to previously defined completion.

barlik avatar Nov 12 '17 15:11 barlik

I see, do you know how to fix it?

junegunn avatar Nov 12 '17 15:11 junegunn

Yes, I can. However, I've been looking into fzf completions yesterday and thinking about a different approach for it.

FZF completions are currently duplicating some code that's already defined inside bash completions. For example, in fzf when you expand '**' it triggers a fzf defined shell function to prepare a list of hosts to complete. This function is however not identical to the the bash's one. E.g. in bash I use HOSTFILE to add additional hosts for the host completion. This is missing from the fzf '**' completion. The situation is the same with other commands (e.g. kill command doesn't complete signals).

I think that an alternative way to approach completions might be to leverage the existing completions and use fzf to filter those. It would work like this:

ssh -i ** -> completion of files with fzf
ssh -l ** -> completion of users with fzf 
ssh -c ** -> completion of crypto algorithms with fzf

By leveraging the existing completions you can:

  1. fix inconsistencies between the completions.
  2. remove a lot of code from fzf completions and make it simpler though more powerful.
  3. remove the need to specify which commands need file completion and which need directory completion. This is handled by bash completions already.
  4. by changing the trigger to <tab> you can have fzf be applied to all completions. This is quite amazing.

I've tried that with a proof of concept ssh completion and it works great. The code is in the early stage, it's just a proof of concept as of now. It triggers the existing completion and then it uses fzf to select the item from the completion list. Hopefully, I'll find a bit more time to finish it in the next couple of days. It might work as a replacement or an alternative to the current completions.

barlik avatar Nov 12 '17 17:11 barlik

Cool, love the idea!

that's already defined inside bash completions

Only if you installed custom bash completions such as the one you linked above. We can leverage those external completions, but we still have to use our functions when alternatives are not found.

junegunn avatar Nov 13 '17 07:11 junegunn

I would love to use the bash-native list of hosts for completion through fzf. Any chance you still have your proof of concept to share? It looks like #1149 might be it.

peterfpeterson avatar Feb 09 '22 20:02 peterfpeterson