diff options
author | tv <tv@krebsco.de> | 2023-09-11 18:24:28 +0200 |
---|---|---|
committer | tv <tv@krebsco.de> | 2023-09-13 18:07:11 +0200 |
commit | 0c4f3acb281be6290c55a6e96bc29fab5b5c7a11 (patch) | |
tree | dadaec00477a095273475ac345b2066b4748c399 /pkgs/override/fzf | |
parent | ab1d0479e90f11806d4703ec6fffed3d5f782914 (diff) |
stockholm -> hrm
Diffstat (limited to 'pkgs/override/fzf')
-rw-r--r-- | pkgs/override/fzf/complete1.patch | 77 | ||||
-rw-r--r-- | pkgs/override/fzf/default.nix | 7 |
2 files changed, 84 insertions, 0 deletions
diff --git a/pkgs/override/fzf/complete1.patch b/pkgs/override/fzf/complete1.patch new file mode 100644 index 0000000..3e3f2c4 --- /dev/null +++ b/pkgs/override/fzf/complete1.patch @@ -0,0 +1,77 @@ +commit 57cbd76c068121b685399fdb4649e7ba537983d6 +Author: tv <tv@krebsco.de> +Date: Mon Dec 5 15:24:30 2022 +0100 + + Add --complete-1 option + +diff --git a/man/man1/fzf.1 b/man/man1/fzf.1 +index 79e7291..3b8a753 100644 +--- a/man/man1/fzf.1 ++++ b/man/man1/fzf.1 +@@ -685,6 +685,9 @@ interactive finder and automatically select the only match + If there is no match for the initial query (\fB--query\fR), do not start + interactive finder and exit immediately + .TP ++.B "--complete-1" ++Exit interactive finder when there's exactly one match ++.TP + .BI "-f, --filter=" "STR" + Filter mode. Do not start interactive finder. When used with \fB--no-sort\fR, + fzf becomes a fuzzy-version of grep. +diff --git a/src/core.go b/src/core.go +index 2ddddc3..09afff2 100644 +--- a/src/core.go ++++ b/src/core.go +@@ -337,8 +337,14 @@ func Run(opts *Options, version string, revision string) { + } + determine(val.final) + } ++ } else { ++ if opts.Complete1 && val.Length() == 1 { ++ opts.Printer(val.Get(0).item.AsString(opts.Ansi)) ++ terminal.reqBox.Set(reqClose, nil) ++ } else { ++ terminal.UpdateList(val, clearSelection()) ++ } + } +- terminal.UpdateList(val, clearSelection()) + } + } + } +diff --git a/src/options.go b/src/options.go +index 5400311..1e38fe4 100644 +--- a/src/options.go ++++ b/src/options.go +@@ -108,6 +108,7 @@ const usage = `usage: fzf [options] + -1, --select-1 Automatically select the only match + -0, --exit-0 Exit immediately when there's no match + -f, --filter=STR Filter mode. Do not start interactive finder. ++ --complete-1 Exit interactive finder when there's exactly one match + --print-query Print query as the first line + --expect=KEYS Comma-separated list of keys to complete fzf + --read0 Read input delimited by ASCII NUL characters +@@ -274,6 +275,7 @@ type Options struct { + Query string + Select1 bool + Exit0 bool ++ Complete1 bool + Filter *string + ToggleSort bool + Expect map[tui.Event]string +@@ -342,6 +344,7 @@ func defaultOptions() *Options { + Query: "", + Select1: false, + Exit0: false, ++ Complete1: false, + Filter: nil, + ToggleSort: false, + Expect: make(map[tui.Event]string), +@@ -1546,6 +1549,8 @@ func parseOptions(opts *Options, allArgs []string) { + opts.Exit0 = true + case "+0", "--no-exit-0": + opts.Exit0 = false ++ case "--complete-1": ++ opts.Complete1 = true + case "--read0": + opts.ReadZero = true + case "--no-read0": diff --git a/pkgs/override/fzf/default.nix b/pkgs/override/fzf/default.nix new file mode 100644 index 0000000..2254d45 --- /dev/null +++ b/pkgs/override/fzf/default.nix @@ -0,0 +1,7 @@ +self: super: + +super.fzf.overrideAttrs (old: { + patches = old.patches or [] ++ [ + ./complete1.patch + ]; +}) |