From 120cd7f25a8209297f15b0a79b36c44b30e641fb Mon Sep 17 00:00:00 2001 From: Andreas Auernhammer Date: Sat, 4 Jan 2025 10:30:32 +0100 Subject: Add `border-native` option to `--tmux` flag (#4157) This commit adds the `border-native` resulting in the following: ``` --tmux[=[center|top|bottom|left|right][,SIZE[%]][,SIZE[%]][,border-native]] ``` By default, when not specified, the `-B` flag is passed to the `tmux popup-window` command such that no border is drawn around the tmux popup window. When the `border-native` option is present, the `-B` flag is omitted and the popup window is drawn using the border style configured in the tmux config file. Fixes #4156 Signed-off-by: Andreas Auernhammer Co-authored-by: Junegunn Choi --- src/options.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src/options.go') diff --git a/src/options.go b/src/options.go index 0b6250f3..a3096d11 100644 --- a/src/options.go +++ b/src/options.go @@ -77,7 +77,7 @@ Usage: fzf [options] (default: 10) --tmux[=OPTS] Start fzf in a tmux popup (requires tmux 3.3+) [center|top|bottom|left|right][,SIZE[%]][,SIZE[%]] - (default: center,50%) + [,border-native] (default: center,50%) --layout=LAYOUT Choose layout: [default|reverse|reverse-list] --border[=STYLE] Draw border around the finder [rounded|sharp|bold|block|thinblock|double|horizontal|vertical| @@ -254,6 +254,7 @@ type tmuxOptions struct { height sizeSpec position windowPosition index int + border bool } type layoutType int @@ -316,11 +317,19 @@ func parseTmuxOptions(arg string, index int) (*tmuxOptions, error) { var err error opts := defaultTmuxOptions(index) tokens := splitRegexp.Split(arg, -1) - errorToReturn := errors.New("invalid tmux option: " + arg + " (expected: [center|top|bottom|left|right][,SIZE[%]][,SIZE[%]])") - if len(tokens) == 0 || len(tokens) > 3 { + errorToReturn := errors.New("invalid tmux option: " + arg + " (expected: [center|top|bottom|left|right][,SIZE[%]][,SIZE[%][,border-native]])") + if len(tokens) == 0 || len(tokens) > 4 { return nil, errorToReturn } + for i, token := range tokens { + if token == "border-native" { + tokens = append(tokens[:i], tokens[i+1:]...) // cut the 'border-native' option + opts.border = true + break + } + } + // Defaults to 'center' switch tokens[0] { case "top", "up": -- cgit v1.2.3