feat: add numbercursorfmt option (#2395)

* feat: add `numbercursorfmt` option

* docs: add documentation

* docs: update `CHANGELOG.md`
This commit is contained in:
CatsDeservePets authored and GitHub committed 2026-02-18 15:18:28 +01:00
1 parent b2f23e6078
commit 59494d1ff8
7 files changed
+27 -8

No files matched your search

+1
View File
@@ -13,6 +13,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
### Added
- A new field `.All` is added to the `ruler` file to display the number of all files (i.e. visible + hidden) in the current working directory (#2376).
- A new option `numbercursorfmt` is added to further customize the appearance of line numbers (#2395).
### Fixed
+5 -2
View File
@@ -290,6 +290,7 @@ The following options can be used to customize the behavior of lf:
mergeindicators bool (default false)
mouse bool (default false)
number bool (default false)
numbercursorfmt string (default '')
numberfmt string (default "\033[33m")
period int (default 0)
preload bool (default false)
@@ -1027,9 +1028,11 @@ Send mouse events as input.
Show the position number for directory items on the left side of the pane.
When the `relativenumber` option is enabled, only the current line shows the absolute position and relative positions are shown for the rest.
## numberfmt (string) (default `\033[33m`)
## numberfmt (string) (default `\033[33m`), numbercursorfmt (string) (default ``)
Format string of the position number for each line.
Format strings for highlighting line numbers.
`numberfmt` applies to all lines.
`numbercursorfmt` applies to the cursor line and falls back to `numberfmt` when left empty.
## period (int) (default 0)
+5 -2
View File
@@ -302,6 +302,7 @@ The following options can be used to customize the behavior of lf:
mergeindicators bool (default false)
mouse bool (default false)
number bool (default false)
numbercursorfmt string (default '')
numberfmt string (default "\033[33m")
period int (default 0)
preload bool (default false)
@@ -1112,9 +1113,11 @@ pane. When the relativenumber option is enabled, only the current line
shows the absolute position and relative positions are shown for the
rest.
numberfmt (string) (default \033[33m)
numberfmt (string) (default \033[33m), numbercursorfmt (string) (default ``)
Format string of the position number for each line.
Format strings for highlighting line numbers. numberfmt applies to all
lines. numbercursorfmt applies to the cursor line and falls back to
numberfmt when left empty.
period (int) (default 0)
+2
View File
@@ -273,6 +273,8 @@ func (e *setExpr) eval(app *app, _ []string) {
gOpts.menuheaderfmt = e.val
case "menuselectfmt":
gOpts.menuselectfmt = e.val
case "numbercursorfmt":
gOpts.numbercursorfmt = e.val
case "numberfmt":
gOpts.numberfmt = e.val
case "period":
+7 -3
View File
@@ -1,6 +1,6 @@
.\" Automatically generated by Pandoc 3.7.0.2
.\"
.TH "LF" "1" "2026\-02\-08" "r42" "DOCUMENTATION"
.TH "LF" "1" "2026\-02\-16" "r42" "DOCUMENTATION"
.SH NAME
lf \- terminal file manager
.SH SYNOPSIS
@@ -314,6 +314,7 @@ menuselectfmt string (default \(dq\(rs033[7m\(dq)
mergeindicators bool (default false)
mouse bool (default false)
number bool (default false)
numbercursorfmt string (default \(aq\(aq)
numberfmt string (default \(dq\(rs033[33m\(dq)
period int (default 0)
preload bool (default false)
@@ -979,8 +980,11 @@ pane.
When the \f[CR]relativenumber\f[R] option is enabled, only the current
line shows the absolute position and relative positions are shown for
the rest.
.SS numberfmt (string) (default \f[CR]\(rs033[33m\f[R])
Format string of the position number for each line.
.SS numberfmt (string) (default \f[CR]\(rs033[33m\f[R]), numbercursorfmt (string) (default \(ga\(ga)
Format strings for highlighting line numbers.
\f[CR]numberfmt\f[R] applies to all lines.
\f[CR]numbercursorfmt\f[R] applies to the cursor line and falls back to
\f[CR]numberfmt\f[R] when left empty.
.SS period (int) (default 0)
Set the interval in seconds for periodic checks of directory updates.
This works by periodically calling the \f[CR]load\f[R] command.
+2
View File
@@ -77,6 +77,7 @@ var gOpts struct {
mergeindicators bool
mouse bool
number bool
numbercursorfmt string
numberfmt string
period int
preload bool
@@ -240,6 +241,7 @@ func init() {
gOpts.mergeindicators = false
gOpts.mouse = false
gOpts.number = false
gOpts.numbercursorfmt = ""
gOpts.numberfmt = "\033[33m"
gOpts.period = 0
gOpts.preload = false
+5 -1
View File
@@ -450,7 +450,11 @@ func (win *win) printDir(ui *ui, dir *dir, context *dirContext, dirStyle *dirSty
}
}
win.print(ui.screen, 0, i, tcell.StyleDefault, fmt.Sprintf(optionToFmtstr(gOpts.numberfmt), ln))
fmtStr := optionToFmtstr(gOpts.numberfmt)
if i == dir.pos && gOpts.numbercursorfmt != "" {
fmtStr = optionToFmtstr(gOpts.numbercursorfmt)
}
win.print(ui.screen, 0, i, tcell.StyleDefault, fmt.Sprintf(fmtStr, ln))
}
path := filepath.Join(dir.path, f.Name())