diff options
author | Junegunn Choi <junegunn.c@gmail.com> | 2023-12-25 23:43:46 +0900 |
---|---|---|
committer | Junegunn Choi <junegunn.c@gmail.com> | 2023-12-26 00:14:05 +0900 |
commit | 1707b8cdba42492a88b3fc43c15c20d219c5ce2b (patch) | |
tree | 268e6950fecc4bec86b38389101e52901134b3a5 /man/man1/fzf.1 | |
parent | 41d4d70b985f665c8ecc66b83aa10209c8dfbbfd (diff) |
Add 'transform' action to conditionally perform a series of actions
'transform' action runs an external command that prints a series of
actions to perform.
# Disallow selecting an empty line
echo -e "1. Hello\n2. Goodbye\n\n3. Exit" |
fzf --reverse --header 'Select one' \
--bind 'enter:transform:[[ -n {} ]] && echo accept || echo "change-header:Invalid selection"'
# Move cursor past the empty line
echo -e "1. Hello\n2. Goodbye\n\n3. Exit" |
fzf --reverse --header 'Select one' \
--bind 'enter:transform:[[ -n {} ]] && echo accept || echo "change-header:Invalid selection"' \
--bind 'focus:transform:[[ -n {} ]] && exit; [[ {fzf:action} =~ up$ ]] && echo up || echo down'
Close #3368
Close #2980
Diffstat (limited to 'man/man1/fzf.1')
-rw-r--r-- | man/man1/fzf.1 | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/man/man1/fzf.1 b/man/man1/fzf.1 index c4fe788c..20e7e17d 100644 --- a/man/man1/fzf.1 +++ b/man/man1/fzf.1 @@ -574,10 +574,6 @@ e.g. When using a field index expression, leading and trailing whitespace is stripped from the replacement string. To preserve the whitespace, use the \fBs\fR flag. -Also, \fB{q}\fR is replaced to the current query string, and \fB{n}\fR is -replaced to zero-based ordinal index of the line. Use \fB{+n}\fR if you want -all index numbers when multiple lines are selected. - A placeholder expression with \fBf\fR flag is replaced to the path of a temporary file that holds the evaluated list. This is useful when you multi-select a large number of items and the length of the evaluated string may @@ -589,6 +585,15 @@ e.g. seq 100000 | fzf --multi --bind ctrl-a:select-all \\ --preview "awk '{sum+=\\$1} END {print sum}' {+f}"\fR +Also, + +* \fB{q}\fR (or \fB{fzf:query}\fR) is replaced to the current query string +.br +* \fB{n}\fR is replaced to the zero-based ordinal index of the current item. + Use \fB{+n}\fR if you want all index numbers when multiple lines are selected. +.br +* \fB{fzf:action}\fR is replaced to to the name of the last action performed + Note that you can escape a placeholder pattern by prepending a backslash. Preview window will be updated even when there is no match for the current |