mirror of
https://github.com/Llewellynvdm/fzf.git
synced 2024-12-23 03:19:01 +00:00
Show how to use reload action
This commit is contained in:
parent
9dfca77c36
commit
825d401403
124
README.md
124
README.md
@ -22,42 +22,50 @@ Pros
|
|||||||
Table of Contents
|
Table of Contents
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
* [Installation](#installation)
|
<!-- vim-markdown-toc GFM -->
|
||||||
* [Using Homebrew or Linuxbrew](#using-homebrew-or-linuxbrew)
|
|
||||||
* [Using git](#using-git)
|
* [Installation](#installation)
|
||||||
* [Using Linux package managers](#using-linux-package-managers)
|
* [Using Homebrew or Linuxbrew](#using-homebrew-or-linuxbrew)
|
||||||
* [Windows](#windows)
|
* [Using git](#using-git)
|
||||||
* [As Vim plugin](#as-vim-plugin)
|
* [Using Linux package managers](#using-linux-package-managers)
|
||||||
* [Upgrading fzf](#upgrading-fzf)
|
* [Windows](#windows)
|
||||||
* [Building fzf](#building-fzf)
|
* [As Vim plugin](#as-vim-plugin)
|
||||||
* [Usage](#usage)
|
* [Upgrading fzf](#upgrading-fzf)
|
||||||
* [Using the finder](#using-the-finder)
|
* [Building fzf](#building-fzf)
|
||||||
* [Layout](#layout)
|
* [Usage](#usage)
|
||||||
* [Search syntax](#search-syntax)
|
* [Using the finder](#using-the-finder)
|
||||||
* [Environment variables](#environment-variables)
|
* [Layout](#layout)
|
||||||
* [Options](#options)
|
* [Search syntax](#search-syntax)
|
||||||
* [Demo](#demo)
|
* [Environment variables](#environment-variables)
|
||||||
* [Examples](#examples)
|
* [Options](#options)
|
||||||
* [fzf-tmux script](#fzf-tmux-script)
|
* [Demo](#demo)
|
||||||
* [Key bindings for command line](#key-bindings-for-command-line)
|
* [Examples](#examples)
|
||||||
* [Fuzzy completion for bash and zsh](#fuzzy-completion-for-bash-and-zsh)
|
* [`fzf-tmux` script](#fzf-tmux-script)
|
||||||
* [Files and directories](#files-and-directories)
|
* [Key bindings for command-line](#key-bindings-for-command-line)
|
||||||
* [Process IDs](#process-ids)
|
* [Fuzzy completion for bash and zsh](#fuzzy-completion-for-bash-and-zsh)
|
||||||
* [Host names](#host-names)
|
* [Files and directories](#files-and-directories)
|
||||||
* [Environment variables / Aliases](#environment-variables--aliases)
|
* [Process IDs](#process-ids)
|
||||||
* [Settings](#settings)
|
* [Host names](#host-names)
|
||||||
* [Supported commands](#supported-commands)
|
* [Environment variables / Aliases](#environment-variables--aliases)
|
||||||
* [Custom fuzzy completion](#custom-fuzzy-completion)
|
* [Settings](#settings)
|
||||||
* [Vim plugin](#vim-plugin)
|
* [Supported commands](#supported-commands)
|
||||||
* [Advanced topics](#advanced-topics)
|
* [Custom fuzzy completion](#custom-fuzzy-completion)
|
||||||
* [Performance](#performance)
|
* [Vim plugin](#vim-plugin)
|
||||||
* [Executing external programs](#executing-external-programs)
|
* [Advanced topics](#advanced-topics)
|
||||||
* [Preview window](#preview-window)
|
* [Performance](#performance)
|
||||||
* [Tips](#tips)
|
* [Executing external programs](#executing-external-programs)
|
||||||
* [Respecting .gitignore](#respecting-gitignore)
|
* [Reloading the candidate list](#reloading-the-candidate-list)
|
||||||
* [Fish shell](#fish-shell)
|
* [1. Update the list of processes by pressing CTRL-R](#1-update-the-list-of-processes-by-pressing-ctrl-r)
|
||||||
* [Related projects](#related-projects)
|
* [2. Switch between sources by pressing CTRL-D or CTRL-F](#2-switch-between-sources-by-pressing-ctrl-d-or-ctrl-f)
|
||||||
* [<a href="LICENSE">License</a>](#license)
|
* [3. Interactive ripgrep integration](#3-interactive-ripgrep-integration)
|
||||||
|
* [Preview window](#preview-window)
|
||||||
|
* [Tips](#tips)
|
||||||
|
* [Respecting `.gitignore`](#respecting-gitignore)
|
||||||
|
* [Fish shell](#fish-shell)
|
||||||
|
* [Related projects](#related-projects)
|
||||||
|
* [License](#license)
|
||||||
|
|
||||||
|
<!-- vim-markdown-toc -->
|
||||||
|
|
||||||
Installation
|
Installation
|
||||||
------------
|
------------
|
||||||
@ -528,6 +536,50 @@ fzf --bind 'f1:execute(less -f {}),ctrl-y:execute-silent(echo {} | pbcopy)+abort
|
|||||||
|
|
||||||
See *KEY BINDINGS* section of the man page for details.
|
See *KEY BINDINGS* section of the man page for details.
|
||||||
|
|
||||||
|
### Reloading the candidate list
|
||||||
|
|
||||||
|
By binding `reload` action to a key or an event, you can make fzf dynamically
|
||||||
|
reload the candidate list. See https://github.com/junegunn/fzf/issues/1750 for
|
||||||
|
more details.
|
||||||
|
|
||||||
|
#### 1. Update the list of processes by pressing CTRL-R
|
||||||
|
|
||||||
|
```sh
|
||||||
|
FZF_DEFAULT_COMMAND='ps -ef' \
|
||||||
|
fzf --bind 'ctrl-r:reload($FZF_DEFAULT_COMMAND)' \
|
||||||
|
--header 'Press CTRL-R to reload' --header-lines=1 \
|
||||||
|
--height=50% --layout=reverse
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 2. Switch between sources by pressing CTRL-D or CTRL-F
|
||||||
|
|
||||||
|
```sh
|
||||||
|
FZF_DEFAULT_COMMAND='find . -type f' \
|
||||||
|
fzf --bind 'ctrl-d:reload(find . -type d),ctrl-f:reload($FZF_DEFAULT_COMMAND)' \
|
||||||
|
--height=50% --layout=reverse
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 3. Interactive ripgrep integration
|
||||||
|
|
||||||
|
The following example uses fzf as the selector interface for ripgrep. We bound
|
||||||
|
`reload` action to `change` event, so every time you type on fzf, ripgrep
|
||||||
|
process will restart with the updated query string denoted by the placeholder
|
||||||
|
expression `{q}`. Also, note that we used `--phony` option so that fzf doesn't
|
||||||
|
perform any secondary filtering.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
INITIAL_QUERY=""
|
||||||
|
RG_PREFIX="rg --column --line-number --no-heading --color=always --smart-case "
|
||||||
|
FZF_DEFAULT_COMMAND="$RG_PREFIX '$INITIAL_QUERY'" \
|
||||||
|
fzf --bind "change:reload:$RG_PREFIX {q} || true" \
|
||||||
|
--ansi --phony --query "$INITIAL_QUERY" \
|
||||||
|
--height=50% --layout=reverse
|
||||||
|
```
|
||||||
|
|
||||||
|
If ripgrep doesn't find any matches, it will exit with a non-zero exit status,
|
||||||
|
and fzf will warn you about it. To suppress the warning message, we added
|
||||||
|
`|| true` to the command, so that it always exits with 0.
|
||||||
|
|
||||||
### Preview window
|
### Preview window
|
||||||
|
|
||||||
When the `--preview` option is set, fzf automatically starts an external process
|
When the `--preview` option is set, fzf automatically starts an external process
|
||||||
|
Loading…
Reference in New Issue
Block a user