From 673c5d886d51fceb3df6bc96edf234837a6442a8 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Thu, 4 Nov 2021 00:49:05 +0900 Subject: [PATCH] Add 'put' action for putting the character to the prompt fzf --bind 'space:preview(date)+put' Close #2456 --- man/man1/fzf.1 | 1 + src/options.go | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/man/man1/fzf.1 b/man/man1/fzf.1 index b4721d0..5f5eb91 100644 --- a/man/man1/fzf.1 +++ b/man/man1/fzf.1 @@ -860,6 +860,7 @@ A key or an event can be bound to one or more of the following actions. \fBpreview-top\fR \fBprevious-history\fR (\fIctrl-p\fR on \fB--history\fR) \fBprint-query\fR (print query and exit) + \fBput\fR (put the character to the prompt) \fBrefresh-preview\fR \fBreload(...)\fR (see below for the details) \fBreplace-query\fR (replace query string with the current selection) diff --git a/src/options.go b/src/options.go index e2c03dd..b93fd97 100644 --- a/src/options.go +++ b/src/options.go @@ -981,6 +981,12 @@ func parseKeymap(keymap map[tui.Event][]action, str string) { appendAction(actEnableSearch) case "disable-search": appendAction(actDisableSearch) + case "put": + if key.Type == tui.Rune && unicode.IsGraphic(key.Char) { + appendAction(actRune) + } else { + errorExit("unable to put non-printable character: " + pair[0]) + } default: t := isExecuteAction(specLower) if t == actIgnore {