Skip to content

Enable to run commands during auto completion such as fzf for some commands

License

Notifications You must be signed in to change notification settings

at-ishikawa/fish-completion-interceptor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fish Completion Interceptor (FCI)

This plugin is under development and can have breaking changes in the future.

This plugin is to run a command for specific commands instead of showing regular completions of fish.

The next demo shows for the usage of kubectl get pods with fzf for a completion by this plugin.

Demo

Install

Install this plugin using a fisher.

fisher install at-ishikawa/fish-completion-interceptor

Configurations

If you try to use completion by a tab key, this plugin is used automatically for specific commands.

If you want to use other completions, define fish_completion_interceptor_fallback function in your config file and call it. For example, if you want to use jethrokuan/fzf as default, you can still use that plugin by defining the next function in ~/.config/fish/config.fish.

function fish_completion_interceptor_fallback
    __fzf_complete
end

There are some variables that can be defined:

  • FISH_COMPLETION_INTERCEPTOR_PLUGINS: The commands to intercept by which function.
  • FISH_COMPLETION_INTERCEPTOR_ENABLED: true if the interceptor is enabled.
  • FISH_COMPLETION_INTERCEPTOR_FZF_KEY_BINDINGS: The options to run fzf. The default is --inline-info --layout reverse --preview-window down:70% --bind ctrl-k:kill-line,ctrl-alt-t:toggle-preview,ctrl-alt-n:preview-down,ctrl-alt-p:preview-up,ctrl-alt-v:preview-page-down.

FCI plugins

Currently, there are 2 plugins supported by this plugin. Note that not all subcommands have been supported.

Customize

If you want to run a command in for a particular command, let's say foo, then you can add it by

function your_command_interceptor
    # Add your logic
    # $argv is arguments from commandline
end

set -U FISH_COMPLETION_INTERCEPTOR_PLUGINS $FISH_COMPLETION_INTERCEPTOR_PLUGINS "foo=your_command_interceptor"

For more details, see the plugin spec doc.

Development

Dependencies

Commmands

  • make install: Install this plugin into ~/.config/fish using fisher
  • make dependencies: Install dependencies to develop this plugin
  • make generate:: Generate configuration files that are supposed to be generated automatically. kubectl is required.
  • make test: Run test cases

About

Enable to run commands during auto completion such as fzf for some commands

Resources

License

Stars

Watchers

Forks

Packages