Show how to use reload action
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Junegunn Choi · committed by Junegunn Choi · parent 9dfca77 · Browse files · 1 file·+88 added−36 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
1 file+88 added−36 removed
- other:+88 added−36 removed
Provenance
- Commit
825d401- Tree
abdfee0- Author
Junegunn Choi <junegunn.c@gmail.com>- Committer
Junegunn Choi <junegunn.c@gmail.com>- Parent
9dfca77
1 file changed+88 added−36 removed
modified:README.md+88 added-36 removed
20 unmodified lines21 22 Table of Contents23 -----------------24 25- * [Installation](#installation)26- * [Using Homebrew or Linuxbrew](#using-homebrew-or-linuxbrew)27- * [Using git](#using-git)28- * [Using Linux package managers](#using-linux-package-managers)29- * [Windows](#windows)30- * [As Vim plugin](#as-vim-plugin)31- * [Upgrading fzf](#upgrading-fzf)32- * [Building fzf](#building-fzf)33- * [Usage](#usage)34- * [Using the finder](#using-the-finder)35- * [Layout](#layout)36- * [Search syntax](#search-syntax)37- * [Environment variables](#environment-variables)38- * [Options](#options)39- * [Demo](#demo)40- * [Examples](#examples)41- * [fzf-tmux script](#fzf-tmux-script)42- * [Key bindings for command line](#key-bindings-for-command-line)43- * [Fuzzy completion for bash and zsh](#fuzzy-completion-for-bash-and-zsh)44- * [Files and directories](#files-and-directories)45- * [Process IDs](#process-ids)46- * [Host names](#host-names)47- * [Environment variables / Aliases](#environment-variables--aliases)48- * [Settings](#settings)49- * [Supported commands](#supported-commands)50- * [Custom fuzzy completion](#custom-fuzzy-completion)51- * [Vim plugin](#vim-plugin)52- * [Advanced topics](#advanced-topics)53- * [Performance](#performance)54- * [Executing external programs](#executing-external-programs)55- * [Preview window](#preview-window)56- * [Tips](#tips)57- * [Respecting .gitignore](#respecting-gitignore)58- * [Fish shell](#fish-shell)59- * [Related projects](#related-projects)60- * [<a href="LICENSE">License</a>](#license)25+<!-- vim-markdown-toc GFM -->26 27+* [Installation](#installation)28+ * [Using Homebrew or Linuxbrew](#using-homebrew-or-linuxbrew)29+ * [Using git](#using-git)30+ * [Using Linux package managers](#using-linux-package-managers)31+ * [Windows](#windows)32+ * [As Vim plugin](#as-vim-plugin)33+* [Upgrading fzf](#upgrading-fzf)34+* [Building fzf](#building-fzf)35+* [Usage](#usage)36+ * [Using the finder](#using-the-finder)37+ * [Layout](#layout)38+ * [Search syntax](#search-syntax)39+ * [Environment variables](#environment-variables)40+ * [Options](#options)41+ * [Demo](#demo)42+* [Examples](#examples)43+* [`fzf-tmux` script](#fzf-tmux-script)44+* [Key bindings for command-line](#key-bindings-for-command-line)45+* [Fuzzy completion for bash and zsh](#fuzzy-completion-for-bash-and-zsh)46+ * [Files and directories](#files-and-directories)47+ * [Process IDs](#process-ids)48+ * [Host names](#host-names)49+ * [Environment variables / Aliases](#environment-variables--aliases)50+ * [Settings](#settings)51+ * [Supported commands](#supported-commands)52+ * [Custom fuzzy completion](#custom-fuzzy-completion)53+* [Vim plugin](#vim-plugin)54+* [Advanced topics](#advanced-topics)55+ * [Performance](#performance)56+ * [Executing external programs](#executing-external-programs)57+ * [Reloading the candidate list](#reloading-the-candidate-list)58+ * [1. Update the list of processes by pressing CTRL-R](#1-update-the-list-of-processes-by-pressing-ctrl-r)59+ * [2. Switch between sources by pressing CTRL-D or CTRL-F](#2-switch-between-sources-by-pressing-ctrl-d-or-ctrl-f)60+ * [3. Interactive ripgrep integration](#3-interactive-ripgrep-integration)61+ * [Preview window](#preview-window)62+* [Tips](#tips)63+ * [Respecting `.gitignore`](#respecting-gitignore)64+ * [Fish shell](#fish-shell)65+* [Related projects](#related-projects)66+* [License](#license)67+68+<!-- vim-markdown-toc -->69+70 Installation71 ------------72 73 fzf project consists of the following components:461 unmodified lines535 ```536 537 See *KEY BINDINGS* section of the man page for details.538 539+### Reloading the candidate list540+541+By binding `reload` action to a key or an event, you can make fzf dynamically542+reload the candidate list. See https://github.com/junegunn/fzf/issues/1750 for543+more details.544+545+#### 1. Update the list of processes by pressing CTRL-R546+547+```sh548+FZF_DEFAULT_COMMAND='ps -ef' \549+ fzf --bind 'ctrl-r:reload($FZF_DEFAULT_COMMAND)' \550+ --header 'Press CTRL-R to reload' --header-lines=1 \551+ --height=50% --layout=reverse552+```553+554+#### 2. Switch between sources by pressing CTRL-D or CTRL-F555+556+```sh557+FZF_DEFAULT_COMMAND='find . -type f' \558+ fzf --bind 'ctrl-d:reload(find . -type d),ctrl-f:reload($FZF_DEFAULT_COMMAND)' \559+ --height=50% --layout=reverse560+```561+562+#### 3. Interactive ripgrep integration563+564+The following example uses fzf as the selector interface for ripgrep. We bound565+`reload` action to `change` event, so every time you type on fzf, ripgrep566+process will restart with the updated query string denoted by the placeholder567+expression `{q}`. Also, note that we used `--phony` option so that fzf doesn't568+perform any secondary filtering.569+570+```sh571+INITIAL_QUERY=""572+RG_PREFIX="rg --column --line-number --no-heading --color=always --smart-case "573+FZF_DEFAULT_COMMAND="$RG_PREFIX '$INITIAL_QUERY'" \574+ fzf --bind "change:reload:$RG_PREFIX {q} || true" \575+ --ansi --phony --query "$INITIAL_QUERY" \576+ --height=50% --layout=reverse577+```578+579+If ripgrep doesn't find any matches, it will exit with a non-zero exit status,580+and fzf will warn you about it. To suppress the warning message, we added581+`|| true` to the command, so that it always exits with 0.582+583 ### Preview window584 585 When the `--preview` option is set, fzf automatically starts an external process 586 with the current line as the argument and shows the result in the split window. 122 unmodified lines