summaryrefslogtreecommitdiff
path: root/CHANGELOG.md
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2025-01-27 15:40:21 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2025-01-27 18:04:57 +0900
commita2aa1a156c29658b62a691f8aa343985043b8c9c (patch)
tree291473b3e429657d064227b9ee5af991e12102fa /CHANGELOG.md
parent2f8a72a42a7503276a99cc0234f98f8c56169320 (diff)
downloadfzf-a2aa1a156c29658b62a691f8aa343985043b8c9c.tar.gz
Allow {q} placeholders with range expressions
e.g. {q:1}, {q:2..}
Diffstat (limited to 'CHANGELOG.md')
-rw-r--r--CHANGELOG.md24
1 files changed, 12 insertions, 12 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index dda3be87..3bd90d78 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -14,7 +14,7 @@ CHANGELOG
--bind 'ctrl-r:reload(ps -ef)' --header 'Press CTRL-R to reload' \
--header-lines-border bottom --no-list-border
```
-- `click-header` event will also set `$FZF_CLICK_HEADER_WORD` and `$FZF_CLICK_HEADER_NTH`. You can use it to implement a clickable header that changes the search scope using the new `transform-nth` action.
+- `click-header` event now sets `$FZF_CLICK_HEADER_WORD` and `$FZF_CLICK_HEADER_NTH`. You can use them to implement a clickable header for changing the search scope using the new `transform-nth` action.
```sh
# Click on the header line to limit search scope
ps -ef | fzf --style full --layout reverse --header-lines 1 \
@@ -26,21 +26,21 @@ CHANGELOG
echo "$FZF_CLICK_HEADER_WORD> "
)'
```
+ - `$FZF_KEY` was updated to expose the type of the click. e.g. `click`, `ctrl-click`, etc. You can use it to implement a more sophisticated behavior.
- `kill` completion for bash and zsh were updated to use this feature
+- Extended `{q}` placeholder to support ranges. e.g. `{q:1}`, `{q:2..}`, etc.
- Added `search(...)` and `transform-search(...)` action to trigger an fzf search with an arbitrary query string. This can be used to extend the search syntax of fzf. In the following example, fzf will use the first word of the query to trigger ripgrep search, and use the rest of the query to perform fzf search within the result.
```sh
TRANSFORMER='
- words=($FZF_QUERY)
-
- # If $FZF_QUERY contains multiple words, drop the first word,
- # and trigger fzf search with the rest
- if [[ ${#words[@]} -gt 1 ]]; then
- echo "search:${FZF_QUERY#* }"
-
- # Otherwise, if the query does not end with a space,
- # restart ripgrep and reload the list
- elif ! [[ $FZF_QUERY =~ \ $ ]]; then
- echo "reload:rg --column --color=always --smart-case \"${words[0]}\""
+ rg_pat={q:1} # The first word is passed to ripgrep
+ fzf_pat={q:2..} # The rest are passed to fzf
+ rg_pat_org={q:s1} # The first word with trailing whitespaces preserved.
+ # We use this to avoid unnecessary reloading of ripgrep.
+
+ if [[ -n $fzf_pat ]]; then
+ echo "search:$fzf_pat"
+ elif ! [[ $rg_pat_org =~ \ $ ]]; then
+ printf "reload:sleep 0.1; rg --column --line-number --no-heading --color=always --smart-case %q || true" "$rg_pat"
else
echo search:
fi