ADVANCED.md: Remove unnecessary `: | fzf`
Before adoption: this commit came in with the history the project adopted, so no landing records it.
See 5b52833
authored by Junegunn Choi · committed by Junegunn Choi · parent 8689f5f · Browse files · 1 file·+10 added−12 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+10 added−12 removed
- other:+10 added−12 removed
Provenance
- Commit
cc2b214- Tree
8af2862- Author
Junegunn Choi <junegunn.c@gmail.com>- Committer
Junegunn Choi <junegunn.c@gmail.com>- Parent
8689f5f
1 file changed+10 added−12 removed
modified:ADVANCED.md+10 added-12 removed
1 Advanced fzf examples2 ======================3 4-* *Last update: 2024/06/06*5-* *Requires fzf 0.53.0 or later*4+* *Last update: 2024/06/24*5+* *Requires fzf 0.54.0 or later*6 7 ---8 9 <!-- vim-markdown-toc GFM -->350 unmodified lines360 # 2. Interactively restart Ripgrep with reload action361 # 3. Open the file in Vim362 RG_PREFIX="rg --column --line-number --no-heading --color=always --smart-case "363 INITIAL_QUERY="${*:-}"364-: | fzf --ansi --disabled --query "$INITIAL_QUERY" \364+fzf --ansi --disabled --query "$INITIAL_QUERY" \365 --bind "start:reload:$RG_PREFIX {q}" \366 --bind "change:reload:sleep 0.1; $RG_PREFIX {q} || true" \367 --delimiter : \368 --preview 'bat --color=always {1} --highlight-line {2}' \2 unmodified lines371 ```372 373 374 375-- Instead of starting fzf in the usual `rg ... | fzf` form, we start fzf with376- an empty input (`: | fzf`), then we make it start the initial Ripgrep377- process immediately via `start:reload` binding. This way, fzf owns the378- initial Ripgrep process so it can kill it on the next `reload`. Otherwise,379- the process will keep running in the background.375+- Instead of starting fzf in the usual `rg ... | fzf` form, we make it start376+ the initial Ripgrep process immediately via `start:reload` binding for the377+ consistency of the code.378 - Filtering is no longer a responsibility of fzf; hence `--disabled`379 - `{q}` in the reload command evaluates to the query string on fzf prompt.380 - `sleep 0.1` in the reload command is for "debouncing". This small delay will381 reduce the number of intermediate Ripgrep processes while we're typing in15 unmodified lines397 # * Press alt-enter to switch to fzf-only filtering398 # 3. Open the file in Vim399 RG_PREFIX="rg --column --line-number --no-heading --color=always --smart-case "400 INITIAL_QUERY="${*:-}"403-: | fzf --ansi --disabled --query "$INITIAL_QUERY" \401+fzf --ansi --disabled --query "$INITIAL_QUERY" \402 --bind "start:reload:$RG_PREFIX {q}" \403 --bind "change:reload:sleep 0.1; $RG_PREFIX {q} || true" \404 --bind "alt-enter:unbind(change,alt-enter)+change-prompt(2. fzf> )+enable-search+clear-query" \405 --color "hl:-1:underline,hl+:-1:underline:reverse" \35 unmodified lines441 # Switch between Ripgrep launcher mode (CTRL-R) and fzf filtering mode (CTRL-F)442 rm -f /tmp/rg-fzf-{r,f}443 RG_PREFIX="rg --column --line-number --no-heading --color=always --smart-case "444 INITIAL_QUERY="${*:-}"447-: | fzf --ansi --disabled --query "$INITIAL_QUERY" \445+fzf --ansi --disabled --query "$INITIAL_QUERY" \446 --bind "start:reload($RG_PREFIX {q})+unbind(ctrl-r)" \447 --bind "change:reload:sleep 0.1; $RG_PREFIX {q} || true" \448 --bind "ctrl-f:unbind(change,ctrl-f)+change-prompt(2. fzf> )+enable-search+rebind(ctrl-r)+transform-query(echo {q} > /tmp/rg-fzf-r; cat /tmp/rg-fzf-f)" \449 --bind "ctrl-r:unbind(ctrl-r)+change-prompt(1. ripgrep> )+disable-search+reload($RG_PREFIX {q} || true)+rebind(change,ctrl-f)+transform-query(echo {q} > /tmp/rg-fzf-f; cat /tmp/rg-fzf-r)" \34 unmodified lines484 # Switch between Ripgrep mode and fzf filtering mode (CTRL-T)485 rm -f /tmp/rg-fzf-{r,f}486 RG_PREFIX="rg --column --line-number --no-heading --color=always --smart-case "487 INITIAL_QUERY="${*:-}"490-: | fzf --ansi --disabled --query "$INITIAL_QUERY" \488+fzf --ansi --disabled --query "$INITIAL_QUERY" \489 --bind "start:reload:$RG_PREFIX {q}" \490 --bind "change:reload:sleep 0.1; $RG_PREFIX {q} || true" \491 --bind 'ctrl-t:transform:[[ ! $FZF_PROMPT =~ ripgrep ]] &&492 echo "rebind(change)+change-prompt(1. ripgrep> )+disable-search+transform-query:echo \{q} > /tmp/rg-fzf-f; cat /tmp/rg-fzf-r" ||31 unmodified lines524 Kubernetes pods.525 526 ```bash527 pods() {530- : | command='kubectl get pods --all-namespaces' fzf \528+ command='kubectl get pods --all-namespaces' fzf \529 --info=inline --layout=reverse --header-lines=1 \530 --prompt "$(kubectl config current-context | sed 's/-context$//')> " \531 --header $'╱ Enter (kubectl exec) ╱ CTRL-O (open log in editor) ╱ CTRL-R (reload) ╱\n\n' \532 --bind 'start:reload:$command' \144 unmodified lines