Skip to content
Myr

Enhance --min-height option to take number followed by +

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Junegunn Choi · committed by Junegunn Choi · parent b83dd6c · Browse files · 9 files+71 added−14 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

9 files+71 added−14 removed

  • tests:+31 added−0 removed
  • other:+40 added−14 removed

9 files+71 added−14 removed

modified:man/man1/fzf.1+6 added-3 removed
334 unmodified lines
335.br336* It will not find the right size when there are multi-line items337338.TP339.BI "\-\-min\-height=" "HEIGHT"340Minimum height when \fB\-\-height\fR is given in percent (default: 10).341Ignored when \fB\-\-height\fR is not specified.339.BI "\-\-min\-height=" "HEIGHT[+]"340Minimum height when \fB\-\-height\fR is given as a percentage.341Add \fB+\fR to automatically increase the value according to the other342layout options so that the specified number of items are visible in the list343section (default: \fB10+\fR).344Ignored when \fB\-\-height\fR is not specified or set as an absolute value.345.TP346.BI "\-\-tmux" "[=[center|top|bottom|left|right][,SIZE[%]][,SIZE[%]][,border-native]]"347Start fzf in a tmux popup (default \fBcenter,50%\fR). Requires tmux 3.3 or348later. This option is ignored if you are not running fzf inside tmux.
1495 unmodified lines
modified:shell/completion.bash+1 added-1 removed
35 unmodified lines
3637__fzf_defaults() {38 # $1: Prepend to FZF_DEFAULT_OPTS_FILE and FZF_DEFAULT_OPTS39 # $2: Append to FZF_DEFAULT_OPTS_FILE and FZF_DEFAULT_OPTS40 echo "--height ${FZF_TMUX_HEIGHT:-40%} --bind=ctrl-z:ignore $1"40 echo "--height ${FZF_TMUX_HEIGHT:-40%} --min-height 20+ --bind=ctrl-z:ignore $1"41 command cat "${FZF_DEFAULT_OPTS_FILE-}" 2> /dev/null42 echo "${FZF_DEFAULT_OPTS-} $2"43}44
581 unmodified lines
modified:shell/completion.zsh+1 added-1 removed
97 unmodified lines
9899__fzf_defaults() {100 # $1: Prepend to FZF_DEFAULT_OPTS_FILE and FZF_DEFAULT_OPTS101 # $2: Append to FZF_DEFAULT_OPTS_FILE and FZF_DEFAULT_OPTS102 echo "--height ${FZF_TMUX_HEIGHT:-40%} --bind=ctrl-z:ignore $1"102 echo "--height ${FZF_TMUX_HEIGHT:-40%} --min-height 20+ --bind=ctrl-z:ignore $1"103 command cat "${FZF_DEFAULT_OPTS_FILE-}" 2> /dev/null104 echo "${FZF_DEFAULT_OPTS-} $2"105}106
309 unmodified lines
modified:shell/key-bindings.bash+1 added-1 removed
modified:shell/key-bindings.fish+1 added-1 removed
18 unmodified lines
19 function __fzf_defaults20 # $1: Prepend to FZF_DEFAULT_OPTS_FILE and FZF_DEFAULT_OPTS21 # $2: Append to FZF_DEFAULT_OPTS_FILE and FZF_DEFAULT_OPTS22 test -n "$FZF_TMUX_HEIGHT"; or set FZF_TMUX_HEIGHT 40%23 echo "--height $FZF_TMUX_HEIGHT --bind=ctrl-z:ignore" $argv[1]23 echo "--height $FZF_TMUX_HEIGHT --min-height 20+ --bind=ctrl-z:ignore" $argv[1]24 test -r "$FZF_DEFAULT_OPTS_FILE"; and string collect -N -- <$FZF_DEFAULT_OPTS_FILE25 echo $FZF_DEFAULT_OPTS $argv[2]26 end27
172 unmodified lines
modified:shell/key-bindings.zsh+1 added-1 removed
39 unmodified lines
4041__fzf_defaults() {42 # $1: Prepend to FZF_DEFAULT_OPTS_FILE and FZF_DEFAULT_OPTS43 # $2: Append to FZF_DEFAULT_OPTS_FILE and FZF_DEFAULT_OPTS44 echo "--height ${FZF_TMUX_HEIGHT:-40%} --bind=ctrl-z:ignore $1"44 echo "--height ${FZF_TMUX_HEIGHT:-40%} --min-height 20+ --bind=ctrl-z:ignore $1"45 command cat "${FZF_DEFAULT_OPTS_FILE-}" 2> /dev/null46 echo "${FZF_DEFAULT_OPTS-} $2"47}48
96 unmodified lines
modified:src/options.go+20 added-6 removed
67 unmodified lines
68 A negative value is calculated as the terminal height69 minus the given value.70 If prefixed with '~', fzf will determine the height71 according to the input size.72 --min-height=HEIGHT Minimum height for percent --height is given in percent73 (default: 10 or above depending on the other options)72 --min-height=HEIGHT[+] Minimum height when --height is given as a percentage.73 Add '+' to automatically increase the value74 according to the other layout options (default: 10+).75 --tmux[=OPTS] Start fzf in a tmux popup (requires tmux 3.3+)76 [center|top|bottom|left|right][,SIZE[%]][,SIZE[%]]77 [,border-native] (default: center,50%)78
594 unmodified lines
673 Mouse: true,674 Theme: theme,675 Black: false,676 Bold: true,676 MinHeight: -1,677 MinHeight: -10,678 Layout: layoutDefault,679 Cycle: false,680 Wrap: false,681 MultiLine: true,
1980 unmodified lines
2662 if opts.Height, err = parseHeight(str, index); err != nil {2663 return err2664 }2665 case "--min-height":2665 if opts.MinHeight, err = nextInt("height required: HEIGHT"); err != nil {2666 expr, err := nextString("minimum height required: HEIGHT[+]")2667 if err != nil {2668 return err2669 }2670 auto := false2671 if strings.HasSuffix(expr, "+") {2672 expr = expr[:len(expr)-1]2673 auto = true2674 }2675 num, err := atoi(expr)2676 if err != nil || num < 0 {2677 return errors.New("minimum height must be a non-negative integer")2678 }2679 if auto {2680 num *= -12681 }2682 opts.MinHeight = num2683 case "--no-height":2684 opts.Height = heightSpec{}2685 case "--no-margin":2686 opts.Margin = defaultMargin()
547 unmodified lines
3234 }32353236 // Sets --min-height automatically3237 if opts.Height.size > 0 && opts.Height.percent && opts.MinHeight < 0 {3223 // 10 items and 1 prompt line3224 opts.MinHeight = 10 + 1 + borderLines(opts.BorderShape) + borderLines(opts.ListBorderShape) + borderLines(opts.InputBorderShape)3238 opts.MinHeight = -opts.MinHeight + 1 + borderLines(opts.BorderShape) + borderLines(opts.ListBorderShape) + borderLines(opts.InputBorderShape)3239 if len(opts.Header) > 0 {3240 opts.MinHeight += borderLines(opts.HeaderBorderShape) + len(opts.Header)3241 }3242 if opts.HeaderLines > 0 {
132 unmodified lines
modified:test/test_layout.rb+31 added
843 unmodified lines
844 assert lines[1]&.start_with?('│ 1')845 assert lines[1]&.end_with?('1000││')846 end847 end848849 def test_min_height_no_auto850 tmux.send_keys %(seq 100 | #{FZF} --border sharp --style full:sharp --height 1% --min-height 5), :Enter851852 block = <<~BLOCK853 ┌───────854 │ ┌─────855 │ │ >856 │ └─────857 └───────858 BLOCK859 tmux.until { assert_block(block, _1) }860 end861862 def test_min_height_auto863 tmux.send_keys %(seq 100 | #{FZF} --style full:sharp --height 1% --min-height 5+), :Enter864865 block = <<~BLOCK866 ┌─────────867 │ 5868 │ 4869 │ 3870 │ 2871 │ > 1872 └─────────873 ┌─────────874 │ >875 └─────────876 BLOCK877 tmux.until { assert_block(block, _1) }878 end879end
modified:CHANGELOG.md+9 added
51 unmodified lines
52 ```sh53 # Load 'ps -ef' output on start and reload it on CTRL-R54 fzf --bind 'start,ctrl-r:reload:ps -ef'55 ```56- `--min-height` option now takes a number followed by `+`, which tells fzf to show at least that many items in the list section. The default value is now changed to `10+`.57 ```sh58 # You will only see the input section which takes 3 lines59 fzf --style=full --height 1% --min-height 36061 # You will see 3 items in the list section62 fzf --style full --height 1% --min-height 3+63 ```64 - Shell integration scripts were updated to use `--min-height 20+` by default65- Added `bell` action to ring the terminal bell66 ```sh67 # Press CTRL-Y to copy the current line to the clipboard and ring the bell68 fzf --bind 'ctrl-y:execute-silent(echo -n {} | pbcopy)+bell'
2435 unmodified lines