This script integrates the FZF "fuzzy finder" with the Clink command line editing enhancements for CMD.exe on Windows.
-
Copy the
fzf.lua
file into your Clink scripts directory. -
Either put
fzf.exe
in a directory listed in the system PATH environment variable, or runclink set fzf.exe_location <put_dir_name_here>
to tell Clink where to find the FZF program.
For detailed information on using FZF, please refer to the FZF documentation.
Here are the default key bindings in Clink:
Key | Description |
---|---|
Ctrl+T | Lists files recursively; choose one or multiple to insert them. |
Ctrl+R | Lists history entries; choose one to insert it. |
Alt+C | Lists subdirectories; choose one to 'cd /d' to it. |
Alt+B | Lists key bindings; choose one to invoke it. |
Tab | Uses fzf to filter match completions. |
Ctrl+Space | Uses fzf to filter match completions. |
Note: For the default key bindings to work, you must be using Clink v1.2.46 or higher. If you're using an older version of Clink then consider upgrading Clink, or manually add key bindings in your .inputrc file as described below.
You can use **
Tab to list files recursively under the directory.
For example:
notepad **
lists files recursively under the current directory.notepad foo**
lists files recursively under the current directory, and usesfoo
as the search phrase.notepad bar\foo**
lists files recursively under thebar
directory, and usesfoo
as the search phrase.
You can use your own custom key bindings if you prefer.
Run clink set fzf.default_bindings false
and add key bindings to your .inputrc
file manually.
Run clink echo
to find key bindings strings. See Key Bindings in the Clink documentation for more information on how to set key bindings.
The default key bindings for FZF are listed here in .inputrc file format for convenience:
# Default key bindings for fzf with Clink.
"\C-t": "luafunc:fzf_file" # Ctrl+T lists files recursively; choose one or multiple to insert them.
"\C-r": "luafunc:fzf_history" # Ctrl+R lists history entries; choose one to insert it.
"\M-c": "luafunc:fzf_directory" # Alt+C lists subdirectories; choose one to 'cd /d' to it.
"\M-b": "luafunc:fzf_bindings" # Alt+B lists key bindings; choose one to invoke it.
"\t": "luafunc:fzf_complete" # Tab uses fzf to filter match completions.
"\e[27;5;32~": "luafunc:fzf_complete" # Ctrl+Space uses fzf to filter match completions.
There is also a "luafunc:fzf_selectcomplete"
function which invokes clink-select-complete
instead of complete
. This enables the **
recursive completion behavior with the interactive completion command.
You can specify FZF options for each of the different commands:
Env Var Name | Description |
---|---|
FZF_CTRL_T_OPTS |
Options for Ctrl+T (the "luafunc:fzf_file" function). |
FZF_CTRL_R_OPTS |
Options for Ctrl+R (the "luafunc:fzf_history" function). |
FZF_ALT_C_OPTS |
Options for Alt+C (the "luafunc:fzf_directory" function). |
FZF_BINDINGS_OPTS |
Options for Alt+B (the "luafunc:fzf_bindings" function). |
FZF_COMPLETE_OPTS |
Options for Ctrl+Space (the "luafunc:fzf_complete" function). |
You can specify commands to run for collecting files or directories:
Env Var Name | Description |
---|---|
FZF_CTRL_T_COMMAND |
Command to run for collecting files for Ctrl+T (the "luafunc:fzf_file" function). |
FZF_ALT_C_COMMAND |
Command to run for collecting directories for Alt+C (the "luafunc:fzf_directory" function). |