Add --freeze-right=N option to keep the rightmost N fields visible

This commit is contained in:
Junegunn Choi
2025-11-09 19:41:58 +09:00
parent 07d53cb7e4
commit b9f2bf64ff
5 changed files with 119 additions and 31 deletions

View File

@@ -105,6 +105,7 @@ Usage: fzf [options]
--gap-line[=STR] Draw horizontal line on each gap using the string
(default: '┈' or '-')
--freeze-left=N Number of fields to freeze on the left
--freeze-right=N Number of fields to freeze on the right
--keep-right Keep the right end of the line visible on overflow
--scroll-off=LINES Number of screen lines to keep above or below when
scrolling to the top or to the bottom (default: 0)
@@ -564,6 +565,7 @@ type Options struct {
Normalize bool
Nth []Range
FreezeLeft int
FreezeRight int
WithNth func(Delimiter) func([]Token, int32) string
AcceptNth func(Delimiter) func([]Token, int32) string
Delimiter Delimiter
@@ -2701,6 +2703,10 @@ func parseOptions(index *int, opts *Options, allArgs []string) error {
if opts.FreezeLeft, err = nextInt("number of fields required"); err != nil {
return err
}
case "--freeze-right":
if opts.FreezeRight, err = nextInt("number of fields required"); err != nil {
return err
}
case "--with-nth":
str, err := nextString("nth expression required")
if err != nil {
@@ -3344,7 +3350,7 @@ func parseOptions(index *int, opts *Options, allArgs []string) error {
return errors.New("empty jump labels")
}
if opts.FreezeLeft < 0 {
if opts.FreezeLeft < 0 || opts.FreezeRight < 0 {
return errors.New("number of fields to freeze must be a non-negative integer")
}