summaryrefslogtreecommitdiff
path: root/ADVANCED.md
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2024-06-24 17:22:46 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2024-06-24 17:23:14 +0900
commitcc2b2146ee30ad38f3ed62c43bb211af48f88d2f (patch)
tree8af2862d313ca1ca25fc0a8ecf854a61e0701e1c /ADVANCED.md
parent8689f5f230aab25012bd5521149abd32a9964dfc (diff)
downloadfzf-cc2b2146ee30ad38f3ed62c43bb211af48f88d2f.tar.gz
ADVANCED.md: Remove unnecessary `: | fzf`
See 5b52833
Diffstat (limited to 'ADVANCED.md')
-rw-r--r--ADVANCED.md22
1 files changed, 10 insertions, 12 deletions
diff --git a/ADVANCED.md b/ADVANCED.md
index 187b6f77..b152d5a6 100644
--- a/ADVANCED.md
+++ b/ADVANCED.md
@@ -1,8 +1,8 @@
Advanced fzf examples
======================
-* *Last update: 2024/06/06*
-* *Requires fzf 0.53.0 or later*
+* *Last update: 2024/06/24*
+* *Requires fzf 0.54.0 or later*
---
@@ -361,7 +361,7 @@ projects, and it will free up memory as you narrow down the results.
# 3. Open the file in Vim
RG_PREFIX="rg --column --line-number --no-heading --color=always --smart-case "
INITIAL_QUERY="${*:-}"
-: | fzf --ansi --disabled --query "$INITIAL_QUERY" \
+fzf --ansi --disabled --query "$INITIAL_QUERY" \
--bind "start:reload:$RG_PREFIX {q}" \
--bind "change:reload:sleep 0.1; $RG_PREFIX {q} || true" \
--delimiter : \
@@ -372,11 +372,9 @@ INITIAL_QUERY="${*:-}"
![image](https://user-images.githubusercontent.com/700826/113684212-f9ff0a00-96ff-11eb-8737-7bb571d320cc.png)
-- Instead of starting fzf in the usual `rg ... | fzf` form, we start fzf with
- an empty input (`: | fzf`), then we make it start the initial Ripgrep
- process immediately via `start:reload` binding. This way, fzf owns the
- initial Ripgrep process so it can kill it on the next `reload`. Otherwise,
- the process will keep running in the background.
+- Instead of starting fzf in the usual `rg ... | fzf` form, we make it start
+ the initial Ripgrep process immediately via `start:reload` binding for the
+ consistency of the code.
- Filtering is no longer a responsibility of fzf; hence `--disabled`
- `{q}` in the reload command evaluates to the query string on fzf prompt.
- `sleep 0.1` in the reload command is for "debouncing". This small delay will
@@ -400,7 +398,7 @@ fzf-only search mode by *"unbinding"* `reload` action from `change` event.
# 3. Open the file in Vim
RG_PREFIX="rg --column --line-number --no-heading --color=always --smart-case "
INITIAL_QUERY="${*:-}"
-: | fzf --ansi --disabled --query "$INITIAL_QUERY" \
+fzf --ansi --disabled --query "$INITIAL_QUERY" \
--bind "start:reload:$RG_PREFIX {q}" \
--bind "change:reload:sleep 0.1; $RG_PREFIX {q} || true" \
--bind "alt-enter:unbind(change,alt-enter)+change-prompt(2. fzf> )+enable-search+clear-query" \
@@ -444,7 +442,7 @@ CTRL-F.
rm -f /tmp/rg-fzf-{r,f}
RG_PREFIX="rg --column --line-number --no-heading --color=always --smart-case "
INITIAL_QUERY="${*:-}"
-: | fzf --ansi --disabled --query "$INITIAL_QUERY" \
+fzf --ansi --disabled --query "$INITIAL_QUERY" \
--bind "start:reload($RG_PREFIX {q})+unbind(ctrl-r)" \
--bind "change:reload:sleep 0.1; $RG_PREFIX {q} || true" \
--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)" \
@@ -487,7 +485,7 @@ prevent immediate evaluation.
rm -f /tmp/rg-fzf-{r,f}
RG_PREFIX="rg --column --line-number --no-heading --color=always --smart-case "
INITIAL_QUERY="${*:-}"
-: | fzf --ansi --disabled --query "$INITIAL_QUERY" \
+fzf --ansi --disabled --query "$INITIAL_QUERY" \
--bind "start:reload:$RG_PREFIX {q}" \
--bind "change:reload:sleep 0.1; $RG_PREFIX {q} || true" \
--bind 'ctrl-t:transform:[[ ! $FZF_PROMPT =~ ripgrep ]] &&
@@ -527,7 +525,7 @@ Kubernetes pods.
```bash
pods() {
- : | command='kubectl get pods --all-namespaces' fzf \
+ command='kubectl get pods --all-namespaces' fzf \
--info=inline --layout=reverse --header-lines=1 \
--prompt "$(kubectl config current-context | sed 's/-context$//')> " \
--header $'╱ Enter (kubectl exec) ╱ CTRL-O (open log in editor) ╱ CTRL-R (reload) ╱\n\n' \