Ef-🐟-ient fish keybindings for fzf
Shell
Clone or download
jethrokuan Merge pull request #71 from patrickf3139/master
fix markdown and mention lazy-loading advantage in README
Latest commit ec49456 Jun 10, 2018

README.md

Fzf

Slack Room

Integrate fzf functionality into fish! Includes handy functions to do the following using fzf

  • command tab completion
  • search command history
  • find and cd into sub-directories
  • find and open files

All functions

  • are lazily-loaded to keep shell startup time down
  • have preset but configurable key bindings

Heavily adapted from @hauleth's PR.

Note that the fzf utility has its own out-of-the-box fish plugin. What sets this plugin apart is that it has a couple more integrations, most notably tab completion, and will probably be updated more frequently. They are not compatible so either use one or the other.

Install

With fisherman

fisher fzf

Requirements

  • fish version: >=2.4.0
  • fzf versions: >0.11.3

FZF binary

This plugin will fail if the fzf binary is not detected in your PATH.

The recommended means of installing fzf is through your respective package managers.

Usage

Legacy New Keybindings Remarks
Ctrl-t Ctrl-f Find a file.
Ctrl-r Ctrl-r Search through command history.
Alt-c Alt-o cd into sub-directories (recursively searched).
Alt-Shift-c Alt-Shift-o cd into sub-directories, including hidden ones.
Ctrl-o Ctrl-o Open a file/dir using default editor ($EDITOR)
Ctrl-g Ctrl-g Open a file/dir using xdg-open or open command

Legacy keybindings are kept by default, but these have conflict with keybindings in fish 2.4.0. If you want to use the new keybindings, enter the following into your terminal:

set -U FZF_LEGACY_KEYBINDINGS 0

NOTE: On OS X, Alt-c (Option-c) types Γ§ by default. In iTerm2, you can send the right escape sequence with Esc-c. If you configure the option key to act as +Esc (iTerm2 Preferences > Profiles > Default > Keys > Left option (βŒ₯) acts as: > +Esc), then alt-c will work for fzf as documented.

Commands

Variable Remarks Example
FZF_FIND_FILE_COMMAND Modify the command used to generate the list of files set -U FZF_FIND_FILE_COMMAND "ag -l --hidden --ignore .git"
FZF_CD_COMMAND Similar to ^ Similar to ^
FZF_CD_WITH_HIDDEN_COMMAND Similar to ^ Similar to ^
FZF_FIND_AND_EXECUTE_COMMAND Similar to ^ Similar to ^
FZF_REVERSE_ISEARCH_COMMAND Similar to ^ Similar to ^
FZF_OPEN_COMMAND Similar to ^ Similar to ^

Variables

Variable Remarks Example
FZF_DEFAULT_OPTS Default options passed to every fzf command set -U FZF_DEFAULT_OPTS "--height 40"
FZF_FIND_FILE_OPTS Pass in additional arguments to the fzf command for find file set -U FZF_FIND_FILE_OPTS "--reverse --inline-info"
FZF_CD_OPTS Similar to ^ Similar to ^
FZF_CD_WITH_HIDDEN_OPTS Similar to ^ Similar to ^
FZF_FIND_AND_EXECUTE_OPTS Similar to ^ Similar to ^
FZF_REVERSE_ISEARCH_OPTS Similar to ^ Similar to ^
FZF_OPEN_OPTS Similar to ^ Similar to ^
FZF_TMUX Runs a tmux-friendly version of fzf instead. set -U FZF_TMUX 1
FZF_COMPLETE Enable fzf for fish tab completion. set -U FZF_COMPLETE 1