Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
- A new option `borderstyle` is added to control whether `drawbox` draws an outline, separators, or both (#2445). This also replaces the existing `roundbox` option.
- The `loading...` message delay of 100 milliseconds for file previews is now applied to directories as well (#2410).
- `lf` will now automatically change to the parent directory if the current directory no longer exists and the `watch` option is enabled (#2424).
- A new option `hiddenfmt` is added to colour hidden files and directories (#2492).

### Fixed

Expand Down
1 change: 1 addition & 0 deletions colors.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ func (sm styleMap) parseBSD(env string) {
}
}


func (sm styleMap) get(f *file) tcell.Style {
if val, ok := sm.styles[f.path]; ok {
return val
Expand Down
9 changes: 9 additions & 0 deletions doc.md
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ The following options can be used to customize the behavior of lf:
filtermethod string (default 'text')
findlen int (default 1)
hidden bool (default false)
hiddenfmt string (default '')
hiddenfiles []string (default '.*' for Unix and '' for Windows)
history bool (default true)
icons bool (default false)
Expand Down Expand Up @@ -955,6 +956,14 @@ Show hidden files.
On Unix systems, hidden files are determined by the value of `hiddenfiles`.
On Windows, files with hidden attributes are also considered hidden files.

## hiddenfmt (string) (default ``)

Format string for colouring hidden files and directories.
When set to a non-empty value, it overrides the normal colour for entries considered hidden (see `hiddenfiles`).
Hidden detection on Windows also respects the filesystem hidden attribute.
Leave empty to disable and fall back to the regular colour lookup.
Example: `set hiddenfmt "\033[3;38;2;146;131;116m"`.

## hiddenfiles ([]string) (default `.*` for Unix and `` for Windows)

List of hidden file glob patterns.
Expand Down
9 changes: 9 additions & 0 deletions doc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1031,6 +1031,15 @@ Show hidden files. On Unix systems, hidden files are determined by the
value of hiddenfiles. On Windows, files with hidden attributes are also
considered hidden files.

hiddendirfmt (string) (default ``), hiddenfilefmt (string) (default ``)

Format strings for colouring hidden directories and files. When set to
a non-empty value, they override the normal di and fi colours for
entries considered hidden (see hiddenfiles). Hidden detection on
Windows also respects the filesystem hidden attribute. Leave empty to
disable and fall back to the regular colour lookup. Example: set
hiddendirfmt "\033[3;38;2;146;131;116m".

hiddenfiles ([]string) (default .* for Unix and `` for Windows)

List of hidden file glob patterns. Patterns can be given as relative or
Expand Down
2 changes: 2 additions & 0 deletions eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,8 @@ func (e *setExpr) eval(app *app, _ []string) {
return
}
gOpts.findlen = n
case "hiddenfmt":
gOpts.hiddenfmt = e.val
case "hiddenfiles":
toks := strings.Split(e.val, ":")
for _, s := range toks {
Expand Down
11 changes: 11 additions & 0 deletions lf.1
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,8 @@ filesep string (default \(dq\(rsn\(dq)
filtermethod string (default \(aqtext\(aq)
findlen int (default 1)
hidden bool (default false)
hiddendirfmt string (default \(aq\(aq)
hiddenfilefmt string (default \(aq\(aq)
hiddenfiles []string (default \(aq.*\(aq for Unix and \(aq\(aq for Windows)
history bool (default true)
icons bool (default false)
Expand Down Expand Up @@ -922,6 +924,15 @@ On Unix systems, hidden files are determined by the value of
\f[CR]hiddenfiles\f[R].
On Windows, files with hidden attributes are also considered hidden
files.
.SS hiddendirfmt (string) (default \(ga\(ga), hiddenfilefmt (string) (default \(ga\(ga)
Format strings for colouring hidden directories and files.
When set to a non-empty value, they override the normal \f[CR]di\f[R]
and \f[CR]fi\f[R] colours for entries considered hidden (see
\f[CR]hiddenfiles\f[R]).
Hidden detection on Windows also respects the filesystem hidden
attribute.
Leave empty to disable and fall back to the regular colour lookup.
Example: \f[CR]set hiddendirfmt \(dq\(rs033[3;38;2;146;131;116m\(dq\f[R].
.SS hiddenfiles ([]string) (default \f[CR].*\f[R] for Unix and \(ga\(ga for Windows)
List of hidden file glob patterns.
Patterns can be given as relative or absolute paths.
Expand Down
2 changes: 2 additions & 0 deletions opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ var gOpts struct {
filtermethod searchMethod
findlen int
hidden bool
hiddenfmt string
hiddenfiles []string
history bool
icons bool
Expand Down Expand Up @@ -245,6 +246,7 @@ func init() {
gOpts.filtermethod = textSearch
gOpts.findlen = 1
gOpts.hidden = false
gOpts.hiddenfmt = ""
gOpts.hiddenfiles = gDefaultHiddenFiles
gOpts.history = true
gOpts.icons = false
Expand Down
7 changes: 6 additions & 1 deletion ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,12 @@ func (win *win) printDir(ui *ui, dir *dir, context *dirContext, dirStyle *dirSty

visualSelections := dir.visualSelections()
for i, f := range dir.files[beg:end] {
st := dirStyle.colors.get(f)
var st tcell.Style
if gOpts.hiddenfmt != "" && isHidden(f, dir.path, gOpts.hiddenfiles) {
st = parseEscapeSequence(gOpts.hiddenfmt)
} else {
st = dirStyle.colors.get(f)
}

if lnwidth > 0 {
var ln string
Expand Down