summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--man/man1/fzf.110
-rw-r--r--src/options.go33
2 files changed, 23 insertions, 20 deletions
diff --git a/man/man1/fzf.1 b/man/man1/fzf.1
index d1c2cdc0..c85d1069 100644
--- a/man/man1/fzf.1
+++ b/man/man1/fzf.1
@@ -228,13 +228,13 @@ Adaptive height has the following limitations:
Minimum height when \fB--height\fR is given in percent (default: 10).
Ignored when \fB--height\fR is not specified.
.TP
-.BI "--tmux=" "[center|top|bottom|left|right][,SIZE[%]][,SIZE[%]]"
-Start fzf in a tmux popup. Requires tmux 3.3 or later. This option is ignored
-if you are not running fzf inside tmux.
+.BI "--tmux" "[=[center|top|bottom|left|right][,SIZE[%]][,SIZE[%]]]"
+Start fzf in a tmux popup (default \fBcenter,50%\fR). Requires tmux 3.3 or
+later. This option is ignored if you are not running fzf inside tmux.
e.g.
- \fB# Popup in the center with 80% width height
- fzf --tmux 80%
+ \fB# Popup in the center with 70% width and height
+ fzf --tmux 70%
# Popup on the left with 40% width and 100% height
fzf --tmux right,40%
diff --git a/src/options.go b/src/options.go
index 9df1298e..8b77d950 100644
--- a/src/options.go
+++ b/src/options.go
@@ -71,8 +71,9 @@ Usage: fzf [options]
according to the input size.
--min-height=HEIGHT Minimum height when --height is given in percent
(default: 10)
- --tmux=OPTS Start fzf in a tmux popup (requires tmux 3.3+)
+ --tmux[=OPTS] Start fzf in a tmux popup (requires tmux 3.3+)
[center|top|bottom|left|right][,SIZE[%]][,SIZE[%]]
+ (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|
@@ -278,9 +279,16 @@ func (o *previewOpts) Toggle() {
o.hidden = !o.hidden
}
+func defaultTmuxOptions() *tmuxOptions {
+ return &tmuxOptions{
+ position: posCenter,
+ width: sizeSpec{50, true},
+ height: sizeSpec{50, true}}
+}
+
func parseTmuxOptions(arg string) (*tmuxOptions, error) {
var err error
- opts := tmuxOptions{}
+ opts := defaultTmuxOptions()
tokens := splitRegexp.Split(arg, -1)
if len(tokens) == 0 || len(tokens) > 3 {
return nil, errors.New("invalid tmux option: " + arg + " (expected: [center|top|bottom|left|right][,SIZE[%]][,SIZE[%]])")
@@ -301,13 +309,7 @@ func parseTmuxOptions(arg string) (*tmuxOptions, error) {
opts.position = posRight
opts.height = sizeSpec{100, true}
case "center":
- opts.position = posCenter
- opts.width = sizeSpec{50, true}
- opts.height = sizeSpec{50, true}
default:
- opts.position = posCenter
- opts.width = sizeSpec{50, true}
- opts.height = sizeSpec{50, true}
tokens = append([]string{"center"}, tokens...)
}
@@ -343,7 +345,7 @@ func parseTmuxOptions(arg string) (*tmuxOptions, error) {
}
}
- return &opts, nil
+ return opts, nil
}
func parseLabelPosition(opts *labelOpts, arg string) error {
@@ -1941,12 +1943,13 @@ func parseOptions(opts *Options, allArgs []string) error {
case "--no-winpty":
opts.NoWinpty = true
case "--tmux":
- str, err := nextString(allArgs, &i, "tmux options required")
- if err != nil {
- return err
- }
- if opts.Tmux, err = parseTmuxOptions(str); err != nil {
- return err
+ given, str := optionalNextString(allArgs, &i)
+ if given {
+ if opts.Tmux, err = parseTmuxOptions(str); err != nil {
+ return err
+ }
+ } else {
+ opts.Tmux = defaultTmuxOptions()
}
case "--no-tmux":
opts.Tmux = nil