m/fzf
1
0
mirror of https://github.com/junegunn/fzf.git synced 2025-11-08 11:23:47 -05:00

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
This commit is contained in:
Junegunn Choi
2023-12-25 23:43:46 +09:00
parent 41d4d70b98
commit 1707b8cdba
10 changed files with 255 additions and 52 deletions

View File

@@ -89,6 +89,9 @@ bench:
install: bin/fzf
generate:
PATH=$(PATH):$(GOPATH)/bin $(GO) generate ./...
build:
goreleaser build --rm-dist --snapshot --skip-post-hooks
@@ -181,4 +184,4 @@ update:
$(GO) get -u
$(GO) mod tidy
.PHONY: all build release test bench install clean docker docker-test update
.PHONY: all generate build release test bench install clean docker docker-test update