Compare commits

29 Commits
Author SHA1 Message Date
Joe Lim 49f2a7c6c4 Prepare for r38 release (#2163) 2025-09-19 14:18:55 +10:00
CatsDeservePets d81c84bbb9 Update docs (#2160) 2025-09-19 03:39:15 +10:00
CatsDeservePets c5075b6455 Update documentation (#2149)
* Fix typos

* Unify spelling

* Improve grammar and wording

* Update usage of `filename` and `file name`

* Prefer `without` over `w/o`

* Generate docs
2025-09-18 13:41:24 +10:00
Joe Lim d2e125d264 Update CHANGELOG.md (#2157) 2025-09-17 15:32:49 +10:00
CatsDeservePets d2bcae2943 Unify usage and synopsis (#2153) 2025-09-17 15:17:21 +10:00
CatsDeservePets f050abc57c Fix: UI glitch with completion menu #2139 (#2140) 2025-09-10 12:28:33 +10:00
Joe Lim 9c0dc813a3 Update CHANGELOG.md (#2143) 2025-09-09 16:28:03 +10:00
Carlo Teubner 995413426c lf -remote: work around busyloop issue on Linux (#2138)
I noticed that running ":maps" in lf on Linux uses a whole CPU. I
managed to track it down to a bug in the Go standard library, for which
I entered https://github.com/golang/go/issues/75304.

Until that is fixed, it seems worth having a workaround for this.
2025-09-09 16:01:22 +10:00
CatsDeservePets b73daad7cc Fix typo in documentation (#2141) 2025-09-09 13:50:08 +10:00
CatsDeservePets f94c62661a Update documentation to mention PowerShell config (#2135) 2025-09-08 14:03:04 +10:00
dependabot[bot] 168a64a288 Bump actions/setup-go from 5 to 6 (#2133)
Bumps [actions/setup-go](https://github.com/actions/setup-go) from 5 to 6.
- [Release notes](https://github.com/actions/setup-go/releases)
- [Commits](https://github.com/actions/setup-go/compare/v5...v6)

---
updated-dependencies:
- dependency-name: actions/setup-go
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-09-08 00:30:24 +10:00
Joe Lim 8dad85197f Remove padding for text previews (#2131)
* Remove offset for text previews

* Update `CHANGELOG.md`

* reword
2025-09-04 15:38:57 +10:00
Joe Lim d079cc8719 Fix copy progress bug when copying files with 0 size (#2130)
* Fix copy progress when copying files with 0 size

* typo

* Update `CHANGELOG.md`
2025-09-04 14:44:29 +10:00
Joe Lim f26b30be18 Rename doc command to help (#2125)
* Rename `doc` command to `help`

* Update `CHANGELOG.md`
2025-08-28 14:47:36 +10:00
Joe Lim ad5af1b2c7 Update CHANGELOG.md (#2124) 2025-08-27 20:01:11 +10:00
Joe Lim 7297e4f522 Add options for customizing the appearance of the menu (#2123)
* Refactor for loop

* Save menu selection

* Add options to customize menu style

* Add documentation
2025-08-27 19:49:07 +10:00
Joe Lim f2d2bb0f2c Draw menu over sixel images if they overlap (#2122)
* Refactor menu drawing code

* Fix menu and sixel overlap
2025-08-27 17:51:47 +10:00
Joe Lim 75334c25a5 Use ratio for more accurate humanize implementation (#2121) 2025-08-27 13:25:32 +10:00
Joe Lim ae583e96d3 Support XDG_CONFIG_HOME/XDG_DATA_HOME on Windows (#2119) 2025-08-26 22:55:45 +10:00
Joe Lim 4fe8f5a858 Add option to specify binary or decimal sizes (#2118)
* Add option to specify binary or decimal sizes

* Fix test case error message

* Add documentation

* Fix typo
2025-08-26 22:32:33 +10:00
Joe Lim 8150586bc2 Clear error messages after a command runs successfully (#2117)
* Draw stat info on demand

* Remove loadfileinfo function

* Fix clearmsg bug when opening directories

* Move visual code
2025-08-26 17:48:15 +10:00
Joe Lim 8f97bf806a Add unit tests for escape sequence parse functions (#2116) 2025-08-26 14:49:33 +10:00
Joe Lim 04afd78e65 Refactor dir.sort function (#2115)
* Refactor filtering code in `dir.sort` function

* Refactor sorting code in `dir.sort` function

* Fix bug
2025-08-26 14:16:54 +10:00
Joe Lim 4384e520b5 Update CONTRIBUTING.md (#2114) 2025-08-26 03:29:52 +10:00
Joe Lim e60c055be3 Remove experimental locale feature (#2111) 2025-08-26 01:41:01 +10:00
Joe Lim 06955cbacc Remove dircache option (#2110) 2025-08-25 23:06:30 +10:00
Joe Lim 13da770af6 Implement builtin support for sixel images, allow combining with text (#2109)
* Add function for reading lines in file

* Implement sixel drawing

* Remove sixel option

* Fix linting error
2025-08-25 22:19:14 +10:00
Joe Lim aba73884e3 Remove deprecated globfilter/globsearch options (#2108) 2025-08-25 15:14:28 +10:00
dependabot[bot] 5a4b0881d7 Bump github.com/gdamore/tcell/v2 from 2.8.1 to 2.9.0 (#2106)
Bumps [github.com/gdamore/tcell/v2](https://github.com/gdamore/tcell) from 2.8.1 to 2.9.0.
- [Release notes](https://github.com/gdamore/tcell/releases)
- [Changelog](https://github.com/gdamore/tcell/blob/main/CHANGESv2.md)
- [Commits](https://github.com/gdamore/tcell/compare/v2.8.1...v2.9.0)

---
updated-dependencies:
- dependency-name: github.com/gdamore/tcell/v2
  dependency-version: 2.9.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-08-25 15:06:06 +10:00
25 changed files with 1119 additions and 1030 deletions

No files matched your search

+3 -3
View File
@@ -19,7 +19,7 @@ jobs:
fetch-depth: 1 fetch-depth: 1
- name: Set up Go - name: Set up Go
uses: actions/setup-go@v5 uses: actions/setup-go@v6
with: with:
go-version: "1.23" go-version: "1.23"
@@ -42,7 +42,7 @@ jobs:
fetch-depth: 1 fetch-depth: 1
- name: Set up Go - name: Set up Go
uses: actions/setup-go@v5 uses: actions/setup-go@v6
with: with:
go-version: "1.23" go-version: "1.23"
@@ -57,7 +57,7 @@ jobs:
fetch-depth: 1 fetch-depth: 1
- name: Set up Go - name: Set up Go
uses: actions/setup-go@v5 uses: actions/setup-go@v6
with: with:
go-version: "1.23" go-version: "1.23"
+1 -1
View File
@@ -13,7 +13,7 @@ jobs:
- uses: actions/checkout@v5 - uses: actions/checkout@v5
- name: Set up Go - name: Set up Go
uses: actions/setup-go@v5 uses: actions/setup-go@v6
with: with:
go-version: "1.23" go-version: "1.23"
+27 -1
View File
@@ -8,6 +8,32 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
- `Added` - `Added`
- `Fixed` - `Fixed`
## [r38](https://github.com/gokcehan/lf/releases/tag/r38)
### Changed
- The deprecated `globfilter` and `globsearch` options are now removed (#2108).
- Sixel image support is now enabled by default, and the `sixel` option has been removed as it is no longer required (#2109).
- The `dircache` option has now been removed (#2110). This was previously used as a workaround to disable the directory cache since at the time changes to files were not detected reliably, but this is no longer the case.
- The experimental `locale` option has been removed in favor of the recommendation to use `addcustominfo`/`set sortby custom` for custom sorting (#2111).
- The existing `doc` command has been renamed to `help` so that it is more natural for users (#2125).
- Text previews are no longer displayed with a padding of two spaces by default (#2131). Instead, a custom padding can be added in the `previewer` script, for example by piping to `sed 's/^/ /'`.
### Added
- Sixel image previews can now display multiple images as well as text (#2109).
- A new option `sizeunits` is added to allow displaying file sizes in either binary or decimal units (#2118).
- `XDG_CONFIG_HOME` and `XDG_DATA_HOME` are now taken into account when looking up config/data files on Windows (#2119).
- Three new options `menufmt`, `menuheaderfmt`, and `menuselectfmt` are added to customize the appearance of the menu (#2123).
### Fixed
- Error messages are now cleared after running interactive commands such as `invert`/`unselect`/`tag-toggle` (#2117).
- The menu is now drawn over sixel images instead of being hidden behind it if they overlap (#2122).
- A bug which prevents the user from quitting when copying files with a size of 0 has been fixed (#2130).
- `lf -remote` should no longer busy wait and cause high CPU usage if its output is not being read (#2138).
- The parameter types for command line options shown by `lf -help` now match the synopsis in the documentation (#2153).
## [r37](https://github.com/gokcehan/lf/releases/tag/r37) ## [r37](https://github.com/gokcehan/lf/releases/tag/r37)
### Changed ### Changed
@@ -28,7 +54,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
- The selection in Visual mode now follows wrapping when `wrapscan`/`wrapscroll` is enabled (#2056). - The selection in Visual mode now follows wrapping when `wrapscan`/`wrapscroll` is enabled (#2056).
- Input pasted from the terminal is now ignored while in Normal mode (#2059). This prevents pasted content from being treated as keybindings, which can result in dangerous unintended behavior. - Input pasted from the terminal is now ignored while in Normal mode (#2059). This prevents pasted content from being treated as keybindings, which can result in dangerous unintended behavior.
- The Command-line mode completion now supports keywords for the `selmode` and `sortby` options (#2061), as well as the `info` and `preserve` options (#2071). - The Command-line mode completion now supports keywords for the `selmode` and `sortby` options (#2061), as well as the `info` and `preserve` options (#2071).
- Command line flags are now exported as environment variables in the form `lf_flag_{flag}` (#2079). - Command line options are now exported as environment variables in the form `lf_flag_{flag}` (#2079).
- Support is added for terminal escape sequences that disable text styles (#2101). - Support is added for terminal escape sequences that disable text styles (#2101).
### Fixed ### Fixed
+6 -3
View File
@@ -28,7 +28,7 @@ Adding a new option usually requires the following steps:
- Add option evaluation logic to `setExpr.eval` in `eval.go` - Add option evaluation logic to `setExpr.eval` in `eval.go`
- Implement the option somewhere in the code - Implement the option somewhere in the code
- Add option name and its default value to `Quick Reference` and `Options` sections in `doc.md` - Add option name and its default value to `Quick Reference` and `Options` sections in `doc.md`
- Run `gen/doc.sh` to update the documentation (requires podman/docker) - Run `gen/doc.sh` to update the documentation (optional as it requires `docker`/`podman`, but appreciated)
- Commit your changes and send a pull request - Commit your changes and send a pull request
## Adding a new builtin command ## Adding a new builtin command
@@ -40,11 +40,14 @@ Adding a new command usually requires the following steps:
- Implement the command somewhere in the code - Implement the command somewhere in the code
- Add command name to `gCmdWords` in `complete.go` for tab completion - Add command name to `gCmdWords` in `complete.go` for tab completion
- Add command name to `Quick Reference` and `Commands` sections in `doc.md` - Add command name to `Quick Reference` and `Commands` sections in `doc.md`
- Optionally, run `gen/doc.sh` to update the documentation (requires podman/docker) - Run `gen/doc.sh` to update the documentation (optional as it requires `docker`/`podman`, but appreciated)
- Commit your changes and send a pull request - Commit your changes and send a pull request
## Platform specific code ## Platform specific code
There are two files named `os.go` and `os_windows.go` for unix and windows specific code respectively. There are two files named `os.go` and `os_windows.go` for Unix and Windows specific code respectively.
If you add something to either of these files but not the other, you probably break the build for the other platform. If you add something to either of these files but not the other, you probably break the build for the other platform.
If your addition works the same in both platforms, your addition probably belongs to `main.go` instead. If your addition works the same in both platforms, your addition probably belongs to `main.go` instead.
There are also different variants of the `df` functionality provided by `df_openbsd.go`, `df_statfs.go`, `df_statvfs.go` and `df_windows.go`.
Where applicable, ensure that any changes you make are reflected across all of these files for consistency.
+4 -18
View File
@@ -340,8 +340,8 @@ func (app *app) loop() {
log.Print("bye!") log.Print("bye!")
return return
case <-app.nav.copyJobsChan: case n := <-app.nav.copyJobsChan:
app.nav.copyJobs += 1 app.nav.copyJobs += n
app.ui.draw(app.nav) app.ui.draw(app.nav)
case n := <-app.nav.copyBytesChan: case n := <-app.nav.copyBytesChan:
app.nav.copyBytes += n app.nav.copyBytes += n
@@ -391,7 +391,6 @@ func (app *app) loop() {
} }
app.ui.draw(app.nav) app.ui.draw(app.nav)
case d := <-app.nav.dirChan: case d := <-app.nav.dirChan:
if gOpts.dircache {
prev, ok := app.nav.dirCache[d.path] prev, ok := app.nav.dirCache[d.path]
if ok { if ok {
d.ind = prev.ind d.ind = prev.ind
@@ -402,11 +401,7 @@ func (app *app) loop() {
d.sort() d.sort()
d.sel(prev.name(), app.nav.height) d.sel(prev.name(), app.nav.height)
} }
app.nav.dirCache[d.path] = d app.nav.dirCache[d.path] = d
} else {
d.sort()
}
var oldCurrPath string var oldCurrPath string
if curr, err := app.nav.currFile(); err == nil { if curr, err := app.nav.currFile(); err == nil {
@@ -425,9 +420,6 @@ func (app *app) loop() {
if err == nil { if err == nil {
if curr.path != oldCurrPath { if curr.path != oldCurrPath {
app.ui.loadFile(app, true) app.ui.loadFile(app, true)
if app.ui.msgIsStat {
app.ui.loadFileInfo(app.nav)
}
} }
if d.path == curr.path { if d.path == curr.path {
app.ui.dirPrev = d app.ui.dirPrev = d
@@ -450,11 +442,9 @@ func (app *app) loop() {
if err == nil { if err == nil {
if r.path == curr.path { if r.path == curr.path {
app.ui.regPrev = r app.ui.regPrev = r
if gOpts.sixel {
app.ui.sxScreen.forceClear = true app.ui.sxScreen.forceClear = true
} }
} }
}
app.ui.draw(app.nav) app.ui.draw(app.nav)
case f := <-app.nav.fileChan: case f := <-app.nav.fileChan:
@@ -476,10 +466,6 @@ func (app *app) loop() {
} }
app.ui.loadFile(app, false) app.ui.loadFile(app, false)
if app.ui.msgIsStat {
app.ui.loadFileInfo(app.nav)
}
onLoad(app, []string{f.path}) onLoad(app, []string{f.path})
app.ui.draw(app.nav) app.ui.draw(app.nav)
case path := <-app.nav.delChan: case path := <-app.nav.delChan:
@@ -688,7 +674,7 @@ func (app *app) doComplete() (matches []compMatch) {
} }
app.ui.cmdAccLeft = []rune(result) app.ui.cmdAccLeft = []rune(result)
app.ui.menu = listMatches(app.ui.screen, matches, -1) app.ui.menu, app.ui.menuSelect = listMatches(app.ui.screen, matches, -1)
return return
} }
@@ -711,7 +697,7 @@ func (app *app) menuComplete(direction int) {
app.menuCompTmp[len(app.menuCompTmp)-1] = app.menuComps[app.menuCompInd].result app.menuCompTmp[len(app.menuCompTmp)-1] = app.menuComps[app.menuCompInd].result
app.ui.cmdAccLeft = []rune(strings.Join(app.menuCompTmp, " ")) app.ui.cmdAccLeft = []rune(strings.Join(app.menuCompTmp, " "))
} }
app.ui.menu = listMatches(app.ui.screen, app.menuComps, app.menuCompInd) app.ui.menu, app.ui.menuSelect = listMatches(app.ui.screen, app.menuComps, app.menuCompInd)
} }
func (app *app) watchDir(dir *dir) { func (app *app) watchDir(dir *dir) {
+10 -2
View File
@@ -182,9 +182,17 @@ func remote(cmd string) error {
v.CloseWrite() v.CloseWrite()
} }
io.Copy(os.Stdout, c) // The most straightforward way to write the reponse to stdout would be
// to do "io.Copy(os.Stdout, c)". However, on Linux, if stdout is connected to
// something like a pager that isn't immediately reading everything,
// this runs into Go bug https://github.com/golang/go/issues/75304 and
// busy-loops, eating a whole CPU.
response, err := io.ReadAll(c)
if err != nil {
return fmt.Errorf("reading response from server: %w", err)
}
c.Close() c.Close()
os.Stdout.Write(response)
return nil return nil
} }
-8
View File
@@ -88,14 +88,6 @@ func parseStyles() styleMap {
return sm return sm
} }
func parseEscapeSequence(s string) tcell.Style {
s = strings.TrimPrefix(s, "\033[")
if i := strings.IndexByte(s, 'm'); i >= 0 {
s = s[:i]
}
return applyAnsiCodes(s, tcell.StyleDefault)
}
func parseColor(toks []string) (tcell.Color, int, error) { func parseColor(toks []string) (tcell.Color, int, error) {
if len(toks) == 0 { if len(toks) == 0 {
return tcell.ColorDefault, 0, fmt.Errorf("invalid args: %v", toks) return tcell.ColorDefault, 0, fmt.Errorf("invalid args: %v", toks)
+2
View File
@@ -398,6 +398,8 @@ func completeCmd(acc []rune) (matches []compMatch, result string) {
matches, result = matchList(f[2], []string{"mode", "timestamps"}) matches, result = matchList(f[2], []string{"mode", "timestamps"})
case "selmode": case "selmode":
matches, result = matchWord(f[2], []string{"all", "dir"}) matches, result = matchWord(f[2], []string{"all", "dir"})
case "sizeunits":
matches, result = matchWord(f[2], []string{"binary", "decimal"})
case "sortby": case "sortby":
matches, result = matchWord(f[2], []string{"atime", "btime", "ctime", "custom", "ext", "name", "natural", "size", "time"}) matches, result = matchWord(f[2], []string{"atime", "btime", "ctime", "custom", "ext", "name", "natural", "size", "time"})
default: default:
+136 -82
View File
@@ -10,7 +10,7 @@ lf - terminal file manager
[**-cpuprofile** *path*] [**-cpuprofile** *path*]
[**-doc**] [**-doc**]
[**-last-dir-path** *path*] [**-last-dir-path** *path*]
[**-log path**] [**-log** *path*]
[**-memprofile** *path*] [**-memprofile** *path*]
[**-print-last-dir**] [**-print-last-dir**]
[**-print-selection**] [**-print-selection**]
@@ -29,7 +29,7 @@ lf is a terminal file manager.
The source code can be found in the repository at https://github.com/gokcehan/lf The source code can be found in the repository at https://github.com/gokcehan/lf
This documentation can either be read from the terminal using `lf -doc` or online at https://github.com/gokcehan/lf/blob/master/doc.md This documentation can either be read from the terminal using `lf -doc` or online at https://github.com/gokcehan/lf/blob/master/doc.md
You can also use the `doc` command (default `<f-1>`) inside lf to view the documentation in a pager. You can also use the `help` command (default `<f-1>`) inside lf to view the documentation in a pager.
A man page with the same content is also available in the repository at https://github.com/gokcehan/lf/blob/master/lf.1 A man page with the same content is also available in the repository at https://github.com/gokcehan/lf/blob/master/lf.1
You can run `lf -help` to see descriptions of command line options. You can run `lf -help` to see descriptions of command line options.
@@ -155,7 +155,6 @@ The following options can be used to customize the behavior of lf:
cursorparentfmt string (default "\033[7m") cursorparentfmt string (default "\033[7m")
cursorpreviewfmt string (default "\033[4m") cursorpreviewfmt string (default "\033[4m")
cutfmt string (default "\033[7;31m") cutfmt string (default "\033[7;31m")
dircache bool (default true)
dircounts bool (default false) dircounts bool (default false)
dirfirst bool (default true) dirfirst bool (default true)
dironly bool (default false) dironly bool (default false)
@@ -178,7 +177,9 @@ The following options can be used to customize the behavior of lf:
info []string (default '') info []string (default '')
infotimefmtnew string (default 'Jan _2 15:04') infotimefmtnew string (default 'Jan _2 15:04')
infotimefmtold string (default 'Jan _2 2006') infotimefmtold string (default 'Jan _2 2006')
locale string (default '') menufmt string (default "\033[0m")
menuheaderfmt string (default "\033[1m")
menuselectfmt string (default "\033[7m")
mouse bool (default false) mouse bool (default false)
number bool (default false) number bool (default false)
numberfmt string (default "\033[33m") numberfmt string (default "\033[33m")
@@ -200,7 +201,7 @@ The following options can be used to customize the behavior of lf:
shellflag string (default '-c' for Unix and '/c' for Windows) shellflag string (default '-c' for Unix and '/c' for Windows)
shellopts []string (default '') shellopts []string (default '')
showbinds bool (default true) showbinds bool (default true)
sixel bool (default false) sizeunits string (default 'binary')
smartcase bool (default true) smartcase bool (default true)
smartdia bool (default false) smartdia bool (default false)
sortby string (default 'natural') sortby string (default 'natural')
@@ -265,8 +266,8 @@ The following commands/keybindings are provided by default:
map e $$EDITOR "$f" map e $$EDITOR "$f"
map i $$PAGER "$f" map i $$PAGER "$f"
map w $$SHELL map w $$SHELL
cmd doc $$lf -doc | $PAGER cmd help $$lf -doc | $PAGER
map <f-1> doc map <f-1> help
cmd maps $lf -remote "query $id maps" | $PAGER cmd maps $lf -remote "query $id maps" | $PAGER
cmd nmaps $lf -remote "query $id nmaps" | $PAGER cmd nmaps $lf -remote "query $id nmaps" | $PAGER
cmd vmaps $lf -remote "query $id vmaps" | $PAGER cmd vmaps $lf -remote "query $id vmaps" | $PAGER
@@ -278,14 +279,18 @@ The following commands/keybindings are provided by default:
map e $%EDITOR% %f% map e $%EDITOR% %f%
map i !%PAGER% %f% map i !%PAGER% %f%
map w $%SHELL% map w $%SHELL%
cmd doc !%lf% -doc | %PAGER% cmd help !%lf% -doc | %PAGER%
map <f-1> doc map <f-1> help
cmd maps !%lf% -remote "query %id% maps" | %PAGER% cmd maps !%lf% -remote "query %id% maps" | %PAGER%
cmd nmaps !%lf% -remote "query %id% nmaps" | %PAGER% cmd nmaps !%lf% -remote "query %id% nmaps" | %PAGER%
cmd vmaps !%lf% -remote "query %id% vmaps" | %PAGER% cmd vmaps !%lf% -remote "query %id% vmaps" | %PAGER%
cmd cmaps !%lf% -remote "query %id% cmaps" | %PAGER% cmd cmaps !%lf% -remote "query %id% cmaps" | %PAGER%
cmd cmds !%lf% -remote "query %id% cmds" | %PAGER% cmd cmds !%lf% -remote "query %id% cmds" | %PAGER%
The defaults for Windows are using `cmd` syntax.
A `PowerShell` compatible configuration file can be found at
https://github.com/gokcehan/lf/blob/master/etc/lfrc.ps1.example
The following additional keybindings are provided by default: The following additional keybindings are provided by default:
map zh set hidden! map zh set hidden!
@@ -310,7 +315,7 @@ If the `mouse` option is enabled, mouse buttons have the following default effec
Click on a file or directory to select it. Click on a file or directory to select it.
Right mouse button Right mouse button
Enter a directory or open a file. Also works on the preview window. Enter a directory or open a file. Also works on the preview pane.
Scroll wheel Scroll wheel
Move up or down. If Ctrl is pressed, scroll up or down. Move up or down. If Ctrl is pressed, scroll up or down.
@@ -368,9 +373,11 @@ You can configure these locations with the following variables given with their
Windows Windows
%LF_CONFIG_HOME% %LF_CONFIG_HOME%
%XDG_CONFIG_HOME%
%APPDATA% %APPDATA%
%LF_DATA_HOME% %LF_DATA_HOME%
%XDG_DATA_HOME%
%LOCALAPPDATA% %LOCALAPPDATA%
A sample configuration file can be found at A sample configuration file can be found at
@@ -496,7 +503,7 @@ Read a shell command to execute piping its standard I/O to the bottom statline.
## shell-wait (modal) (default `!`) ## shell-wait (modal) (default `!`)
Read a shell command to execute and wait for a key press in the end. Read a shell command to execute and wait for a key press at the end.
## shell-async (modal) (default `&`) ## shell-async (modal) (default `&`)
@@ -504,11 +511,11 @@ Read a shell command to execute asynchronously without standard I/O.
## find (modal) (default `f`), find-back (modal) (default `F`), find-next (default `;`), find-prev (default `,`) ## find (modal) (default `f`), find-back (modal) (default `F`), find-next (default `;`), find-prev (default `,`)
Read key(s) to find the appropriate file name match in the forward/backward direction and jump to the next/previous match. Read key(s) to find the appropriate filename match in the forward/backward direction and jump to the next/previous match.
## search (default `/`), search-back (default `?`), search-next (default `n`), search-prev (default `N`) ## search (default `/`), search-back (default `?`), search-next (default `n`), search-prev (default `N`)
Read a pattern to search for a file name match in the forward/backward direction and jump to the next/previous match. Read a pattern to search for a filename match in the forward/backward direction and jump to the next/previous match.
## filter (modal), setfilter ## filter (modal), setfilter
@@ -536,7 +543,7 @@ You can define a new tag-clearing command by combining `tag` with `tag-toggle` (
## tag-toggle (default `t`) ## tag-toggle (default `t`)
Tag a file with `*` or a single width character given in the argument if the file is untagged, otherwise remove the tag. Tag a file with `*` or a single-width character given in the argument if the file is untagged, otherwise remove the tag.
## echo ## echo
@@ -622,7 +629,7 @@ When the cursor is at the first character in `:` mode, pressing one of the keys
You can go back with `cmd-delete-back` (`<backspace>` by default). You can go back with `cmd-delete-back` (`<backspace>` by default).
The command line commands should be mostly compatible with readline keybindings. The command line commands should be mostly compatible with readline keybindings.
A character refers to a Unicode code point, a word consists of letters and digits, and a unix word consists of any non-blank characters. A character refers to a Unicode code point, a word consists of letters and digits, and a Unix word consists of any non-blank characters.
## cmd-insert ## cmd-insert
@@ -682,7 +689,7 @@ Delete everything up to the beginning/end of the line.
## cmd-delete-unix-word (default `<c-w>`) ## cmd-delete-unix-word (default `<c-w>`)
Delete the previous unix word. Delete the previous Unix word.
## cmd-yank (default `<c-y>`) ## cmd-yank (default `<c-y>`)
@@ -715,7 +722,7 @@ Character `:` is used as the separator for list options `[]int` and `[]string`.
## anchorfind (bool) (default true) ## anchorfind (bool) (default true)
When this option is enabled, the find command starts matching patterns from the beginning of file names, otherwise, it can match at an arbitrary position. When this option is enabled, the find command starts matching patterns from the beginning of filenames, otherwise, it can match at an arbitrary position.
## autoquit (bool) (default true) ## autoquit (bool) (default true)
@@ -730,14 +737,14 @@ Format string of the box drawing characters enabled by the `drawbox` option.
Set the path of a cleaner file. Set the path of a cleaner file.
The file should be executable. The file should be executable.
This file is called if previewing is enabled, the previewer is set, and the previously selected file has its preview cache disabled. This file is called if previewing is enabled, the previewer is set, and the previously selected file has its preview cache disabled.
The following arguments are passed to the file, (1) current file name, (2) width, (3) height, (4) horizontal position, (5) vertical position of preview pane and (6) next file name to be previewed respectively. The following arguments are passed to the file, (1) current filename, (2) width, (3) height, (4) horizontal position, (5) vertical position of preview pane and (6) next filename to be previewed respectively.
Preview cleaning is disabled when the value of this option is left empty. Preview cleaning is disabled when the value of this option is left empty.
## copyfmt (string) (default `\033[7;33m`) ## copyfmt (string) (default `\033[7;33m`)
Format string of the indicator for files to be copied. Format string of the indicator for files to be copied.
## cursoractivefmt (string) (default `\033[7m`), cursorparentfmt string (default `\033[7m`), cursorpreviewfmt string (default `\033[4m`) ## cursoractivefmt (string) (default `\033[7m`), cursorparentfmt (string) (default `\033[7m`), cursorpreviewfmt (string) (default `\033[4m`)
Format strings for highlighting the cursor. Format strings for highlighting the cursor.
`cursoractivefmt` applies in the current directory pane, `cursoractivefmt` applies in the current directory pane,
@@ -755,10 +762,6 @@ For example, `\033[4m%s\033[0m` has the same effect as `\033[4m`.
Format string of the indicator for files to be cut. Format string of the indicator for files to be cut.
## dircache (bool) (default true)
Cache directory contents.
## dircounts (bool) (default false) ## dircounts (bool) (default false)
When this option is enabled, directory sizes show the number of items inside instead of the total size of the directory, which needs to be calculated for each directory using `calcdirsize`. When this option is enabled, directory sizes show the number of items inside instead of the total size of the directory, which needs to be calculated for each directory using `calcdirsize`.
@@ -786,8 +789,8 @@ Draw boxes around panes with box drawing characters.
## dupfilefmt (string) (default `%f.~%n~`) ## dupfilefmt (string) (default `%f.~%n~`)
Format string of file name when creating duplicate files. With the default format, copying a file `abc.txt` to the same directory will result in a duplicate file called `abc.txt.~1~`. Format string of filename when creating duplicate files. With the default format, copying a file `abc.txt` to the same directory will result in a duplicate file called `abc.txt.~1~`.
Special expansions are provided, `%f` as the file name, `%b` for the basename (file name without extension), `%e` as the extension (including the dot) and `%n` as the number of duplicates. Special expansions are provided, `%f` as the file name, `%b` for the base name (file name without extension), `%e` as the extension (including the dot) and `%n` as the number of duplicates.
## errorfmt (string) (default `\033[7;31;47m`) ## errorfmt (string) (default `\033[7;31;47m`)
@@ -803,7 +806,7 @@ File separator used in environment variables `fs`, `fv` and `fx`.
## filtermethod (string) (default `text`) ## filtermethod (string) (default `text`)
How filter command patterns are treated. How filter command patterns are treated.
Currently supported methods are `text` (i.e. string literals), `glob` (i.e shell globs) and `regex` (i.e. regular expressions). Currently supported methods are `text` (i.e. string literals), `glob` (i.e. shell globs) and `regex` (i.e. regular expressions).
See `SEARCHING FILES` for more details. See `SEARCHING FILES` for more details.
## findlen (int) (default 1) ## findlen (int) (default 1)
@@ -860,8 +863,19 @@ Jump to the first match after each keystroke during searching.
## info ([]string) (default ``) ## info ([]string) (default ``)
A list of information that is shown for directory items at the right side of the pane. A list of information that is shown for directory items at the right side of the pane.
Currently supported information types are `size`, `time`, `atime`, `btime`, `ctime`, `perm`, `user`, `group` and `custom`.
The `custom` type is empty by default and can be updated using the `addcustominfo` command. The following information types are supported:
perm file permission
user user name
group group name
size file size
time time of last data modification
atime time of last access
btime time of file birth
ctime time of last status (inode) change
custom property defined via `addcustominfo` (empty by default)
Information is only shown when the pane width is more than twice the width of information. Information is only shown when the pane width is more than twice the width of information.
## infotimefmtnew (string) (default `Jan _2 15:04`) ## infotimefmtnew (string) (default `Jan _2 15:04`)
@@ -872,11 +886,17 @@ Format string of the file time shown in the info column when it matches this yea
Format string of the file time shown in the info column when it doesn't match this year. Format string of the file time shown in the info column when it doesn't match this year.
## locale (string) (default ``) ## menufmt (string) (default `\033[0m`)
An IETF BCP 47 language tag (e.g. `zh-CN`) for specifying the locale used when using sort type `natural` and `name`. Format string of the menu.
An empty string means disable locale ordering, and the special value `*` is used to indicate reading the locale setting from the system environment.
This feature is currently experimental. ## menuheaderfmt (string) (default `\033[1m`)
Format string of the header row in the menu.
## menuselectfmt (string) (default `\033[7m`)
Format string of the currently selected item in the menu.
## mouse (bool) (default false) ## mouse (bool) (default false)
@@ -915,7 +935,7 @@ Files containing the null character (U+0000) in the read portion are considered
Set the path of a previewer file to filter the content of regular files for previewing. Set the path of a previewer file to filter the content of regular files for previewing.
The file should be executable. The file should be executable.
The following arguments are passed to the file, (1) current file name, (2) width, (3) height, (4) horizontal position, and (5) vertical position of preview pane respectively. The following arguments are passed to the file, (1) current filename, (2) width, (3) height, (4) horizontal position, and (5) vertical position of preview pane respectively.
SIGPIPE signal is sent when enough lines are read. SIGPIPE signal is sent when enough lines are read.
If the previewer returns a non-zero exit code, then the preview cache for the given file is disabled. If the previewer returns a non-zero exit code, then the preview cache for the given file is disabled.
This means that if the file is selected in the future, the previewer is called once again. This means that if the file is selected in the future, the previewer is called once again.
@@ -924,7 +944,17 @@ Preview filtering is disabled and files are displayed as they are when the value
## promptfmt (string) (default `\033[32;1m%u@%h\033[0m:\033[34;1m%d\033[0m\033[1m%f\033[0m`) ## promptfmt (string) (default `\033[32;1m%u@%h\033[0m:\033[34;1m%d\033[0m\033[1m%f\033[0m`)
Format string of the prompt shown in the top line. Format string of the prompt shown in the top line.
Special expansions are provided, `%u` as the user name, `%h` as the hostname, `%w` as the working directory, `%d` as the working directory with a trailing path separator, `%f` as the file name, and `%F` as the current filter. `%S` may be used once and will provide a spacer so that the following parts are right aligned on the screen.
The following special expansions are supported:
%f file name
%h host name
%u user name
%w working directory
%d working directory (with trailing path separator)
%F current filter
%S spacer to right-align the following parts (can be used once)
The home folder is shown as `~` in the working directory expansion. The home folder is shown as `~` in the working directory expansion.
Directory names are automatically shortened to a single character starting from the leftmost parent when the prompt does not fit the screen. Directory names are automatically shortened to a single character starting from the leftmost parent when the prompt does not fit the screen.
@@ -950,7 +980,22 @@ Draw rounded outer corners when the `drawbox` option is enabled.
## rulerfmt (string) (default ` %a| %p| \033[7;31m %m \033[0m| \033[7;33m %c \033[0m| \033[7;35m %s \033[0m| \033[7;36m %v \033[0m| \033[7;34m %f \033[0m| %i/%t`) ## rulerfmt (string) (default ` %a| %p| \033[7;31m %m \033[0m| \033[7;33m %c \033[0m| \033[7;35m %s \033[0m| \033[7;36m %v \033[0m| \033[7;34m %f \033[0m| %i/%t`)
Format string of the ruler shown in the bottom right corner. Format string of the ruler shown in the bottom right corner.
Special expansions are provided, `%a` as the pressed keys, `%p` as the progress of file operations, `%m` as the number of files to be cut (moved), `%c` as the number of files to be copied, `%s` as the number of selected files, `%v` as the number of visually selected files, `%f` as the filter, `%i` as the position of the cursor, `%t` as the number of files shown in the current directory, `%h` as the number of files hidden in the current directory, `%P` as the scroll percentage, and `%d` as the amount of free disk space remaining.
The following special expansions are supported:
%a pressed keys
%p progress of file operations
%m number of files to be cut (moved)
%c number of files to be copied
%s number of selected files
%v number of visually selected files
%t number of shown files in the current directory
%h number of hidden files in the current directory
%f current filter
%i cursor position
%P scroll percentage
%d amount of free disk space
Additional expansions are provided for environment variables exported by lf, in the form `%{lf_<name>}` (e.g. `%{lf_selmode}`). This is useful for displaying the current settings. Additional expansions are provided for environment variables exported by lf, in the form `%{lf_<name>}` (e.g. `%{lf_selmode}`). This is useful for displaying the current settings.
Expansions are also provided for user-defined options, in the form `%{lf_user_<name>}` (e.g. `%{lf_user_foo}`). Expansions are also provided for user-defined options, in the form `%{lf_user_<name>}` (e.g. `%{lf_user_foo}`).
The `|` character splits the format string into sections. Any section containing a failed expansion (result is a blank string) is discarded and not shown. The `|` character splits the format string into sections. Any section containing a failed expansion (result is a blank string) is discarded and not shown.
@@ -958,13 +1003,13 @@ The `|` character splits the format string into sections. Any section containing
## scrolloff (int) (default 0) ## scrolloff (int) (default 0)
Minimum number of offset lines shown at all times at the top and bottom of the screen when scrolling. Minimum number of offset lines shown at all times at the top and bottom of the screen when scrolling.
The current line is kept in the middle when this option is set to a large value that is bigger than the half of number of lines. The current line is kept in the middle when this option is set to a large value that is bigger than half the number of lines.
A smaller offset can be used when the current file is close to the beginning or end of the list to show the maximum number of items. A smaller offset can be used when the current file is close to the beginning or end of the list to show the maximum number of items.
## searchmethod (string) default `text`) ## searchmethod (string) (default `text`)
How search command patterns are treated. How search command patterns are treated.
Currently supported methods are `text` (i.e. string literals), `glob` (i.e shell globs) and `regex` (i.e. regular expressions). Currently supported methods are `text` (i.e. string literals), `glob` (i.e. shell globs) and `regex` (i.e. regular expressions).
See `SEARCHING FILES` for more details. See `SEARCHING FILES` for more details.
## selectfmt (string) (default `\033[7;35m`) ## selectfmt (string) (default `\033[7;35m`)
@@ -994,9 +1039,9 @@ List of shell options to pass to the shell executable.
Show bindings associated with pressed keys. Show bindings associated with pressed keys.
## sixel (bool) (default false) ## sizeunits (string) (default `binary`)
Render sixel images in preview. Determines whether file sizes are displayed using binary units (`1K` is 1024 bytes) or decimal units (`1K` is 1000 bytes).
## smartcase (bool) (default true) ## smartcase (bool) (default true)
@@ -1011,29 +1056,38 @@ This option has no effect when `ignoredia` is disabled.
## sortby (string) (default `natural`) ## sortby (string) (default `natural`)
Sort type for directories. Sort type for directories.
Currently supported sort types are `natural`, `name`, `size`, `time`, `atime`, `btime`, `ctime`, `ext` and `custom`.
Meaning of each sort type: The following sort types are supported:
natural file name (track_2.flac comes before track_10.flac) natural file name (track_2.flac comes before track_10.flac)
name file name (track_10.flac comes before track_2.flac) name file name (track_10.flac comes before track_2.flac)
ext file extension
size file size size file size
time time of last data modification time time of last data modification
atime time of last access atime time of last access
btime time of file birth btime time of file birth
ctime time of last status (inode) change ctime time of last status (inode) change
ext file extension custom property defined via `addcustominfo` (empty by default)
custom property defined via `addcustominfo`
## statfmt (string) (default `\033[36m%p\033[0m| %c| %u| %g| %S| %t| -> %l`) ## statfmt (string) (default `\033[36m%p\033[0m| %c| %u| %g| %S| %t| -> %l`)
Format string of the file info shown in the bottom left corner. Format string of the file info shown in the bottom left corner.
Special expansions are provided, `%p` as the file permissions, `%c` as the link count, `%u` as the user, `%g` as the group, `%s` as the file size, `%S` as the file size but with a fixed width of five characters (left-padded with spaces), `%t` as the last modified time, `%l` as the link target, `%m` as the current mode and `%M` as the current mode but also shown in Normal mode (displaying `NORMAL` instead of a blank string).
The following special expansions are supported:
%p file permission
%c link count
%u user name
%g group name
%s file size
%S file size (left-padded with spaces to a fixed width of 5 characters)
%t time of last data modification
%l link target
%m current mode
%M current mode (displaying `NORMAL` instead of a blank string in Normal mode)
The `|` character splits the format string into sections. Any section containing a failed expansion (result is a blank string) is discarded and not shown. The `|` character splits the format string into sections. Any section containing a failed expansion (result is a blank string) is discarded and not shown.
File size is formatted using first letter of IEC 80000-13:2025 prefixes for binary multiples (i.e. 1024 bytes is `1.0K`).
## tabstop (int) (default 8) ## tabstop (int) (default 8)
Number of space characters to show for horizontal tabulation (U+0009) character. Number of space characters to show for horizontal tabulation (U+0009) character.
@@ -1057,7 +1111,7 @@ Format string of the file modification time shown in the bottom line.
## truncatechar (string) (default `~`) ## truncatechar (string) (default `~`)
The truncate character that is shown at the end when the file name does not fit into the pane. The truncate character that is shown at the end when the filename does not fit into the pane.
## truncatepct (int) (default 100) ## truncatepct (int) (default 100)
@@ -1144,7 +1198,7 @@ For example, with POSIX shells, you can use `[ -n "$LF_LEVEL" ] && PS1="$PS1""(l
## OPENER ## OPENER
If this variable is set in the environment, use the same value. Otherwise, this is set to `start` in Windows, `open` in MacOS, `xdg-open` in others. If this variable is set in the environment, use the same value. Otherwise, this is set to `start` in Windows, `open` in macOS, `xdg-open` in others.
## EDITOR ## EDITOR
@@ -1249,7 +1303,7 @@ This shell command can be defined to be executed before quitting.
The following command prefixes are used by lf: The following command prefixes are used by lf:
: read (default) builtin/custom command : read (default) built-in/custom command
$ shell shell command $ shell shell command
% shell-pipe shell command running with the UI % shell-pipe shell command running with the UI
! shell-wait shell command waiting for a key press ! shell-wait shell command waiting for a key press
@@ -1277,12 +1331,12 @@ Command `set` is used to set an option which can be a boolean, integer, or strin
set hidden false # boolean disable set hidden false # boolean disable
set hidden! # boolean toggle set hidden! # boolean toggle
set scrolloff 10 # integer value set scrolloff 10 # integer value
set sortby time # string value w/o quotes set sortby time # string value without quotes
set sortby 'time' # string value with single quotes (whitespaces) set sortby 'time' # string value with single quotes (whitespace)
set sortby "time" # string value with double quotes (backslash escapes) set sortby "time" # string value with double quotes (backslash escapes)
Command `setlocal` is used to set a local option for a directory which can be a boolean or string. Command `setlocal` is used to set a local option for a directory which can be a boolean or string.
Currently supported local options are `dircounts`, `dirfirst`, `dironly`, `hidden`, `info`, `locale`, `reverse` and `sortby`. Currently supported local options are `dircounts`, `dirfirst`, `dironly`, `hidden`, `info`, `reverse` and `sortby`.
Adding a trailing path separator (i.e. `/` for Unix and `\` for Windows) sets the option for the given directory along with its subdirectories: Adding a trailing path separator (i.e. `/` for Unix and `\` for Windows) sets the option for the given directory along with its subdirectories:
setlocal /foo/bar hidden # boolean enable setlocal /foo/bar hidden # boolean enable
@@ -1290,15 +1344,15 @@ Adding a trailing path separator (i.e. `/` for Unix and `\` for Windows) sets th
setlocal /foo/bar nohidden # boolean disable setlocal /foo/bar nohidden # boolean disable
setlocal /foo/bar hidden false # boolean disable setlocal /foo/bar hidden false # boolean disable
setlocal /foo/bar hidden! # boolean toggle setlocal /foo/bar hidden! # boolean toggle
setlocal /foo/bar sortby time # string value w/o quotes setlocal /foo/bar sortby time # string value without quotes
setlocal /foo/bar sortby 'time' # string value with single quotes (whitespaces) setlocal /foo/bar sortby 'time' # string value with single quotes (whitespace)
setlocal /foo/bar sortby "time" # string value with double quotes (backslash escapes) setlocal /foo/bar sortby "time" # string value with double quotes (backslash escapes)
setlocal /foo/bar hidden # for only '/foo/bar' directory setlocal /foo/bar hidden # for only '/foo/bar' directory
setlocal /foo/bar/ hidden # for '/foo/bar' and its subdirectories (e.g. '/foo/bar/baz') setlocal /foo/bar/ hidden # for '/foo/bar' and its subdirectories (e.g. '/foo/bar/baz')
Command `map` is used to bind a key in Normal and Visual mode to a command which can be a builtin command, custom command, or shell command: Command `map` is used to bind a key in Normal and Visual mode to a command which can be a built-in command, custom command, or shell command:
map gh cd ~ # builtin command map gh cd ~ # built-in command
map D trash # custom command map D trash # custom command
map i $less $f # shell command map i $less $f # shell command
map U !du -csh * # waiting shell command map U !du -csh * # waiting shell command
@@ -1355,7 +1409,7 @@ Regular keys are assigned to a command with the usual syntax:
map a down map a down
Keys combined with the shift key simply use the uppercase letter: Keys combined with the Shift key simply use the uppercase letter:
map A down map A down
@@ -1372,19 +1426,19 @@ Function keys are prefixed with `f` character:
map <f-1> down map <f-1> down
Keys combined with the control key are prefixed with a `c` character: Keys combined with the Ctrl key are prefixed with a `c` character:
map <c-a> down map <c-a> down
Keys combined with the alt key are assigned in two different ways depending on the behavior of your terminal. Keys combined with the Alt key are assigned in two different ways depending on the behavior of your terminal.
Older terminals (e.g. xterm) may set the 8th bit of a character when the alt key is pressed. Older terminals (e.g. xterm) may set the 8th bit of a character when the Alt key is pressed.
On these terminals, you can use the corresponding byte for the mapping: On these terminals, you can use the corresponding byte for the mapping:
map á down map á down
Newer terminals (e.g. gnome-terminal) may prefix the key with an escape key when the alt key is pressed. Newer terminals (e.g. gnome-terminal) may prefix the key with an escape character when the Alt key is pressed.
lf uses the escape delaying mechanism to recognize alt keys in these terminals (delay is 100ms). lf uses the escape delaying mechanism to recognize Alt keys in these terminals (delay is 100ms).
On these terminals, keys combined with the alt key are prefixed with an `a` character: On these terminals, keys combined with the Alt key are prefixed with an `a` character:
map <a-a> down map <a-a> down
@@ -1484,18 +1538,18 @@ However, use of this option is highly recommended and it is assumed in the rest
# PIPING SHELL COMMANDS # PIPING SHELL COMMANDS
Regular shell commands have some limitations in some cases. Regular shell commands have some limitations in some cases.
When an output or error message is given and the command exits afterwards, the ui is immediately resumed and there is no way to see the message without dropping to shell again. When an output or error message is given and the command exits afterwards, the UI is immediately resumed and there is no way to see the message without dropping to shell again.
Also, even when there is no output or error, the UI still needs to be paused while the command is running. Also, even when there is no output or error, the UI still needs to be paused while the command is running.
This can cause flickering on the screen for short commands and similar distractions for longer commands. This can cause flickering on the screen for short commands and similar distractions for longer commands.
Instead of pausing the UI, piping shell commands connect stdin, stdout, and stderr of the command to the statline at the bottom of the UI. Instead of pausing the UI, piping shell commands connect stdin, stdout, and stderr of the command to the statline at the bottom of the UI.
This can be useful for programs following the Unix philosophy to give no output in the success case, and brief error messages or prompts in other cases. This can be useful for programs following the Unix philosophy to give no output in the success case, and brief error messages or prompts in other cases.
For example, following rename command prompts for overwrite in the statline if there is an existing file with the given name: For example, the following rename command prompts for overwrite in the statline if there is an existing file with the given name:
cmd rename %mv -i $f $1 cmd rename %mv -i $f $1
You can also output error messages in the command and it will show up in the statline. You can also output error messages in the command and they will show up in the statline.
For example, an alternative rename command may look like this: For example, an alternative rename command may look like this:
cmd rename %[ -e $1 ] && printf "file exists" || mv $f $1 cmd rename %[ -e $1 ] && printf "file exists" || mv $f $1
@@ -1537,7 +1591,7 @@ You can optionally give it an ID number to send a command to a single client:
lf -remote 'send 1234 echo hello world' lf -remote 'send 1234 echo hello world'
All clients have a unique id number but you may not be aware of the id number when you are writing a command. All clients have a unique ID number but you may not be aware of the ID number when you are writing a command.
For this purpose, an `$id` variable is exported to the environment for shell commands. For this purpose, an `$id` variable is exported to the environment for shell commands.
The value of this variable is set to the process ID of the client. The value of this variable is set to the process ID of the client.
You can use it to send a remote command from a client to the server which in return sends a command back to itself. You can use it to send a remote command from a client to the server which in return sends a command back to itself.
@@ -1558,7 +1612,7 @@ For example, you can configure the number of columns in the UI with respect to t
fi fi
}} }}
In addition, the `query` command can be used to obtain information about a specific lf instance by providing its id: In addition, the `query` command can be used to obtain information about a specific lf instance by providing its ID:
lf -remote "query $id maps" lf -remote "query $id maps"
@@ -1611,7 +1665,7 @@ Only file modes and (some) timestamps can be preserved (see `preserve` option),
Special files such as character and block devices, named pipes, and sockets are skipped and links are not followed. Special files such as character and block devices, named pipes, and sockets are skipped and links are not followed.
Moving is performed using the rename operation of the underlying OS. Moving is performed using the rename operation of the underlying OS.
For cross-device moving, lf falls back to copying and then deletes the original files if there are no errors. For cross-device moving, lf falls back to copying and then deletes the original files if there are no errors.
Operation errors are shown in the message line as well as the log file and they do not preemptively finish the corresponding file operation. Operation errors are shown in the message line as well as the log file and they do not prematurely terminate the corresponding file operation.
File operations can be performed on the currently selected file or on multiple files by selecting them first. File operations can be performed on the currently selected file or on multiple files by selecting them first.
When you `copy` a file, lf doesn't actually copy the file on the disk, but only records its name to a file. When you `copy` a file, lf doesn't actually copy the file on the disk, but only records its name to a file.
@@ -1666,10 +1720,10 @@ You can set the number of keys to match using `findlen` option.
If you set this value to zero, then the keys are read until there is only a single match. If you set this value to zero, then the keys are read until there is only a single match.
The default values of these two options are set to jump to the first file with the given initial. The default values of these two options are set to jump to the first file with the given initial.
Some options effect both searching and finding. Some options affect both searching and finding.
You can disable `wrapscan` option to prevent searches from being wrapped around at the end of the file list. You can disable `wrapscan` option to prevent searches from being wrapped around at the end of the file list.
You can disable `ignorecase` option to match cases in the pattern and the filename. You can disable `ignorecase` option to match cases in the pattern and the filename.
This option is already automatically overridden if the pattern contains upper-case characters. This option is already automatically overridden if the pattern contains uppercase characters.
You can disable `smartcase` option to disable this behavior. You can disable `smartcase` option to disable this behavior.
Two similar options `ignoredia` and `smartdia` are provided to control matching diacritics in Latin letters. Two similar options `ignoredia` and `smartdia` are provided to control matching diacritics in Latin letters.
@@ -1685,7 +1739,7 @@ It is possible to use different command types:
cmd open &xdg-open $f cmd open &xdg-open $f
You may want to use either file extensions or mime types from `file` command: You may want to use either file extensions or MIME types from `file` command:
cmd open ${{ cmd open ${{
case $(file --mime-type -Lb $f) in case $(file --mime-type -Lb $f) in
@@ -1719,11 +1773,11 @@ Possible options are `libfile-mimeinfo-perl` (executable name is `mimeopen`), `r
lf previews files on the preview pane by printing the file until the end or until the preview pane is filled. lf previews files on the preview pane by printing the file until the end or until the preview pane is filled.
This output can be enhanced by providing a custom preview script for filtering. This output can be enhanced by providing a custom preview script for filtering.
This can be used to highlight source codes, list contents of archive files or view PDF or image files to name a few. This can be used to highlight source code, list contents of archive files or view PDF or image files to name a few.
For coloring lf recognizes ANSI escape codes. For coloring lf recognizes ANSI escape codes.
To use this feature, you need to set the value of `previewer` option to the path of an executable file. To use this feature, you need to set the value of `previewer` option to the path of an executable file.
Five arguments are passed to the file, (1) current file name, (2) width, (3) height, (4) horizontal position, and (5) vertical position of preview pane respectively. Five arguments are passed to the file, (1) current filename, (2) width, (3) height, (4) horizontal position, and (5) vertical position of preview pane respectively.
The output of the execution is printed in the preview pane. The output of the execution is printed in the preview pane.
You may also want to use the same script in your pager mapping as well: You may also want to use the same script in your pager mapping as well:
@@ -1736,7 +1790,7 @@ For `less` pager, you may instead utilize `LESSOPEN` mechanism so that useful in
map i $LESSOPEN='| ~/.config/lf/pv.sh %s' less -R $f map i $LESSOPEN='| ~/.config/lf/pv.sh %s' less -R $f
Since this script is called for each file selection change it needs to be as efficient as possible and this responsibility is left to the user. Since this script is called for each file selection change it needs to be as efficient as possible and this responsibility is left to the user.
You may use file extensions to determine the type of file more efficiently compared to obtaining mime types from `file` command. You may use file extensions to determine the type of file more efficiently compared to obtaining MIME types from `file` command.
Extensions can then be used to match cleanly within a conditional: Extensions can then be used to match cleanly within a conditional:
#!/bin/sh #!/bin/sh
@@ -1870,7 +1924,7 @@ It starts with a default color scheme and updates colors using values of existin
Colors are set in the following order: Colors are set in the following order:
1. default 1. default
2. LSCOLORS (Mac/BSD ls) 2. LSCOLORS (macOS/BSD ls)
3. LS_COLORS (GNU ls) 3. LS_COLORS (GNU ls)
4. LF_COLORS (lf specific) 4. LF_COLORS (lf specific)
5. colors file (lf specific) 5. colors file (lf specific)
@@ -1979,7 +2033,7 @@ You may instead divide it into multiple lines in between double quotes by escapi
ex=01;32:\ ex=01;32:\
" "
The `ln` entry supports the special value `target`, which will use the link target to select a style. File name rules will still apply based on the link's name -- this mirrors GNU's `ls` and `dircolors` behavior. The `ln` entry supports the special value `target`, which will use the link target to select a style. Filename rules will still apply based on the link's name -- this mirrors GNU's `ls` and `dircolors` behavior.
Having such a long variable definition in a shell configuration file might be undesirable. Having such a long variable definition in a shell configuration file might be undesirable.
You may instead use the colors file (refer to the [CONFIGURATION section](https://github.com/gokcehan/lf/blob/master/doc.md#configuration)) for configuration. You may instead use the colors file (refer to the [CONFIGURATION section](https://github.com/gokcehan/lf/blob/master/doc.md#configuration)) for configuration.
A sample colors file can be found at A sample colors file can be found at
@@ -1991,12 +2045,12 @@ https://en.wikipedia.org/wiki/ANSI_escape_code
Icons are configured using `LF_ICONS` environment variable or an icons file (refer to the [CONFIGURATION section](https://github.com/gokcehan/lf/blob/master/doc.md#configuration)). Icons are configured using `LF_ICONS` environment variable or an icons file (refer to the [CONFIGURATION section](https://github.com/gokcehan/lf/blob/master/doc.md#configuration)).
The variable uses the same syntax as `LS_COLORS/LF_COLORS`. The variable uses the same syntax as `LS_COLORS/LF_COLORS`.
Instead of colors, you should put a single characters as values of entries. Instead of colors, you should use single characters or symbols as values.
The `ln` entry supports the special value `target`, which will use the link target to select a icon. File name rules will still apply based on the link's name -- this mirrors GNU's `ls` and `dircolors` behavior. The `ln` entry supports the special value `target`, which will use the link target to select a icon. Filename rules will still apply based on the link's name -- this mirrors GNU's `ls` and `dircolors` behavior.
The icons file (refer to the [CONFIGURATION section](https://github.com/gokcehan/lf/blob/master/doc.md#configuration)) should consist of whitespace-separated arrays with a `#` character to start comments until the end of the line. The icons file (refer to the [CONFIGURATION section](https://github.com/gokcehan/lf/blob/master/doc.md#configuration)) should consist of whitespace-separated arrays with a `#` character to start comments until the end of the line.
Each line should contain 1-3 columns, first column is filetype or filename pattern, second column is the icon, third column is an optional icon color. If there is only one column, means to disable rule for this filetype or pattern. Each line should contain 1-3 columns: a file type or file name pattern, the icon, and an optional icon color. Using only one column disables all rules for that type or name.
Do not forget to add `set icons true` to your `lfrc` to see the icons. Do not forget to add `set icons true` to your `lfrc` to see the icons.
Default values are as follows given with their matching order in lf: Default values are listed below in the order lf matches them:
ln l ln l
or l or l
+167 -131
View File
@@ -18,7 +18,7 @@ https://github.com/gokcehan/lf
This documentation can either be read from the terminal using lf -doc or This documentation can either be read from the terminal using lf -doc or
online at https://github.com/gokcehan/lf/blob/master/doc.md You can also online at https://github.com/gokcehan/lf/blob/master/doc.md You can also
use the doc command (default <f-1>) inside lf to view the documentation use the help command (default <f-1>) inside lf to view the documentation
in a pager. A man page with the same content is also available in the in a pager. A man page with the same content is also available in the
repository at https://github.com/gokcehan/lf/blob/master/lf.1 repository at https://github.com/gokcehan/lf/blob/master/lf.1
@@ -145,7 +145,6 @@ The following options can be used to customize the behavior of lf:
cursorparentfmt string (default "\033[7m") cursorparentfmt string (default "\033[7m")
cursorpreviewfmt string (default "\033[4m") cursorpreviewfmt string (default "\033[4m")
cutfmt string (default "\033[7;31m") cutfmt string (default "\033[7;31m")
dircache bool (default true)
dircounts bool (default false) dircounts bool (default false)
dirfirst bool (default true) dirfirst bool (default true)
dironly bool (default false) dironly bool (default false)
@@ -168,7 +167,9 @@ The following options can be used to customize the behavior of lf:
info []string (default '') info []string (default '')
infotimefmtnew string (default 'Jan _2 15:04') infotimefmtnew string (default 'Jan _2 15:04')
infotimefmtold string (default 'Jan _2 2006') infotimefmtold string (default 'Jan _2 2006')
locale string (default '') menufmt string (default "\033[0m")
menuheaderfmt string (default "\033[1m")
menuselectfmt string (default "\033[7m")
mouse bool (default false) mouse bool (default false)
number bool (default false) number bool (default false)
numberfmt string (default "\033[33m") numberfmt string (default "\033[33m")
@@ -190,7 +191,7 @@ The following options can be used to customize the behavior of lf:
shellflag string (default '-c' for Unix and '/c' for Windows) shellflag string (default '-c' for Unix and '/c' for Windows)
shellopts []string (default '') shellopts []string (default '')
showbinds bool (default true) showbinds bool (default true)
sixel bool (default false) sizeunits string (default 'binary')
smartcase bool (default true) smartcase bool (default true)
smartdia bool (default false) smartdia bool (default false)
sortby string (default 'natural') sortby string (default 'natural')
@@ -256,8 +257,8 @@ The following commands/keybindings are provided by default:
map e $$EDITOR "$f" map e $$EDITOR "$f"
map i $$PAGER "$f" map i $$PAGER "$f"
map w $$SHELL map w $$SHELL
cmd doc $$lf -doc | $PAGER cmd help $$lf -doc | $PAGER
map <f-1> doc map <f-1> help
cmd maps $lf -remote "query $id maps" | $PAGER cmd maps $lf -remote "query $id maps" | $PAGER
cmd nmaps $lf -remote "query $id nmaps" | $PAGER cmd nmaps $lf -remote "query $id nmaps" | $PAGER
cmd vmaps $lf -remote "query $id vmaps" | $PAGER cmd vmaps $lf -remote "query $id vmaps" | $PAGER
@@ -269,14 +270,18 @@ The following commands/keybindings are provided by default:
map e $%EDITOR% %f% map e $%EDITOR% %f%
map i !%PAGER% %f% map i !%PAGER% %f%
map w $%SHELL% map w $%SHELL%
cmd doc !%lf% -doc | %PAGER% cmd help !%lf% -doc | %PAGER%
map <f-1> doc map <f-1> help
cmd maps !%lf% -remote "query %id% maps" | %PAGER% cmd maps !%lf% -remote "query %id% maps" | %PAGER%
cmd nmaps !%lf% -remote "query %id% nmaps" | %PAGER% cmd nmaps !%lf% -remote "query %id% nmaps" | %PAGER%
cmd vmaps !%lf% -remote "query %id% vmaps" | %PAGER% cmd vmaps !%lf% -remote "query %id% vmaps" | %PAGER%
cmd cmaps !%lf% -remote "query %id% cmaps" | %PAGER% cmd cmaps !%lf% -remote "query %id% cmaps" | %PAGER%
cmd cmds !%lf% -remote "query %id% cmds" | %PAGER% cmd cmds !%lf% -remote "query %id% cmds" | %PAGER%
The defaults for Windows are using cmd syntax. A PowerShell compatible
configuration file can be found at
https://github.com/gokcehan/lf/blob/master/etc/lfrc.ps1.example
The following additional keybindings are provided by default: The following additional keybindings are provided by default:
map zh set hidden! map zh set hidden!
@@ -302,7 +307,7 @@ effects:
Click on a file or directory to select it. Click on a file or directory to select it.
Right mouse button Right mouse button
Enter a directory or open a file. Also works on the preview window. Enter a directory or open a file. Also works on the preview pane.
Scroll wheel Scroll wheel
Move up or down. If Ctrl is pressed, scroll up or down. Move up or down. If Ctrl is pressed, scroll up or down.
@@ -361,9 +366,11 @@ with their order of precedences and their default values:
Windows Windows
%LF_CONFIG_HOME% %LF_CONFIG_HOME%
%XDG_CONFIG_HOME%
%APPDATA% %APPDATA%
%LF_DATA_HOME% %LF_DATA_HOME%
%XDG_DATA_HOME%
%LOCALAPPDATA% %LOCALAPPDATA%
A sample configuration file can be found at A sample configuration file can be found at
@@ -500,7 +507,7 @@ statline.
shell-wait (modal) (default !) shell-wait (modal) (default !)
Read a shell command to execute and wait for a key press in the end. Read a shell command to execute and wait for a key press at the end.
shell-async (modal) (default &) shell-async (modal) (default &)
@@ -508,12 +515,12 @@ Read a shell command to execute asynchronously without standard I/O.
find (modal) (default f), find-back (modal) (default F), find-next (default ;), find-prev (default ,) find (modal) (default f), find-back (modal) (default F), find-next (default ;), find-prev (default ,)
Read key(s) to find the appropriate file name match in the Read key(s) to find the appropriate filename match in the
forward/backward direction and jump to the next/previous match. forward/backward direction and jump to the next/previous match.
search (default /), search-back (default ?), search-next (default n), search-prev (default N) search (default /), search-back (default ?), search-next (default n), search-prev (default N)
Read a pattern to search for a file name match in the forward/backward Read a pattern to search for a filename match in the forward/backward
direction and jump to the next/previous match. direction and jump to the next/previous match.
filter (modal), setfilter filter (modal), setfilter
@@ -545,7 +552,7 @@ can define a new tag-clearing command by combining tag with tag-toggle
tag-toggle (default t) tag-toggle (default t)
Tag a file with * or a single width character given in the argument if Tag a file with * or a single-width character given in the argument if
the file is untagged, otherwise remove the tag. the file is untagged, otherwise remove the tag.
echo echo
@@ -644,7 +651,7 @@ with cmd-delete-back (<backspace> by default).
The command line commands should be mostly compatible with readline The command line commands should be mostly compatible with readline
keybindings. A character refers to a Unicode code point, a word consists keybindings. A character refers to a Unicode code point, a word consists
of letters and digits, and a unix word consists of any non-blank of letters and digits, and a Unix word consists of any non-blank
characters. characters.
cmd-insert cmd-insert
@@ -708,7 +715,7 @@ Delete everything up to the beginning/end of the line.
cmd-delete-unix-word (default <c-w>) cmd-delete-unix-word (default <c-w>)
Delete the previous unix word. Delete the previous Unix word.
cmd-yank (default <c-y>) cmd-yank (default <c-y>)
@@ -744,8 +751,8 @@ Character : is used as the separator for list options []int and
anchorfind (bool) (default true) anchorfind (bool) (default true)
When this option is enabled, the find command starts matching patterns When this option is enabled, the find command starts matching patterns
from the beginning of file names, otherwise, it can match at an from the beginning of filenames, otherwise, it can match at an arbitrary
arbitrary position. position.
autoquit (bool) (default true) autoquit (bool) (default true)
@@ -761,16 +768,16 @@ cleaner (string) (default ``) (not called if empty)
Set the path of a cleaner file. The file should be executable. This file Set the path of a cleaner file. The file should be executable. This file
is called if previewing is enabled, the previewer is set, and the is called if previewing is enabled, the previewer is set, and the
previously selected file has its preview cache disabled. The following previously selected file has its preview cache disabled. The following
arguments are passed to the file, (1) current file name, (2) width, (3) arguments are passed to the file, (1) current filename, (2) width, (3)
height, (4) horizontal position, (5) vertical position of preview pane height, (4) horizontal position, (5) vertical position of preview pane
and (6) next file name to be previewed respectively. Preview cleaning is and (6) next filename to be previewed respectively. Preview cleaning is
disabled when the value of this option is left empty. disabled when the value of this option is left empty.
copyfmt (string) (default \033[7;33m) copyfmt (string) (default \033[7;33m)
Format string of the indicator for files to be copied. Format string of the indicator for files to be copied.
cursoractivefmt (string) (default \033[7m), cursorparentfmt string (default \033[7m), cursorpreviewfmt string (default \033[4m) cursoractivefmt (string) (default \033[7m), cursorparentfmt (string) (default \033[7m), cursorpreviewfmt (string) (default \033[4m)
Format strings for highlighting the cursor. cursoractivefmt applies in Format strings for highlighting the cursor. cursoractivefmt applies in
the current directory pane, cursorparentfmt applies in panes that show the current directory pane, cursorparentfmt applies in panes that show
@@ -794,10 +801,6 @@ cutfmt (string) (default \033[7;31m)
Format string of the indicator for files to be cut. Format string of the indicator for files to be cut.
dircache (bool) (default true)
Cache directory contents.
dircounts (bool) (default false) dircounts (bool) (default false)
When this option is enabled, directory sizes show the number of items When this option is enabled, directory sizes show the number of items
@@ -830,10 +833,10 @@ Draw boxes around panes with box drawing characters.
dupfilefmt (string) (default %f.~%n~) dupfilefmt (string) (default %f.~%n~)
Format string of file name when creating duplicate files. With the Format string of filename when creating duplicate files. With the
default format, copying a file abc.txt to the same directory will result default format, copying a file abc.txt to the same directory will result
in a duplicate file called abc.txt.~1~. Special expansions are provided, in a duplicate file called abc.txt.~1~. Special expansions are provided,
%f as the file name, %b for the basename (file name without extension), %f as the file name, %b for the base name (file name without extension),
%e as the extension (including the dot) and %n as the number of %e as the extension (including the dot) and %n as the number of
duplicates. duplicates.
@@ -853,7 +856,7 @@ File separator used in environment variables fs, fv and fx.
filtermethod (string) (default text) filtermethod (string) (default text)
How filter command patterns are treated. Currently supported methods are How filter command patterns are treated. Currently supported methods are
text (i.e. string literals), glob (i.e shell globs) and regex (i.e. text (i.e. string literals), glob (i.e. shell globs) and regex (i.e.
regular expressions). See SEARCHING FILES for more details. regular expressions). See SEARCHING FILES for more details.
findlen (int) (default 1) findlen (int) (default 1)
@@ -912,9 +915,20 @@ Jump to the first match after each keystroke during searching.
info ([]string) (default ``) info ([]string) (default ``)
A list of information that is shown for directory items at the right A list of information that is shown for directory items at the right
side of the pane. Currently supported information types are size, time, side of the pane.
atime, btime, ctime, perm, user, group and custom. The custom type is
empty by default and can be updated using the addcustominfo command. The following information types are supported:
perm file permission
user user name
group group name
size file size
time time of last data modification
atime time of last access
btime time of file birth
ctime time of last status (inode) change
custom property defined via `addcustominfo` (empty by default)
Information is only shown when the pane width is more than twice the Information is only shown when the pane width is more than twice the
width of information. width of information.
@@ -928,13 +942,17 @@ infotimefmtold (string) (default Jan _2 2006)
Format string of the file time shown in the info column when it doesn't Format string of the file time shown in the info column when it doesn't
match this year. match this year.
locale (string) (default ``) menufmt (string) (default \033[0m)
An IETF BCP 47 language tag (e.g. zh-CN) for specifying the locale used Format string of the menu.
when using sort type natural and name. An empty string means disable
locale ordering, and the special value * is used to indicate reading the menuheaderfmt (string) (default \033[1m)
locale setting from the system environment. This feature is currently
experimental. Format string of the header row in the menu.
menuselectfmt (string) (default \033[7m)
Format string of the currently selected item in the menu.
mouse (bool) (default false) mouse (bool) (default false)
@@ -979,8 +997,8 @@ previewer (string) (default ``) (not filtered if empty)
Set the path of a previewer file to filter the content of regular files Set the path of a previewer file to filter the content of regular files
for previewing. The file should be executable. The following arguments for previewing. The file should be executable. The following arguments
are passed to the file, (1) current file name, (2) width, (3) height, are passed to the file, (1) current filename, (2) width, (3) height, (4)
(4) horizontal position, and (5) vertical position of preview pane horizontal position, and (5) vertical position of preview pane
respectively. SIGPIPE signal is sent when enough lines are read. If the respectively. SIGPIPE signal is sent when enough lines are read. If the
previewer returns a non-zero exit code, then the preview cache for the previewer returns a non-zero exit code, then the preview cache for the
given file is disabled. This means that if the file is selected in the given file is disabled. This means that if the file is selected in the
@@ -990,15 +1008,22 @@ option is left empty.
promptfmt (string) (default \033[32;1m%u@%h\033[0m:\033[34;1m%d\033[0m\033[1m%f\033[0m) promptfmt (string) (default \033[32;1m%u@%h\033[0m:\033[34;1m%d\033[0m\033[1m%f\033[0m)
Format string of the prompt shown in the top line. Special expansions Format string of the prompt shown in the top line.
are provided, %u as the user name, %h as the hostname, %w as the working
directory, %d as the working directory with a trailing path separator, The following special expansions are supported:
%f as the file name, and %F as the current filter. %S may be used once
and will provide a spacer so that the following parts are right aligned %f file name
on the screen. The home folder is shown as ~ in the working directory %h host name
expansion. Directory names are automatically shortened to a single %u user name
character starting from the leftmost parent when the prompt does not fit %w working directory
the screen. %d working directory (with trailing path separator)
%F current filter
%S spacer to right-align the following parts (can be used once)
The home folder is shown as ~ in the working directory expansion.
Directory names are automatically shortened to a single character
starting from the leftmost parent when the prompt does not fit the
screen.
ratios ([]int) (default 1:2:3) ratios ([]int) (default 1:2:3)
@@ -1022,18 +1047,27 @@ Draw rounded outer corners when the drawbox option is enabled.
rulerfmt (string) (default %a| %p| \033[7;31m %m \033[0m| \033[7;33m %c \033[0m| \033[7;35m %s \033[0m| \033[7;36m %v \033[0m| \033[7;34m %f \033[0m| %i/%t) rulerfmt (string) (default %a| %p| \033[7;31m %m \033[0m| \033[7;33m %c \033[0m| \033[7;35m %s \033[0m| \033[7;36m %v \033[0m| \033[7;34m %f \033[0m| %i/%t)
Format string of the ruler shown in the bottom right corner. Special Format string of the ruler shown in the bottom right corner.
expansions are provided, %a as the pressed keys, %p as the progress of
file operations, %m as the number of files to be cut (moved), %c as the The following special expansions are supported:
number of files to be copied, %s as the number of selected files, %v as
the number of visually selected files, %f as the filter, %i as the %a pressed keys
position of the cursor, %t as the number of files shown in the current %p progress of file operations
directory, %h as the number of files hidden in the current directory, %P %m number of files to be cut (moved)
as the scroll percentage, and %d as the amount of free disk space %c number of files to be copied
remaining. Additional expansions are provided for environment variables %s number of selected files
exported by lf, in the form %{lf_<name>} (e.g. %{lf_selmode}). This is %v number of visually selected files
useful for displaying the current settings. Expansions are also provided %t number of shown files in the current directory
for user-defined options, in the form %{lf_user_<name>} (e.g. %h number of hidden files in the current directory
%f current filter
%i cursor position
%P scroll percentage
%d amount of free disk space
Additional expansions are provided for environment variables exported by
lf, in the form %{lf_<name>} (e.g. %{lf_selmode}). This is useful for
displaying the current settings. Expansions are also provided for
user-defined options, in the form %{lf_user_<name>} (e.g.
%{lf_user_foo}). The | character splits the format string into sections. %{lf_user_foo}). The | character splits the format string into sections.
Any section containing a failed expansion (result is a blank string) is Any section containing a failed expansion (result is a blank string) is
discarded and not shown. discarded and not shown.
@@ -1042,15 +1076,15 @@ scrolloff (int) (default 0)
Minimum number of offset lines shown at all times at the top and bottom Minimum number of offset lines shown at all times at the top and bottom
of the screen when scrolling. The current line is kept in the middle of the screen when scrolling. The current line is kept in the middle
when this option is set to a large value that is bigger than the half of when this option is set to a large value that is bigger than half the
number of lines. A smaller offset can be used when the current file is number of lines. A smaller offset can be used when the current file is
close to the beginning or end of the list to show the maximum number of close to the beginning or end of the list to show the maximum number of
items. items.
searchmethod (string) default text) searchmethod (string) (default text)
How search command patterns are treated. Currently supported methods are How search command patterns are treated. Currently supported methods are
text (i.e. string literals), glob (i.e shell globs) and regex (i.e. text (i.e. string literals), glob (i.e. shell globs) and regex (i.e.
regular expressions). See SEARCHING FILES for more details. regular expressions). See SEARCHING FILES for more details.
selectfmt (string) (default \033[7;35m) selectfmt (string) (default \033[7;35m)
@@ -1080,9 +1114,10 @@ showbinds (bool) (default true)
Show bindings associated with pressed keys. Show bindings associated with pressed keys.
sixel (bool) (default false) sizeunits (string) (default binary)
Render sixel images in preview. Determines whether file sizes are displayed using binary units (1K is
1024 bytes) or decimal units (1K is 1000 bytes).
smartcase (bool) (default true) smartcase (bool) (default true)
@@ -1096,38 +1131,41 @@ diacritic. This option has no effect when ignoredia is disabled.
sortby (string) (default natural) sortby (string) (default natural)
Sort type for directories. Currently supported sort types are natural, Sort type for directories.
name, size, time, atime, btime, ctime, ext and custom.
Meaning of each sort type: The following sort types are supported:
natural file name (track_2.flac comes before track_10.flac) natural file name (track_2.flac comes before track_10.flac)
name file name (track_10.flac comes before track_2.flac) name file name (track_10.flac comes before track_2.flac)
ext file extension
size file size size file size
time time of last data modification time time of last data modification
atime time of last access atime time of last access
btime time of file birth btime time of file birth
ctime time of last status (inode) change ctime time of last status (inode) change
ext file extension custom property defined via `addcustominfo` (empty by default)
custom property defined via `addcustominfo`
statfmt (string) (default \033[36m%p\033[0m| %c| %u| %g| %S| %t| -> %l) statfmt (string) (default \033[36m%p\033[0m| %c| %u| %g| %S| %t| -> %l)
Format string of the file info shown in the bottom left corner. Special Format string of the file info shown in the bottom left corner.
expansions are provided, %p as the file permissions, %c as the link
count, %u as the user, %g as the group, %s as the file size, %S as the The following special expansions are supported:
file size but with a fixed width of five characters (left-padded with
spaces), %t as the last modified time, %l as the link target, %m as the %p file permission
current mode and %M as the current mode but also shown in Normal mode %c link count
(displaying NORMAL instead of a blank string). %u user name
%g group name
%s file size
%S file size (left-padded with spaces to a fixed width of 5 characters)
%t time of last data modification
%l link target
%m current mode
%M current mode (displaying `NORMAL` instead of a blank string in Normal mode)
The | character splits the format string into sections. Any section The | character splits the format string into sections. Any section
containing a failed expansion (result is a blank string) is discarded containing a failed expansion (result is a blank string) is discarded
and not shown. and not shown.
File size is formatted using first letter of IEC 80000-13:2025 prefixes
for binary multiples (i.e. 1024 bytes is 1.0K).
tabstop (int) (default 8) tabstop (int) (default 8)
Number of space characters to show for horizontal tabulation (U+0009) Number of space characters to show for horizontal tabulation (U+0009)
@@ -1155,7 +1193,7 @@ Format string of the file modification time shown in the bottom line.
truncatechar (string) (default ~) truncatechar (string) (default ~)
The truncate character that is shown at the end when the file name does The truncate character that is shown at the end when the filename does
not fit into the pane. not fit into the pane.
truncatepct (int) (default 100) truncatepct (int) (default 100)
@@ -1254,7 +1292,7 @@ configuration file (e.g. ~/.bashrc).
OPENER OPENER
If this variable is set in the environment, use the same value. If this variable is set in the environment, use the same value.
Otherwise, this is set to start in Windows, open in MacOS, xdg-open in Otherwise, this is set to start in Windows, open in macOS, xdg-open in
others. others.
EDITOR EDITOR
@@ -1376,7 +1414,7 @@ PREFIXES
The following command prefixes are used by lf: The following command prefixes are used by lf:
: read (default) builtin/custom command : read (default) built-in/custom command
$ shell shell command $ shell shell command
% shell-pipe shell command running with the UI % shell-pipe shell command running with the UI
! shell-wait shell command waiting for a key press ! shell-wait shell command waiting for a key press
@@ -1407,31 +1445,31 @@ string:
set hidden false # boolean disable set hidden false # boolean disable
set hidden! # boolean toggle set hidden! # boolean toggle
set scrolloff 10 # integer value set scrolloff 10 # integer value
set sortby time # string value w/o quotes set sortby time # string value without quotes
set sortby 'time' # string value with single quotes (whitespaces) set sortby 'time' # string value with single quotes (whitespace)
set sortby "time" # string value with double quotes (backslash escapes) set sortby "time" # string value with double quotes (backslash escapes)
Command setlocal is used to set a local option for a directory which can Command setlocal is used to set a local option for a directory which can
be a boolean or string. Currently supported local options are dircounts, be a boolean or string. Currently supported local options are dircounts,
dirfirst, dironly, hidden, info, locale, reverse and sortby. Adding a dirfirst, dironly, hidden, info, reverse and sortby. Adding a trailing
trailing path separator (i.e. / for Unix and \ for Windows) sets the path separator (i.e. / for Unix and \ for Windows) sets the option for
option for the given directory along with its subdirectories: the given directory along with its subdirectories:
setlocal /foo/bar hidden # boolean enable setlocal /foo/bar hidden # boolean enable
setlocal /foo/bar hidden true # boolean enable setlocal /foo/bar hidden true # boolean enable
setlocal /foo/bar nohidden # boolean disable setlocal /foo/bar nohidden # boolean disable
setlocal /foo/bar hidden false # boolean disable setlocal /foo/bar hidden false # boolean disable
setlocal /foo/bar hidden! # boolean toggle setlocal /foo/bar hidden! # boolean toggle
setlocal /foo/bar sortby time # string value w/o quotes setlocal /foo/bar sortby time # string value without quotes
setlocal /foo/bar sortby 'time' # string value with single quotes (whitespaces) setlocal /foo/bar sortby 'time' # string value with single quotes (whitespace)
setlocal /foo/bar sortby "time" # string value with double quotes (backslash escapes) setlocal /foo/bar sortby "time" # string value with double quotes (backslash escapes)
setlocal /foo/bar hidden # for only '/foo/bar' directory setlocal /foo/bar hidden # for only '/foo/bar' directory
setlocal /foo/bar/ hidden # for '/foo/bar' and its subdirectories (e.g. '/foo/bar/baz') setlocal /foo/bar/ hidden # for '/foo/bar' and its subdirectories (e.g. '/foo/bar/baz')
Command map is used to bind a key in Normal and Visual mode to a command Command map is used to bind a key in Normal and Visual mode to a command
which can be a builtin command, custom command, or shell command: which can be a built-in command, custom command, or shell command:
map gh cd ~ # builtin command map gh cd ~ # built-in command
map D trash # custom command map D trash # custom command
map i $less $f # shell command map i $less $f # shell command
map U !du -csh * # waiting shell command map U !du -csh * # waiting shell command
@@ -1491,7 +1529,7 @@ Regular keys are assigned to a command with the usual syntax:
map a down map a down
Keys combined with the shift key simply use the uppercase letter: Keys combined with the Shift key simply use the uppercase letter:
map A down map A down
@@ -1509,21 +1547,21 @@ Function keys are prefixed with f character:
map <f-1> down map <f-1> down
Keys combined with the control key are prefixed with a c character: Keys combined with the Ctrl key are prefixed with a c character:
map <c-a> down map <c-a> down
Keys combined with the alt key are assigned in two different ways Keys combined with the Alt key are assigned in two different ways
depending on the behavior of your terminal. Older terminals (e.g. xterm) depending on the behavior of your terminal. Older terminals (e.g. xterm)
may set the 8th bit of a character when the alt key is pressed. On these may set the 8th bit of a character when the Alt key is pressed. On these
terminals, you can use the corresponding byte for the mapping: terminals, you can use the corresponding byte for the mapping:
map á down map á down
Newer terminals (e.g. gnome-terminal) may prefix the key with an escape Newer terminals (e.g. gnome-terminal) may prefix the key with an escape
key when the alt key is pressed. lf uses the escape delaying mechanism character when the Alt key is pressed. lf uses the escape delaying
to recognize alt keys in these terminals (delay is 100ms). On these mechanism to recognize Alt keys in these terminals (delay is 100ms). On
terminals, keys combined with the alt key are prefixed with an a these terminals, keys combined with the Alt key are prefixed with an a
character: character:
map <a-a> down map <a-a> down
@@ -1635,7 +1673,7 @@ PIPING SHELL COMMANDS
Regular shell commands have some limitations in some cases. When an Regular shell commands have some limitations in some cases. When an
output or error message is given and the command exits afterwards, the output or error message is given and the command exits afterwards, the
ui is immediately resumed and there is no way to see the message without UI is immediately resumed and there is no way to see the message without
dropping to shell again. Also, even when there is no output or error, dropping to shell again. Also, even when there is no output or error,
the UI still needs to be paused while the command is running. This can the UI still needs to be paused while the command is running. This can
cause flickering on the screen for short commands and similar cause flickering on the screen for short commands and similar
@@ -1647,14 +1685,14 @@ can be useful for programs following the Unix philosophy to give no
output in the success case, and brief error messages or prompts in other output in the success case, and brief error messages or prompts in other
cases. cases.
For example, following rename command prompts for overwrite in the For example, the following rename command prompts for overwrite in the
statline if there is an existing file with the given name: statline if there is an existing file with the given name:
cmd rename %mv -i $f $1 cmd rename %mv -i $f $1
You can also output error messages in the command and it will show up in You can also output error messages in the command and they will show up
the statline. For example, an alternative rename command may look like in the statline. For example, an alternative rename command may look
this: like this:
cmd rename %[ -e $1 ] && printf "file exists" || mv $f $1 cmd rename %[ -e $1 ] && printf "file exists" || mv $f $1
@@ -1703,7 +1741,7 @@ send a command to a single client:
lf -remote 'send 1234 echo hello world' lf -remote 'send 1234 echo hello world'
All clients have a unique id number but you may not be aware of the id All clients have a unique ID number but you may not be aware of the ID
number when you are writing a command. For this purpose, an $id variable number when you are writing a command. For this purpose, an $id variable
is exported to the environment for shell commands. The value of this is exported to the environment for shell commands. The value of this
variable is set to the process ID of the client. You can use it to send variable is set to the process ID of the client. You can use it to send
@@ -1728,7 +1766,7 @@ UI with respect to the terminal width as follows:
}} }}
In addition, the query command can be used to obtain information about a In addition, the query command can be used to obtain information about a
specific lf instance by providing its id: specific lf instance by providing its ID:
lf -remote "query $id maps" lf -remote "query $id maps"
@@ -1787,8 +1825,8 @@ named pipes, and sockets are skipped and links are not followed. Moving
is performed using the rename operation of the underlying OS. For is performed using the rename operation of the underlying OS. For
cross-device moving, lf falls back to copying and then deletes the cross-device moving, lf falls back to copying and then deletes the
original files if there are no errors. Operation errors are shown in the original files if there are no errors. Operation errors are shown in the
message line as well as the log file and they do not preemptively finish message line as well as the log file and they do not prematurely
the corresponding file operation. terminate the corresponding file operation.
File operations can be performed on the currently selected file or on File operations can be performed on the currently selected file or on
multiple files by selecting them first. When you copy a file, lf doesn't multiple files by selecting them first. When you copy a file, lf doesn't
@@ -1859,14 +1897,14 @@ zero, then the keys are read until there is only a single match. The
default values of these two options are set to jump to the first file default values of these two options are set to jump to the first file
with the given initial. with the given initial.
Some options effect both searching and finding. You can disable wrapscan Some options affect both searching and finding. You can disable wrapscan
option to prevent searches from being wrapped around at the end of the option to prevent searches from being wrapped around at the end of the
file list. You can disable ignorecase option to match cases in the file list. You can disable ignorecase option to match cases in the
pattern and the filename. This option is already automatically pattern and the filename. This option is already automatically
overridden if the pattern contains upper-case characters. You can overridden if the pattern contains uppercase characters. You can disable
disable smartcase option to disable this behavior. Two similar options smartcase option to disable this behavior. Two similar options ignoredia
ignoredia and smartdia are provided to control matching diacritics in and smartdia are provided to control matching diacritics in Latin
Latin letters. letters.
OPENING FILES OPENING FILES
@@ -1881,7 +1919,7 @@ It is possible to use different command types:
cmd open &xdg-open $f cmd open &xdg-open $f
You may want to use either file extensions or mime types from file You may want to use either file extensions or MIME types from file
command: command:
cmd open ${{ cmd open ${{
@@ -1923,12 +1961,12 @@ PREVIEWING FILES
lf previews files on the preview pane by printing the file until the end lf previews files on the preview pane by printing the file until the end
or until the preview pane is filled. This output can be enhanced by or until the preview pane is filled. This output can be enhanced by
providing a custom preview script for filtering. This can be used to providing a custom preview script for filtering. This can be used to
highlight source codes, list contents of archive files or view PDF or highlight source code, list contents of archive files or view PDF or
image files to name a few. For coloring lf recognizes ANSI escape codes. image files to name a few. For coloring lf recognizes ANSI escape codes.
To use this feature, you need to set the value of previewer option to To use this feature, you need to set the value of previewer option to
the path of an executable file. Five arguments are passed to the file, the path of an executable file. Five arguments are passed to the file,
(1) current file name, (2) width, (3) height, (4) horizontal position, (1) current filename, (2) width, (3) height, (4) horizontal position,
and (5) vertical position of preview pane respectively. The output of and (5) vertical position of preview pane respectively. The output of
the execution is printed in the preview pane. You may also want to use the execution is printed in the preview pane. You may also want to use
the same script in your pager mapping as well: the same script in your pager mapping as well:
@@ -1946,7 +1984,7 @@ still be displayed in the statusline below:
Since this script is called for each file selection change it needs to Since this script is called for each file selection change it needs to
be as efficient as possible and this responsibility is left to the user. be as efficient as possible and this responsibility is left to the user.
You may use file extensions to determine the type of file more You may use file extensions to determine the type of file more
efficiently compared to obtaining mime types from file command. efficiently compared to obtaining MIME types from file command.
Extensions can then be used to match cleanly within a conditional: Extensions can then be used to match cleanly within a conditional:
#!/bin/sh #!/bin/sh
@@ -2094,7 +2132,7 @@ environment variables possibly by overwriting its previous values.
Colors are set in the following order: Colors are set in the following order:
1. default 1. default
2. LSCOLORS (Mac/BSD ls) 2. LSCOLORS (macOS/BSD ls)
3. LS_COLORS (GNU ls) 3. LS_COLORS (GNU ls)
4. LF_COLORS (lf specific) 4. LF_COLORS (lf specific)
5. colors file (lf specific) 5. colors file (lf specific)
@@ -2226,7 +2264,7 @@ escaping newlines with backslashes as follows:
" "
The ln entry supports the special value target, which will use the link The ln entry supports the special value target, which will use the link
target to select a style. File name rules will still apply based on the target to select a style. Filename rules will still apply based on the
link's name -- this mirrors GNU's ls and dircolors behavior. Having such link's name -- this mirrors GNU's ls and dircolors behavior. Having such
a long variable definition in a shell configuration file might be a long variable definition in a shell configuration file might be
undesirable. You may instead use the colors file (refer to the undesirable. You may instead use the colors file (refer to the
@@ -2239,19 +2277,17 @@ ICONS
Icons are configured using LF_ICONS environment variable or an icons Icons are configured using LF_ICONS environment variable or an icons
file (refer to the CONFIGURATION section). The variable uses the same file (refer to the CONFIGURATION section). The variable uses the same
syntax as LS_COLORS/LF_COLORS. Instead of colors, you should put a syntax as LS_COLORS/LF_COLORS. Instead of colors, you should use single
single characters as values of entries. The ln entry supports the characters or symbols as values. The ln entry supports the special value
special value target, which will use the link target to select a icon. target, which will use the link target to select a icon. Filename rules
File name rules will still apply based on the link's name -- this will still apply based on the link's name -- this mirrors GNU's ls and
mirrors GNU's ls and dircolors behavior. The icons file (refer to the dircolors behavior. The icons file (refer to the CONFIGURATION section)
CONFIGURATION section) should consist of whitespace-separated arrays should consist of whitespace-separated arrays with a # character to
with a # character to start comments until the end of the line. Each start comments until the end of the line. Each line should contain 1-3
line should contain 1-3 columns, first column is filetype or filename columns: a file type or file name pattern, the icon, and an optional
pattern, second column is the icon, third column is an optional icon icon color. Using only one column disables all rules for that type or
color. If there is only one column, means to disable rule for this name. Do not forget to add set icons true to your lfrc to see the icons.
filetype or pattern. Do not forget to add set icons true to your lfrc to Default values are listed below in the order lf matches them:
see the icons. Default values are as follows given with their matching
order in lf:
ln l ln l
or l or l
+2 -2
View File
@@ -22,8 +22,8 @@ map i $less %f%
# change the shell used in default shell keybinding # change the shell used in default shell keybinding
map w $powershell map w $powershell
# change 'doc' command to use a different pager # change 'help' command to use a different pager
cmd doc $lf -doc | less cmd help $lf -doc | less
# leave some space at the top and the bottom of the screen # leave some space at the top and the bottom of the screen
set scrolloff 10 set scrolloff 10
+1 -2
View File
@@ -21,8 +21,7 @@ cmd open &&$Env:OPENER.Trim('"', ' ') "$Env:f"
map e $&$Env:EDITOR "$Env:f" map e $&$Env:EDITOR "$Env:f"
map i !&$Env:PAGER "$Env:f" map i !&$Env:PAGER "$Env:f"
map w $&$Env:SHELL map w $&$Env:SHELL
cmd doc !&$Env:lf -doc | &$Env:PAGER cmd help !&$Env:lf -doc | &$Env:PAGER
map <f-1> doc
cmd maps !&$Env:lf -remote "query $Env:id maps" | &$Env:PAGER cmd maps !&$Env:lf -remote "query $Env:id maps" | &$Env:PAGER
cmd nmaps !&$Env:lf -remote "query $Env:id nmaps" | &$Env:PAGER cmd nmaps !&$Env:lf -remote "query $Env:id nmaps" | &$Env:PAGER
cmd vmaps !&$Env:lf -remote "query $Env:id vmaps" | &$Env:PAGER cmd vmaps !&$Env:lf -remote "query $Env:id vmaps" | &$Env:PAGER
+86 -142
View File
@@ -64,8 +64,6 @@ func (e *setExpr) eval(app *app, args []string) {
err = applyBoolOpt(&gOpts.anchorfind, e) err = applyBoolOpt(&gOpts.anchorfind, e)
case "autoquit", "noautoquit", "autoquit!": case "autoquit", "noautoquit", "autoquit!":
err = applyBoolOpt(&gOpts.autoquit, e) err = applyBoolOpt(&gOpts.autoquit, e)
case "dircache", "nodircache", "dircache!":
err = applyBoolOpt(&gOpts.dircache, e)
case "dircounts", "nodircounts", "dircounts!": case "dircounts", "nodircounts", "dircounts!":
err = applyBoolOpt(&gOpts.dircounts, e) err = applyBoolOpt(&gOpts.dircounts, e)
if err == nil { if err == nil {
@@ -92,18 +90,9 @@ func (e *setExpr) eval(app *app, args []string) {
err = applyBoolOpt(&gOpts.drawbox, e) err = applyBoolOpt(&gOpts.drawbox, e)
if err == nil { if err == nil {
app.ui.renew() app.ui.renew()
if app.nav.height != app.ui.wins[0].h {
app.nav.height = app.ui.wins[0].h
clear(app.nav.regCache) clear(app.nav.regCache)
}
app.ui.loadFile(app, true) app.ui.loadFile(app, true)
} }
// DEPRECATED: remove after r37 is released
case "globfilter", "noglobfilter", "globfilter!":
app.ui.echoerr("option 'globfilter' is deprecated, use 'filtermethod' instead")
// DEPRECATED: remove after r37 is released
case "globsearch", "noglobsearch", "globsearch!":
app.ui.echoerr("option 'globsearch' is deprecated, use 'searchmethod' instead")
case "hidden", "nohidden", "hidden!": case "hidden", "nohidden", "hidden!":
err = applyBoolOpt(&gOpts.hidden, e) err = applyBoolOpt(&gOpts.hidden, e)
if err == nil { if err == nil {
@@ -154,10 +143,8 @@ func (e *setExpr) eval(app *app, args []string) {
err = errors.New("preview: 'ratios' should consist of at least two numbers before enabling 'preview'") err = errors.New("preview: 'ratios' should consist of at least two numbers before enabling 'preview'")
} }
if err == nil { if err == nil {
if gOpts.sixel {
app.ui.sxScreen.forceClear = true
}
gOpts.preview = preview gOpts.preview = preview
app.ui.sxScreen.forceClear = true
app.ui.loadFile(app, true) app.ui.loadFile(app, true)
} }
case "relativenumber", "norelativenumber", "relativenumber!": case "relativenumber", "norelativenumber", "relativenumber!":
@@ -172,11 +159,9 @@ func (e *setExpr) eval(app *app, args []string) {
err = applyBoolOpt(&gOpts.roundbox, e) err = applyBoolOpt(&gOpts.roundbox, e)
case "showbinds", "noshowbinds", "showbinds!": case "showbinds", "noshowbinds", "showbinds!":
err = applyBoolOpt(&gOpts.showbinds, e) err = applyBoolOpt(&gOpts.showbinds, e)
// DEPRECATED: remove after r38 is released
case "sixel", "nosixel", "sixel!": case "sixel", "nosixel", "sixel!":
err = applyBoolOpt(&gOpts.sixel, e) app.ui.echoerr("option 'sixel' has been removed as it is now enabled by default")
clear(app.nav.regCache)
app.ui.sxScreen.forceClear = true
app.ui.loadFile(app, true)
case "smartcase", "nosmartcase", "smartcase!": case "smartcase", "nosmartcase", "smartcase!":
err = applyBoolOpt(&gOpts.smartcase, e) err = applyBoolOpt(&gOpts.smartcase, e)
if err == nil { if err == nil {
@@ -291,17 +276,12 @@ func (e *setExpr) eval(app *app, args []string) {
gOpts.infotimefmtnew = e.val gOpts.infotimefmtnew = e.val
case "infotimefmtold": case "infotimefmtold":
gOpts.infotimefmtold = e.val gOpts.infotimefmtold = e.val
case "locale": case "menufmt":
localeStr := e.val gOpts.menufmt = e.val
if localeStr != localeStrDisable { case "menuheaderfmt":
if _, err = getLocaleTag(localeStr); err != nil { gOpts.menuheaderfmt = e.val
app.ui.echoerrf("locale: %s", err.Error()) case "menuselectfmt":
return gOpts.menuselectfmt = e.val
}
}
gOpts.locale = localeStr
app.nav.sort()
app.ui.sort()
case "numberfmt": case "numberfmt":
gOpts.numberfmt = e.val gOpts.numberfmt = e.val
case "period": case "period":
@@ -361,9 +341,7 @@ func (e *setExpr) eval(app *app, args []string) {
} }
gOpts.ratios = rats gOpts.ratios = rats
app.ui.wins = getWins(app.ui.screen) app.ui.wins = getWins(app.ui.screen)
if gOpts.sixel {
clear(app.nav.regCache) clear(app.nav.regCache)
}
app.ui.loadFile(app, true) app.ui.loadFile(app, true)
case "rulerfmt": case "rulerfmt":
gOpts.rulerfmt = e.val gOpts.rulerfmt = e.val
@@ -406,6 +384,14 @@ func (e *setExpr) eval(app *app, args []string) {
return return
} }
gOpts.shellopts = strings.Split(e.val, ":") gOpts.shellopts = strings.Split(e.val, ":")
case "sizeunits":
switch e.val {
case "binary", "decimal":
gOpts.sizeunits = e.val
default:
app.ui.echoerr("sizeunits: value should either be 'binary' or 'decimal'")
return
}
case "sortby": case "sortby":
method := sortMethod(e.val) method := sortMethod(e.val)
if !isValidSortMethod(method) { if !isValidSortMethod(method) {
@@ -474,7 +460,7 @@ func (e *setExpr) eval(app *app, args []string) {
return return
} }
app.ui.loadFileInfo(app.nav) app.ui.echo("")
} }
func (e *setLocalExpr) eval(app *app, args []string) { func (e *setLocalExpr) eval(app *app, args []string) {
@@ -540,17 +526,6 @@ func (e *setLocalExpr) eval(app *app, args []string) {
gLocalOpts.sortby[e.path] = method gLocalOpts.sortby[e.path] = method
app.nav.sort() app.nav.sort()
app.ui.sort() app.ui.sort()
case "locale":
localeStr := e.val
if localeStr != localeStrDisable {
if _, err = getLocaleTag(localeStr); err != nil {
app.ui.echoerrf("locale: %s", err.Error())
return
}
}
gLocalOpts.locale[e.path] = localeStr
app.nav.sort()
app.ui.sort()
default: default:
err = fmt.Errorf("unknown option: %s", e.opt) err = fmt.Errorf("unknown option: %s", e.opt)
} }
@@ -560,7 +535,7 @@ func (e *setLocalExpr) eval(app *app, args []string) {
return return
} }
app.ui.loadFileInfo(app.nav) app.ui.echo("")
} }
func (e *mapExpr) eval(app *app, args []string) { func (e *mapExpr) eval(app *app, args []string) {
@@ -571,7 +546,7 @@ func (e *mapExpr) eval(app *app, args []string) {
gOpts.nkeys[e.keys] = e.expr gOpts.nkeys[e.keys] = e.expr
gOpts.vkeys[e.keys] = e.expr gOpts.vkeys[e.keys] = e.expr
} }
app.ui.loadFileInfo(app.nav) app.ui.echo("")
} }
func (e *nmapExpr) eval(app *app, args []string) { func (e *nmapExpr) eval(app *app, args []string) {
@@ -580,7 +555,7 @@ func (e *nmapExpr) eval(app *app, args []string) {
} else { } else {
gOpts.nkeys[e.keys] = e.expr gOpts.nkeys[e.keys] = e.expr
} }
app.ui.loadFileInfo(app.nav) app.ui.echo("")
} }
func (e *vmapExpr) eval(app *app, args []string) { func (e *vmapExpr) eval(app *app, args []string) {
@@ -589,7 +564,7 @@ func (e *vmapExpr) eval(app *app, args []string) {
} else { } else {
gOpts.vkeys[e.keys] = e.expr gOpts.vkeys[e.keys] = e.expr
} }
app.ui.loadFileInfo(app.nav) app.ui.echo("")
} }
func (e *cmapExpr) eval(app *app, args []string) { func (e *cmapExpr) eval(app *app, args []string) {
@@ -598,7 +573,7 @@ func (e *cmapExpr) eval(app *app, args []string) {
} else { } else {
gOpts.cmdkeys[e.key] = e.expr gOpts.cmdkeys[e.key] = e.expr
} }
app.ui.loadFileInfo(app.nav) app.ui.echo("")
} }
func (e *cmdExpr) eval(app *app, args []string) { func (e *cmdExpr) eval(app *app, args []string) {
@@ -619,7 +594,7 @@ func (e *cmdExpr) eval(app *app, args []string) {
} }
} }
app.ui.loadFileInfo(app.nav) app.ui.echo("")
} }
func preChdir(app *app) { func preChdir(app *app) {
@@ -636,11 +611,6 @@ func onChdir(app *app) {
} }
func onLoad(app *app, files []string) { func onLoad(app *app, files []string) {
// prevent infinite loops
if !gOpts.dircache {
return
}
if cmd, ok := gOpts.cmds["on-load"]; ok { if cmd, ok := gOpts.cmds["on-load"]; ok {
cmd.eval(app, files) cmd.eval(app, files)
} }
@@ -703,6 +673,7 @@ func splitKeys(s string) (keys []string) {
func update(app *app) { func update(app *app) {
app.ui.menu = "" app.ui.menu = ""
app.ui.menuSelect = nil
app.menuCompActive = false app.menuCompActive = false
switch { switch {
@@ -721,7 +692,6 @@ func update(app *app) {
app.ui.echoerrf("search: %s: %s", err, app.nav.search) app.ui.echoerrf("search: %s: %s", err, app.nav.search)
} else if old != dir.ind { } else if old != dir.ind {
app.ui.loadFile(app, true) app.ui.loadFile(app, true)
app.ui.loadFileInfo(app.nav)
} }
case gOpts.incsearch && app.ui.cmdPrefix == "?": case gOpts.incsearch && app.ui.cmdPrefix == "?":
app.nav.search = string(app.ui.cmdAccLeft) + string(app.ui.cmdAccRight) app.nav.search = string(app.ui.cmdAccLeft) + string(app.ui.cmdAccRight)
@@ -738,7 +708,6 @@ func update(app *app) {
app.ui.echoerrf("search: %s: %s", err, app.nav.search) app.ui.echoerrf("search: %s: %s", err, app.nav.search)
} else if old != dir.ind { } else if old != dir.ind {
app.ui.loadFile(app, true) app.ui.loadFile(app, true)
app.ui.loadFileInfo(app.nav)
} }
case gOpts.incfilter && app.ui.cmdPrefix == "filter: ": case gOpts.incfilter && app.ui.cmdPrefix == "filter: ":
filter := string(app.ui.cmdAccLeft) + string(app.ui.cmdAccRight) filter := string(app.ui.cmdAccLeft) + string(app.ui.cmdAccRight)
@@ -749,7 +718,6 @@ func update(app *app) {
app.ui.echoerrf("filter: %s", err) app.ui.echoerrf("filter: %s", err)
} else if old != dir.ind { } else if old != dir.ind {
app.ui.loadFile(app, true) app.ui.loadFile(app, true)
app.ui.loadFileInfo(app.nav)
} }
} }
} }
@@ -774,7 +742,6 @@ func resetIncCmd(app *app) {
if dir.ind != app.nav.searchInd { if dir.ind != app.nav.searchInd {
dir.ind = app.nav.searchInd dir.ind = app.nav.searchInd
app.ui.loadFile(app, true) app.ui.loadFile(app, true)
app.ui.loadFileInfo(app.nav)
} }
} else if gOpts.incfilter && app.ui.cmdPrefix == "filter: " { } else if gOpts.incfilter && app.ui.cmdPrefix == "filter: " {
dir := app.nav.currDir() dir := app.nav.currDir()
@@ -782,7 +749,6 @@ func resetIncCmd(app *app) {
app.nav.setFilter(app.nav.prevFilter) app.nav.setFilter(app.nav.prevFilter)
if old != dir.ind { if old != dir.ind {
app.ui.loadFile(app, true) app.ui.loadFile(app, true)
app.ui.loadFileInfo(app.nav)
} }
} }
} }
@@ -791,23 +757,14 @@ func normal(app *app) {
resetIncCmd(app) resetIncCmd(app)
app.cmdHistoryInd = 0 app.cmdHistoryInd = 0
app.menuCompActive = false
app.ui.menu = "" app.ui.menu = ""
app.ui.menuSelect = nil
app.menuCompActive = false
app.ui.cmdAccLeft = nil app.ui.cmdAccLeft = nil
app.ui.cmdAccRight = nil app.ui.cmdAccRight = nil
app.ui.cmdPrefix = "" app.ui.cmdPrefix = ""
// ensure the mode indicator in `statfmt` is updated properly
app.ui.loadFileInfo(app.nav)
}
func visual(app *app) {
dir := app.nav.currDir()
dir.visualAnchor = dir.ind
dir.visualWrap = 0
app.ui.loadFileInfo(app.nav)
} }
func insert(app *app, arg string) { func insert(app *app, arg string) {
@@ -827,7 +784,6 @@ func insert(app *app, arg string) {
app.ui.echoerrf("find: pattern not found: %s", app.nav.find) app.ui.echoerrf("find: pattern not found: %s", app.nav.find)
case 1: case 1:
app.ui.loadFile(app, true) app.ui.loadFile(app, true)
app.ui.loadFileInfo(app.nav)
default: default:
app.ui.cmdAccLeft = append(app.ui.cmdAccLeft, []rune(arg)...) app.ui.cmdAccLeft = append(app.ui.cmdAccLeft, []rune(arg)...)
return return
@@ -842,7 +798,6 @@ func insert(app *app, arg string) {
app.ui.echoerrf("find: pattern not found: %s", app.nav.find) app.ui.echoerrf("find: pattern not found: %s", app.nav.find)
} else if moved { } else if moved {
app.ui.loadFile(app, true) app.ui.loadFile(app, true)
app.ui.loadFileInfo(app.nav)
} }
} }
@@ -856,7 +811,6 @@ func insert(app *app, arg string) {
app.ui.echoerrf("find-back: pattern not found: %s", app.nav.find) app.ui.echoerrf("find-back: pattern not found: %s", app.nav.find)
case 1: case 1:
app.ui.loadFile(app, true) app.ui.loadFile(app, true)
app.ui.loadFileInfo(app.nav)
default: default:
app.ui.cmdAccLeft = append(app.ui.cmdAccLeft, []rune(arg)...) app.ui.cmdAccLeft = append(app.ui.cmdAccLeft, []rune(arg)...)
return return
@@ -871,7 +825,6 @@ func insert(app *app, arg string) {
app.ui.echoerrf("find-back: pattern not found: %s", app.nav.find) app.ui.echoerrf("find-back: pattern not found: %s", app.nav.find)
} else if moved { } else if moved {
app.ui.loadFile(app, true) app.ui.loadFile(app, true)
app.ui.loadFileInfo(app.nav)
} }
} }
@@ -886,7 +839,6 @@ func insert(app *app, arg string) {
} }
app.nav.unselect() app.nav.unselect()
app.ui.loadFile(app, true) app.ui.loadFile(app, true)
app.ui.loadFileInfo(app.nav)
} }
case strings.HasPrefix(app.ui.cmdPrefix, "replace"): case strings.HasPrefix(app.ui.cmdPrefix, "replace"):
normal(app) normal(app)
@@ -906,7 +858,6 @@ func insert(app *app, arg string) {
} }
} }
app.ui.loadFile(app, true) app.ui.loadFile(app, true)
app.ui.loadFileInfo(app.nav)
} }
case strings.HasPrefix(app.ui.cmdPrefix, "create"): case strings.HasPrefix(app.ui.cmdPrefix, "create"):
normal(app) normal(app)
@@ -930,7 +881,6 @@ func insert(app *app, arg string) {
} }
} }
app.ui.loadFile(app, true) app.ui.loadFile(app, true)
app.ui.loadFileInfo(app.nav)
} }
case app.ui.cmdPrefix == "mark-save: ": case app.ui.cmdPrefix == "mark-save: ":
normal(app) normal(app)
@@ -951,7 +901,6 @@ func insert(app *app, arg string) {
return return
} }
} }
app.ui.loadFileInfo(app.nav)
case app.ui.cmdPrefix == "mark-load: ": case app.ui.cmdPrefix == "mark-load: ":
normal(app) normal(app)
@@ -976,7 +925,6 @@ func insert(app *app, arg string) {
return return
} }
app.ui.loadFile(app, true) app.ui.loadFile(app, true)
app.ui.loadFileInfo(app.nav)
if wd != path { if wd != path {
app.nav.marks["'"] = wd app.nav.marks["'"] = wd
@@ -1004,7 +952,6 @@ func insert(app *app, arg string) {
return return
} }
} }
app.ui.loadFileInfo(app.nav)
case app.ui.cmdPrefix == ":" && len(app.ui.cmdAccLeft) == 0: case app.ui.cmdPrefix == ":" && len(app.ui.cmdAccLeft) == 0:
switch arg { switch arg {
case "!", "$", "%", "&": case "!", "$", "%", "&":
@@ -1014,6 +961,7 @@ func insert(app *app, arg string) {
fallthrough fallthrough
default: default:
app.ui.menu = "" app.ui.menu = ""
app.ui.menuSelect = nil
app.menuCompActive = false app.menuCompActive = false
app.ui.cmdAccLeft = append(app.ui.cmdAccLeft, []rune(arg)...) app.ui.cmdAccLeft = append(app.ui.cmdAccLeft, []rune(arg)...)
} }
@@ -1031,7 +979,6 @@ func (e *callExpr) eval(app *app, args []string) {
} }
if app.nav.up(e.count) { if app.nav.up(e.count) {
app.ui.loadFile(app, true) app.ui.loadFile(app, true)
app.ui.loadFileInfo(app.nav)
} }
case "half-up": case "half-up":
if !app.nav.init { if !app.nav.init {
@@ -1039,7 +986,6 @@ func (e *callExpr) eval(app *app, args []string) {
} }
if app.nav.up(e.count * app.nav.height / 2) { if app.nav.up(e.count * app.nav.height / 2) {
app.ui.loadFile(app, true) app.ui.loadFile(app, true)
app.ui.loadFileInfo(app.nav)
} }
case "page-up": case "page-up":
if !app.nav.init { if !app.nav.init {
@@ -1047,7 +993,6 @@ func (e *callExpr) eval(app *app, args []string) {
} }
if app.nav.up(e.count * app.nav.height) { if app.nav.up(e.count * app.nav.height) {
app.ui.loadFile(app, true) app.ui.loadFile(app, true)
app.ui.loadFileInfo(app.nav)
} }
case "scroll-up": case "scroll-up":
if !app.nav.init { if !app.nav.init {
@@ -1055,7 +1000,6 @@ func (e *callExpr) eval(app *app, args []string) {
} }
if app.nav.scrollUp(e.count) { if app.nav.scrollUp(e.count) {
app.ui.loadFile(app, true) app.ui.loadFile(app, true)
app.ui.loadFileInfo(app.nav)
} }
case "down": case "down":
if !app.nav.init { if !app.nav.init {
@@ -1063,7 +1007,6 @@ func (e *callExpr) eval(app *app, args []string) {
} }
if app.nav.down(e.count) { if app.nav.down(e.count) {
app.ui.loadFile(app, true) app.ui.loadFile(app, true)
app.ui.loadFileInfo(app.nav)
} }
case "half-down": case "half-down":
if !app.nav.init { if !app.nav.init {
@@ -1071,7 +1014,6 @@ func (e *callExpr) eval(app *app, args []string) {
} }
if app.nav.down(e.count * app.nav.height / 2) { if app.nav.down(e.count * app.nav.height / 2) {
app.ui.loadFile(app, true) app.ui.loadFile(app, true)
app.ui.loadFileInfo(app.nav)
} }
case "page-down": case "page-down":
if !app.nav.init { if !app.nav.init {
@@ -1079,7 +1021,6 @@ func (e *callExpr) eval(app *app, args []string) {
} }
if app.nav.down(e.count * app.nav.height) { if app.nav.down(e.count * app.nav.height) {
app.ui.loadFile(app, true) app.ui.loadFile(app, true)
app.ui.loadFileInfo(app.nav)
} }
case "scroll-down": case "scroll-down":
if !app.nav.init { if !app.nav.init {
@@ -1087,7 +1028,6 @@ func (e *callExpr) eval(app *app, args []string) {
} }
if app.nav.scrollDown(e.count) { if app.nav.scrollDown(e.count) {
app.ui.loadFile(app, true) app.ui.loadFile(app, true)
app.ui.loadFileInfo(app.nav)
} }
case "updir": case "updir":
if !app.nav.init { if !app.nav.init {
@@ -1102,7 +1042,6 @@ func (e *callExpr) eval(app *app, args []string) {
} }
} }
app.ui.loadFile(app, true) app.ui.loadFile(app, true)
app.ui.loadFileInfo(app.nav)
restartIncCmd(app) restartIncCmd(app)
onChdir(app) onChdir(app)
case "open": case "open":
@@ -1124,23 +1063,19 @@ func (e *callExpr) eval(app *app, args []string) {
return return
} }
app.ui.loadFile(app, true) app.ui.loadFile(app, true)
app.ui.loadFileInfo(app.nav)
restartIncCmd(app) restartIncCmd(app)
onChdir(app) onChdir(app)
return } else {
}
if gSelectionPath != "" || gPrintSelection { if gSelectionPath != "" || gPrintSelection {
app.selectionOut, _ = app.nav.currFileOrSelections() app.selectionOut, _ = app.nav.currFileOrSelections()
app.quitChan <- struct{}{} app.quitChan <- struct{}{}
return return
} }
app.ui.loadFileInfo(app.nav)
if cmd, ok := gOpts.cmds["open"]; ok { if cmd, ok := gOpts.cmds["open"]; ok {
cmd.eval(app, e.args) cmd.eval(app, e.args)
} }
}
case "jump-next": case "jump-next":
resetIncCmd(app) resetIncCmd(app)
preChdir(app) preChdir(app)
@@ -1148,7 +1083,6 @@ func (e *callExpr) eval(app *app, args []string) {
app.nav.cdJumpListNext() app.nav.cdJumpListNext()
} }
app.ui.loadFile(app, true) app.ui.loadFile(app, true)
app.ui.loadFileInfo(app.nav)
restartIncCmd(app) restartIncCmd(app)
onChdir(app) onChdir(app)
case "jump-prev": case "jump-prev":
@@ -1158,7 +1092,6 @@ func (e *callExpr) eval(app *app, args []string) {
app.nav.cdJumpListPrev() app.nav.cdJumpListPrev()
} }
app.ui.loadFile(app, true) app.ui.loadFile(app, true)
app.ui.loadFileInfo(app.nav)
restartIncCmd(app) restartIncCmd(app)
onChdir(app) onChdir(app)
case "top": case "top":
@@ -1173,7 +1106,6 @@ func (e *callExpr) eval(app *app, args []string) {
} }
if moved { if moved {
app.ui.loadFile(app, true) app.ui.loadFile(app, true)
app.ui.loadFileInfo(app.nav)
} }
case "bottom": case "bottom":
if !app.nav.init { if !app.nav.init {
@@ -1189,7 +1121,6 @@ func (e *callExpr) eval(app *app, args []string) {
} }
if moved { if moved {
app.ui.loadFile(app, true) app.ui.loadFile(app, true)
app.ui.loadFileInfo(app.nav)
} }
case "high": case "high":
if !app.nav.init { if !app.nav.init {
@@ -1197,7 +1128,6 @@ func (e *callExpr) eval(app *app, args []string) {
} }
if app.nav.high() { if app.nav.high() {
app.ui.loadFile(app, true) app.ui.loadFile(app, true)
app.ui.loadFileInfo(app.nav)
} }
case "middle": case "middle":
if !app.nav.init { if !app.nav.init {
@@ -1205,7 +1135,6 @@ func (e *callExpr) eval(app *app, args []string) {
} }
if app.nav.middle() { if app.nav.middle() {
app.ui.loadFile(app, true) app.ui.loadFile(app, true)
app.ui.loadFileInfo(app.nav)
} }
case "low": case "low":
if !app.nav.init { if !app.nav.init {
@@ -1213,7 +1142,6 @@ func (e *callExpr) eval(app *app, args []string) {
} }
if app.nav.low() { if app.nav.low() {
app.ui.loadFile(app, true) app.ui.loadFile(app, true)
app.ui.loadFileInfo(app.nav)
} }
case "toggle": case "toggle":
if !app.nav.init { if !app.nav.init {
@@ -1287,7 +1215,6 @@ func (e *callExpr) eval(app *app, args []string) {
return return
} }
} }
app.ui.loadFileInfo(app.nav)
case "cut": case "cut":
if !app.nav.init { if !app.nav.init {
return return
@@ -1309,7 +1236,6 @@ func (e *callExpr) eval(app *app, args []string) {
return return
} }
} }
app.ui.loadFileInfo(app.nav)
case "paste": case "paste":
if !app.nav.init { if !app.nav.init {
return return
@@ -1322,7 +1248,6 @@ func (e *callExpr) eval(app *app, args []string) {
return return
} }
app.ui.loadFile(app, true) app.ui.loadFile(app, true)
app.ui.loadFileInfo(app.nav)
case "clear": case "clear":
if !app.nav.init { if !app.nav.init {
return return
@@ -1342,7 +1267,6 @@ func (e *callExpr) eval(app *app, args []string) {
return return
} }
} }
app.ui.loadFileInfo(app.nav)
case "sync": case "sync":
if err := app.nav.sync(); err != nil { if err := app.nav.sync(); err != nil {
app.ui.echoerrf("sync: %s", err) app.ui.echoerrf("sync: %s", err)
@@ -1358,13 +1282,10 @@ func (e *callExpr) eval(app *app, args []string) {
app.nav.height = app.ui.wins[0].h app.nav.height = app.ui.wins[0].h
clear(app.nav.regCache) clear(app.nav.regCache)
} }
if gOpts.sixel {
clear(app.nav.regCache)
app.ui.sxScreen.forceClear = true
}
for _, dir := range app.nav.dirs { for _, dir := range app.nav.dirs {
dir.boundPos(app.nav.height) dir.boundPos(app.nav.height)
} }
app.ui.sxScreen.forceClear = true
app.ui.loadFile(app, true) app.ui.loadFile(app, true)
onRedraw(app) onRedraw(app)
case "load": case "load":
@@ -1381,7 +1302,6 @@ func (e *callExpr) eval(app *app, args []string) {
app.ui.echoerrf("reload: %s", err) app.ui.echoerrf("reload: %s", err)
} }
app.ui.loadFile(app, true) app.ui.loadFile(app, true)
app.ui.loadFileInfo(app.nav)
case "delete": case "delete":
if !app.nav.init { if !app.nav.init {
return return
@@ -1416,7 +1336,6 @@ func (e *callExpr) eval(app *app, args []string) {
app.ui.cmdPrefix = "delete " + strconv.Itoa(len(list)) + " items? [y/N] " app.ui.cmdPrefix = "delete " + strconv.Itoa(len(list)) + " items? [y/N] "
} }
} }
app.ui.loadFileInfo(app.nav)
case "rename": case "rename":
if !app.nav.init { if !app.nav.init {
return return
@@ -1452,42 +1371,36 @@ func (e *callExpr) eval(app *app, args []string) {
app.ui.cmdAccRight = append(app.ui.cmdAccRight, []rune(extension)...) app.ui.cmdAccRight = append(app.ui.cmdAccRight, []rune(extension)...)
} }
} }
app.ui.loadFileInfo(app.nav)
case "read": case "read":
if app.ui.cmdPrefix == ">" { if app.ui.cmdPrefix == ">" {
return return
} }
normal(app) normal(app)
app.ui.cmdPrefix = ":" app.ui.cmdPrefix = ":"
app.ui.loadFileInfo(app.nav)
case "shell": case "shell":
if app.ui.cmdPrefix == ">" { if app.ui.cmdPrefix == ">" {
return return
} }
normal(app) normal(app)
app.ui.cmdPrefix = "$" app.ui.cmdPrefix = "$"
app.ui.loadFileInfo(app.nav)
case "shell-pipe": case "shell-pipe":
if app.ui.cmdPrefix == ">" { if app.ui.cmdPrefix == ">" {
return return
} }
normal(app) normal(app)
app.ui.cmdPrefix = "%" app.ui.cmdPrefix = "%"
app.ui.loadFileInfo(app.nav)
case "shell-wait": case "shell-wait":
if app.ui.cmdPrefix == ">" { if app.ui.cmdPrefix == ">" {
return return
} }
normal(app) normal(app)
app.ui.cmdPrefix = "!" app.ui.cmdPrefix = "!"
app.ui.loadFileInfo(app.nav)
case "shell-async": case "shell-async":
if app.ui.cmdPrefix == ">" { if app.ui.cmdPrefix == ">" {
return return
} }
normal(app) normal(app)
app.ui.cmdPrefix = "&" app.ui.cmdPrefix = "&"
app.ui.loadFileInfo(app.nav)
case "find": case "find":
if app.ui.cmdPrefix == ">" { if app.ui.cmdPrefix == ">" {
return return
@@ -1495,7 +1408,6 @@ func (e *callExpr) eval(app *app, args []string) {
normal(app) normal(app)
app.ui.cmdPrefix = "find: " app.ui.cmdPrefix = "find: "
app.nav.findBack = false app.nav.findBack = false
app.ui.loadFileInfo(app.nav)
case "find-back": case "find-back":
if app.ui.cmdPrefix == ">" { if app.ui.cmdPrefix == ">" {
return return
@@ -1503,7 +1415,6 @@ func (e *callExpr) eval(app *app, args []string) {
normal(app) normal(app)
app.ui.cmdPrefix = "find-back: " app.ui.cmdPrefix = "find-back: "
app.nav.findBack = true app.nav.findBack = true
app.ui.loadFileInfo(app.nav)
case "find-next": case "find-next":
if !app.nav.init { if !app.nav.init {
return return
@@ -1519,7 +1430,6 @@ func (e *callExpr) eval(app *app, args []string) {
} }
if old != dir.ind { if old != dir.ind {
app.ui.loadFile(app, true) app.ui.loadFile(app, true)
app.ui.loadFileInfo(app.nav)
} }
case "find-prev": case "find-prev":
if !app.nav.init { if !app.nav.init {
@@ -1536,7 +1446,6 @@ func (e *callExpr) eval(app *app, args []string) {
} }
if old != dir.ind { if old != dir.ind {
app.ui.loadFile(app, true) app.ui.loadFile(app, true)
app.ui.loadFileInfo(app.nav)
} }
case "search": case "search":
if !app.nav.init { if !app.nav.init {
@@ -1551,7 +1460,6 @@ func (e *callExpr) eval(app *app, args []string) {
app.nav.searchInd = dir.ind app.nav.searchInd = dir.ind
app.nav.searchPos = dir.pos app.nav.searchPos = dir.pos
app.nav.searchBack = false app.nav.searchBack = false
app.ui.loadFileInfo(app.nav)
case "search-back": case "search-back":
if !app.nav.init { if !app.nav.init {
return return
@@ -1565,7 +1473,6 @@ func (e *callExpr) eval(app *app, args []string) {
app.nav.searchInd = dir.ind app.nav.searchInd = dir.ind
app.nav.searchPos = dir.pos app.nav.searchPos = dir.pos
app.nav.searchBack = true app.nav.searchBack = true
app.ui.loadFileInfo(app.nav)
case "search-next": case "search-next":
if !app.nav.init { if !app.nav.init {
return return
@@ -1576,14 +1483,12 @@ func (e *callExpr) eval(app *app, args []string) {
app.ui.echoerrf("search-back: %s: %s", err, app.nav.search) app.ui.echoerrf("search-back: %s: %s", err, app.nav.search)
} else if moved { } else if moved {
app.ui.loadFile(app, true) app.ui.loadFile(app, true)
app.ui.loadFileInfo(app.nav)
} }
} else { } else {
if moved, err := app.nav.searchNext(); err != nil { if moved, err := app.nav.searchNext(); err != nil {
app.ui.echoerrf("search: %s: %s", err, app.nav.search) app.ui.echoerrf("search: %s: %s", err, app.nav.search)
} else if moved { } else if moved {
app.ui.loadFile(app, true) app.ui.loadFile(app, true)
app.ui.loadFileInfo(app.nav)
} }
} }
} }
@@ -1597,14 +1502,12 @@ func (e *callExpr) eval(app *app, args []string) {
app.ui.echoerrf("search-back: %s: %s", err, app.nav.search) app.ui.echoerrf("search-back: %s: %s", err, app.nav.search)
} else if moved { } else if moved {
app.ui.loadFile(app, true) app.ui.loadFile(app, true)
app.ui.loadFileInfo(app.nav)
} }
} else { } else {
if moved, err := app.nav.searchPrev(); err != nil { if moved, err := app.nav.searchPrev(); err != nil {
app.ui.echoerrf("search: %s: %s", err, app.nav.search) app.ui.echoerrf("search: %s: %s", err, app.nav.search)
} else if moved { } else if moved {
app.ui.loadFile(app, true) app.ui.loadFile(app, true)
app.ui.loadFileInfo(app.nav)
} }
} }
} }
@@ -1624,7 +1527,6 @@ func (e *callExpr) eval(app *app, args []string) {
} else { } else {
app.ui.cmdAccLeft = []rune(strings.Join(e.args, " ")) app.ui.cmdAccLeft = []rune(strings.Join(e.args, " "))
} }
app.ui.loadFileInfo(app.nav)
case "setfilter": case "setfilter":
if !app.nav.init { if !app.nav.init {
return return
@@ -1634,7 +1536,6 @@ func (e *callExpr) eval(app *app, args []string) {
app.ui.echoerrf("filter: %s", err) app.ui.echoerrf("filter: %s", err)
} }
app.ui.loadFile(app, true) app.ui.loadFile(app, true)
app.ui.loadFileInfo(app.nav)
case "mark-save": case "mark-save":
if app.ui.cmdPrefix == ">" { if app.ui.cmdPrefix == ">" {
return return
@@ -1740,7 +1641,6 @@ func (e *callExpr) eval(app *app, args []string) {
} }
app.ui.loadFile(app, true) app.ui.loadFile(app, true)
app.ui.loadFileInfo(app.nav)
if wd != path { if wd != path {
app.nav.marks["'"] = wd app.nav.marks["'"] = wd
@@ -1780,7 +1680,6 @@ func (e *callExpr) eval(app *app, args []string) {
} }
app.ui.loadFile(app, true) app.ui.loadFile(app, true)
app.ui.loadFileInfo(app.nav)
if wd != path { if wd != path {
app.nav.marks["'"] = wd app.nav.marks["'"] = wd
@@ -1793,7 +1692,6 @@ func (e *callExpr) eval(app *app, args []string) {
return return
} }
app.readFile(replaceTilde(e.args[0])) app.readFile(replaceTilde(e.args[0]))
app.ui.loadFileInfo(app.nav)
case "push": case "push":
if len(e.args) != 1 { if len(e.args) != 1 {
app.ui.echoerr("push: requires an argument") app.ui.echoerr("push: requires an argument")
@@ -1859,7 +1757,6 @@ func (e *callExpr) eval(app *app, args []string) {
app.ui.echoerrf("calcdirsize: %s", err) app.ui.echoerrf("calcdirsize: %s", err)
return return
} }
app.ui.loadFileInfo(app.nav)
app.nav.sort() app.nav.sort()
app.ui.sort() app.ui.sort()
case "clearmaps": case "clearmaps":
@@ -1885,7 +1782,9 @@ func (e *callExpr) eval(app *app, args []string) {
if !app.nav.init { if !app.nav.init {
return return
} }
visual(app) dir := app.nav.currDir()
dir.visualAnchor = dir.ind
dir.visualWrap = 0
case "visual-accept": case "visual-accept":
if !app.nav.init { if !app.nav.init {
return return
@@ -1949,6 +1848,7 @@ func (e *callExpr) eval(app *app, args []string) {
app.menuComplete(-1) app.menuComplete(-1)
case "cmd-menu-accept": case "cmd-menu-accept":
app.ui.menu = "" app.ui.menu = ""
app.ui.menuSelect = nil
app.menuCompActive = false app.menuCompActive = false
case "cmd-enter": case "cmd-enter":
s := string(append(app.ui.cmdAccLeft, app.ui.cmdAccRight...)) s := string(append(app.ui.cmdAccLeft, app.ui.cmdAccRight...))
@@ -1957,6 +1857,7 @@ func (e *callExpr) eval(app *app, args []string) {
} }
app.ui.menu = "" app.ui.menu = ""
app.ui.menuSelect = nil
app.menuCompActive = false app.menuCompActive = false
app.ui.cmdAccLeft = nil app.ui.cmdAccLeft = nil
@@ -2010,7 +1911,6 @@ func (e *callExpr) eval(app *app, args []string) {
app.ui.echoerrf("search: %s: %s", err, app.nav.search) app.ui.echoerrf("search: %s: %s", err, app.nav.search)
} else if old != dir.ind { } else if old != dir.ind {
app.ui.loadFile(app, true) app.ui.loadFile(app, true)
app.ui.loadFileInfo(app.nav)
} }
case "?": case "?":
dir := app.nav.currDir() dir := app.nav.currDir()
@@ -2026,7 +1926,6 @@ func (e *callExpr) eval(app *app, args []string) {
app.ui.echoerrf("search-back: %s: %s", err, app.nav.search) app.ui.echoerrf("search-back: %s: %s", err, app.nav.search)
} else if old != dir.ind { } else if old != dir.ind {
app.ui.loadFile(app, true) app.ui.loadFile(app, true)
app.ui.loadFileInfo(app.nav)
} }
case "filter: ": case "filter: ":
log.Printf("filter: %s", s) log.Printf("filter: %s", s)
@@ -2035,14 +1934,12 @@ func (e *callExpr) eval(app *app, args []string) {
app.ui.echoerrf("filter: %s", err) app.ui.echoerrf("filter: %s", err)
} }
app.ui.loadFile(app, true) app.ui.loadFile(app, true)
app.ui.loadFileInfo(app.nav)
case "find: ": case "find: ":
app.ui.cmdPrefix = "" app.ui.cmdPrefix = ""
if moved, found := app.nav.findNext(); !found { if moved, found := app.nav.findNext(); !found {
app.ui.echoerrf("find: pattern not found: %s", app.nav.find) app.ui.echoerrf("find: pattern not found: %s", app.nav.find)
} else if moved { } else if moved {
app.ui.loadFile(app, true) app.ui.loadFile(app, true)
app.ui.loadFileInfo(app.nav)
} }
case "find-back: ": case "find-back: ":
app.ui.cmdPrefix = "" app.ui.cmdPrefix = ""
@@ -2050,7 +1947,6 @@ func (e *callExpr) eval(app *app, args []string) {
app.ui.echoerrf("find-back: pattern not found: %s", app.nav.find) app.ui.echoerrf("find-back: pattern not found: %s", app.nav.find)
} else if moved { } else if moved {
app.ui.loadFile(app, true) app.ui.loadFile(app, true)
app.ui.loadFileInfo(app.nav)
} }
case "rename: ": case "rename: ":
app.ui.cmdPrefix = "" app.ui.cmdPrefix = ""
@@ -2107,7 +2003,6 @@ func (e *callExpr) eval(app *app, args []string) {
} }
} }
app.ui.loadFile(app, true) app.ui.loadFile(app, true)
app.ui.loadFileInfo(app.nav)
default: default:
log.Printf("entering unknown execution prefix: %q", app.ui.cmdPrefix) log.Printf("entering unknown execution prefix: %q", app.ui.cmdPrefix)
} }
@@ -2356,6 +2251,55 @@ func (e *callExpr) eval(app *app, args []string) {
} }
cmd.eval(app, e.args) cmd.eval(app, e.args)
} }
// commands that run silently or write messages shouldn't clear existing messages
keepMsgCmds := []string{
"addcustominfo",
"draw",
"echo",
"echoerr",
"echomsg",
"load",
"push",
"redraw",
"sync",
"tty-write",
"cmd-insert",
"cmd-escape",
"cmd-complete",
"cmd-menu-complete",
"cmd-menu-complete-back",
"cmd-menu-accept",
"cmd-enter",
"cmd-interrupt",
"cmd-history-next",
"cmd-history-prev",
"cmd-left",
"cmd-right",
"cmd-home",
"cmd-end",
"cmd-delete",
"cmd-delete-back",
"cmd-delete-home",
"cmd-delete-end",
"cmd-delete-unix-word",
"cmd-yank",
"cmd-transpose",
"cmd-transpose-word",
"cmd-word",
"cmd-word-back",
"cmd-delete-word",
"cmd-delete-word-back",
"cmd-capitalize-word",
"cmd-uppercase-word",
"cmd-lowercase-word",
"on-focus-gained",
"on-focus-lost",
"on-init",
}
if !slices.Contains(keepMsgCmds, e.name) {
app.ui.echo("")
}
} }
func (e *execExpr) eval(app *app, args []string) { func (e *execExpr) eval(app *app, args []string) {
+2 -3
View File
@@ -3,18 +3,17 @@ module github.com/gokcehan/lf
go 1.23.0 go 1.23.0
require ( require (
github.com/Xuanwo/go-locale v1.1.3
github.com/djherbis/times v1.6.0 github.com/djherbis/times v1.6.0
github.com/fsnotify/fsnotify v1.9.0 github.com/fsnotify/fsnotify v1.9.0
github.com/gdamore/tcell/v2 v2.8.1 github.com/gdamore/tcell/v2 v2.9.0
github.com/mattn/go-runewidth v0.0.16 github.com/mattn/go-runewidth v0.0.16
golang.org/x/sys v0.35.0 golang.org/x/sys v0.35.0
golang.org/x/term v0.34.0 golang.org/x/term v0.34.0
golang.org/x/text v0.28.0
) )
require ( require (
github.com/gdamore/encoding v1.0.1 // indirect github.com/gdamore/encoding v1.0.1 // indirect
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
github.com/rivo/uniseg v0.4.7 // indirect github.com/rivo/uniseg v0.4.7 // indirect
golang.org/x/text v0.28.0 // indirect
) )
+2 -37
View File
@@ -1,48 +1,30 @@
github.com/Xuanwo/go-locale v1.1.3 h1:EWZZJJt5rqPHHbqPRH1zFCn5D7xHjjebODctA4aUO3A=
github.com/Xuanwo/go-locale v1.1.3/go.mod h1:REn+F/c+AtGSWYACBSYZgl23AP+0lfQC+SEFPN+hj30=
github.com/djherbis/times v1.6.0 h1:w2ctJ92J8fBvWPxugmXIv7Nz7Q3iDMKNx9v5ocVH20c= github.com/djherbis/times v1.6.0 h1:w2ctJ92J8fBvWPxugmXIv7Nz7Q3iDMKNx9v5ocVH20c=
github.com/djherbis/times v1.6.0/go.mod h1:gOHeRAz2h+VJNZ5Gmc/o7iD9k4wW7NMVqieYCY99oc0= github.com/djherbis/times v1.6.0/go.mod h1:gOHeRAz2h+VJNZ5Gmc/o7iD9k4wW7NMVqieYCY99oc0=
github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k= github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k=
github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0= github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
github.com/gdamore/encoding v1.0.1 h1:YzKZckdBL6jVt2Gc+5p82qhrGiqMdG/eNs6Wy0u3Uhw= github.com/gdamore/encoding v1.0.1 h1:YzKZckdBL6jVt2Gc+5p82qhrGiqMdG/eNs6Wy0u3Uhw=
github.com/gdamore/encoding v1.0.1/go.mod h1:0Z0cMFinngz9kS1QfMjCP8TY7em3bZYeeklsSDPivEo= github.com/gdamore/encoding v1.0.1/go.mod h1:0Z0cMFinngz9kS1QfMjCP8TY7em3bZYeeklsSDPivEo=
github.com/gdamore/tcell/v2 v2.8.1 h1:KPNxyqclpWpWQlPLx6Xui1pMk8S+7+R37h3g07997NU= github.com/gdamore/tcell/v2 v2.9.0 h1:N6t+eqK7/xwtRPwxzs1PXeRWnm0H9l02CrgJ7DLn1ys=
github.com/gdamore/tcell/v2 v2.8.1/go.mod h1:bj8ori1BG3OYMjmb3IklZVWfZUJ1UBQt9JXrOCOhGWw= github.com/gdamore/tcell/v2 v2.9.0/go.mod h1:8/ZoqM9rxzYphT9tH/9LnunhV9oPBqwS8WHGYm5nrmo=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY= github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0= github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc= github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc=
github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.4.3/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc=
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk=
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
@@ -50,39 +32,22 @@ golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220615213510-4f61da869c0c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220615213510-4f61da869c0c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI= golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI=
golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU=
golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk=
golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY=
golang.org/x/term v0.28.0/go.mod h1:Sw/lC2IAUZ92udQNf3WodGtn4k/XoLyZoh8v/8uiwek=
golang.org/x/term v0.34.0 h1:O/2T7POpk0ZZ7MAzMeWFSg6S5IpWd/RXDlM9hgM3DR4= golang.org/x/term v0.34.0 h1:O/2T7POpk0ZZ7MAzMeWFSg6S5IpWd/RXDlM9hgM3DR4=
golang.org/x/term v0.34.0/go.mod h1:5jC53AEywhIVebHgPVeg0mj8OD3VO9OzclacVrqpaAw= golang.org/x/term v0.34.0/go.mod h1:5jC53AEywhIVebHgPVeg0mj8OD3VO9OzclacVrqpaAw=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
golang.org/x/text v0.28.0 h1:rhazDwis8INMIwQ4tpjLDzUhx6RlXqZNPEM0huQojng= golang.org/x/text v0.28.0 h1:rhazDwis8INMIwQ4tpjLDzUhx6RlXqZNPEM0huQojng=
golang.org/x/text v0.28.0/go.mod h1:U8nCwOR8jO/marOQ0QbDiOngZVEBB7MAiitBuMjXiNU= golang.org/x/text v0.28.0/go.mod h1:U8nCwOR8jO/marOQ0QbDiOngZVEBB7MAiitBuMjXiNU=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58=
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
+153 -126
View File
@@ -1,13 +1,13 @@
.\" Automatically generated by Pandoc 3.7.0.2 .\" Automatically generated by Pandoc 3.7.0.2
.\" .\"
.TH "LF" "1" "2025\-08\-25" "r37" "DOCUMENTATION" .TH "LF" "1" "2025\-09\-19" "r38" "DOCUMENTATION"
.SH NAME .SH NAME
lf \- terminal file manager lf \- terminal file manager
.SH SYNOPSIS .SH SYNOPSIS
\f[B]lf\f[R] [\f[B]\-command\f[R] \f[I]command\f[R]] [\f[B]\-config\f[R] \f[B]lf\f[R] [\f[B]\-command\f[R] \f[I]command\f[R]] [\f[B]\-config\f[R]
\f[I]path\f[R]] [\f[B]\-cpuprofile\f[R] \f[I]path\f[R]] \f[I]path\f[R]] [\f[B]\-cpuprofile\f[R] \f[I]path\f[R]]
[\f[B]\-doc\f[R]] [\f[B]\-last\-dir\-path\f[R] \f[I]path\f[R]] [\f[B]\-doc\f[R]] [\f[B]\-last\-dir\-path\f[R] \f[I]path\f[R]]
[\f[B]\-log path\f[R]] [\f[B]\-memprofile\f[R] \f[I]path\f[R]] [\f[B]\-log\f[R] \f[I]path\f[R]] [\f[B]\-memprofile\f[R] \f[I]path\f[R]]
[\f[B]\-print\-last\-dir\f[R]] [\f[B]\-print\-selection\f[R]] [\f[B]\-print\-last\-dir\f[R]] [\f[B]\-print\-selection\f[R]]
[\f[B]\-remote\f[R] \f[I]command\f[R]] [\f[B]\-selection\-path\f[R] [\f[B]\-remote\f[R] \f[I]command\f[R]] [\f[B]\-selection\-path\f[R]
\f[I]path\f[R]] [\f[B]\-server\f[R]] [\f[B]\-single\f[R]] \f[I]path\f[R]] [\f[B]\-server\f[R]] [\f[B]\-single\f[R]]
@@ -24,7 +24,7 @@ This documentation can either be read from the terminal using
\f[CR]lf \-doc\f[R] or online at \c \f[CR]lf \-doc\f[R] or online at \c
.UR https://github.com/gokcehan/lf/blob/master/doc.md .UR https://github.com/gokcehan/lf/blob/master/doc.md
.UE \c .UE \c
\ You can also use the \f[CR]doc\f[R] command (default \ You can also use the \f[CR]help\f[R] command (default
\f[CR]<f\-1>\f[R]) inside lf to view the documentation in a pager. \f[CR]<f\-1>\f[R]) inside lf to view the documentation in a pager.
A man page with the same content is also available in the repository at A man page with the same content is also available in the repository at
\c \c
@@ -160,7 +160,6 @@ cursoractivefmt string (default \(dq\(rs033[7m\(dq)
cursorparentfmt string (default \(dq\(rs033[7m\(dq) cursorparentfmt string (default \(dq\(rs033[7m\(dq)
cursorpreviewfmt string (default \(dq\(rs033[4m\(dq) cursorpreviewfmt string (default \(dq\(rs033[4m\(dq)
cutfmt string (default \(dq\(rs033[7;31m\(dq) cutfmt string (default \(dq\(rs033[7;31m\(dq)
dircache bool (default true)
dircounts bool (default false) dircounts bool (default false)
dirfirst bool (default true) dirfirst bool (default true)
dironly bool (default false) dironly bool (default false)
@@ -183,7 +182,9 @@ incsearch bool (default false)
info []string (default \(aq\(aq) info []string (default \(aq\(aq)
infotimefmtnew string (default \(aqJan _2 15:04\(aq) infotimefmtnew string (default \(aqJan _2 15:04\(aq)
infotimefmtold string (default \(aqJan _2 2006\(aq) infotimefmtold string (default \(aqJan _2 2006\(aq)
locale string (default \(aq\(aq) menufmt string (default \(dq\(rs033[0m\(dq)
menuheaderfmt string (default \(dq\(rs033[1m\(dq)
menuselectfmt string (default \(dq\(rs033[7m\(dq)
mouse bool (default false) mouse bool (default false)
number bool (default false) number bool (default false)
numberfmt string (default \(dq\(rs033[33m\(dq) numberfmt string (default \(dq\(rs033[33m\(dq)
@@ -205,7 +206,7 @@ shell string (default \(aqsh\(aq for Unix and \(aqcmd\(aq for Win
shellflag string (default \(aq\-c\(aq for Unix and \(aq/c\(aq for Windows) shellflag string (default \(aq\-c\(aq for Unix and \(aq/c\(aq for Windows)
shellopts []string (default \(aq\(aq) shellopts []string (default \(aq\(aq)
showbinds bool (default true) showbinds bool (default true)
sixel bool (default false) sizeunits string (default \(aqbinary\(aq)
smartcase bool (default true) smartcase bool (default true)
smartdia bool (default false) smartdia bool (default false)
sortby string (default \(aqnatural\(aq) sortby string (default \(aqnatural\(aq)
@@ -277,8 +278,8 @@ cmd open &$OPENER \(dq$f\(dq
map e $$EDITOR \(dq$f\(dq map e $$EDITOR \(dq$f\(dq
map i $$PAGER \(dq$f\(dq map i $$PAGER \(dq$f\(dq
map w $$SHELL map w $$SHELL
cmd doc $$lf \-doc | $PAGER cmd help $$lf \-doc | $PAGER
map <f\-1> doc map <f\-1> help
cmd maps $lf \-remote \(dqquery $id maps\(dq | $PAGER cmd maps $lf \-remote \(dqquery $id maps\(dq | $PAGER
cmd nmaps $lf \-remote \(dqquery $id nmaps\(dq | $PAGER cmd nmaps $lf \-remote \(dqquery $id nmaps\(dq | $PAGER
cmd vmaps $lf \-remote \(dqquery $id vmaps\(dq | $PAGER cmd vmaps $lf \-remote \(dqquery $id vmaps\(dq | $PAGER
@@ -290,8 +291,8 @@ cmd open &%OPENER% %f%
map e $%EDITOR% %f% map e $%EDITOR% %f%
map i !%PAGER% %f% map i !%PAGER% %f%
map w $%SHELL% map w $%SHELL%
cmd doc !%lf% \-doc | %PAGER% cmd help !%lf% \-doc | %PAGER%
map <f\-1> doc map <f\-1> help
cmd maps !%lf% \-remote \(dqquery %id% maps\(dq | %PAGER% cmd maps !%lf% \-remote \(dqquery %id% maps\(dq | %PAGER%
cmd nmaps !%lf% \-remote \(dqquery %id% nmaps\(dq | %PAGER% cmd nmaps !%lf% \-remote \(dqquery %id% nmaps\(dq | %PAGER%
cmd vmaps !%lf% \-remote \(dqquery %id% vmaps\(dq | %PAGER% cmd vmaps !%lf% \-remote \(dqquery %id% vmaps\(dq | %PAGER%
@@ -299,6 +300,11 @@ cmd cmaps !%lf% \-remote \(dqquery %id% cmaps\(dq | %PAGER%
cmd cmds !%lf% \-remote \(dqquery %id% cmds\(dq | %PAGER% cmd cmds !%lf% \-remote \(dqquery %id% cmds\(dq | %PAGER%
.EE .EE
.PP .PP
The defaults for Windows are using \f[CR]cmd\f[R] syntax.
A \f[CR]PowerShell\f[R] compatible configuration file can be found at \c
.UR https://github.com/gokcehan/lf/blob/master/etc/lfrc.ps1.example
.UE \c
.PP
The following additional keybindings are provided by default: The following additional keybindings are provided by default:
.IP .IP
.EX .EX
@@ -327,7 +333,7 @@ Left mouse button
Click on a file or directory to select it. Click on a file or directory to select it.
Right mouse button Right mouse button
Enter a directory or open a file. Also works on the preview window. Enter a directory or open a file. Also works on the preview pane.
Scroll wheel Scroll wheel
Move up or down. If Ctrl is pressed, scroll up or down. Move up or down. If Ctrl is pressed, scroll up or down.
@@ -400,9 +406,11 @@ Unix
Windows Windows
%LF_CONFIG_HOME% %LF_CONFIG_HOME%
%XDG_CONFIG_HOME%
%APPDATA% %APPDATA%
%LF_DATA_HOME% %LF_DATA_HOME%
%XDG_DATA_HOME%
%LOCALAPPDATA% %LOCALAPPDATA%
.EE .EE
.PP .PP
@@ -493,14 +501,14 @@ Read a shell command to execute.
Read a shell command to execute piping its standard I/O to the bottom Read a shell command to execute piping its standard I/O to the bottom
statline. statline.
.SS shell\-wait (modal) (default \f[CR]!\f[R]) .SS shell\-wait (modal) (default \f[CR]!\f[R])
Read a shell command to execute and wait for a key press in the end. Read a shell command to execute and wait for a key press at the end.
.SS shell\-async (modal) (default \f[CR]&\f[R]) .SS shell\-async (modal) (default \f[CR]&\f[R])
Read a shell command to execute asynchronously without standard I/O. Read a shell command to execute asynchronously without standard I/O.
.SS find (modal) (default \f[CR]f\f[R]), find\-back (modal) (default \f[CR]F\f[R]), find\-next (default \f[CR];\f[R]), find\-prev (default \f[CR],\f[R]) .SS find (modal) (default \f[CR]f\f[R]), find\-back (modal) (default \f[CR]F\f[R]), find\-next (default \f[CR];\f[R]), find\-prev (default \f[CR],\f[R])
Read key(s) to find the appropriate file name match in the Read key(s) to find the appropriate filename match in the
forward/backward direction and jump to the next/previous match. forward/backward direction and jump to the next/previous match.
.SS search (default \f[CR]/\f[R]), search\-back (default \f[CR]?\f[R]), search\-next (default \f[CR]n\f[R]), search\-prev (default \f[CR]N\f[R]) .SS search (default \f[CR]/\f[R]), search\-back (default \f[CR]?\f[R]), search\-next (default \f[CR]n\f[R]), search\-prev (default \f[CR]N\f[R])
Read a pattern to search for a file name match in the forward/backward Read a pattern to search for a filename match in the forward/backward
direction and jump to the next/previous match. direction and jump to the next/previous match.
.SS filter (modal), setfilter .SS filter (modal), setfilter
Command \f[CR]filter\f[R] reads a pattern to filter out and only view Command \f[CR]filter\f[R] reads a pattern to filter out and only view
@@ -524,7 +532,7 @@ You can define a new tag\-clearing command by combining \f[CR]tag\f[R]
with \f[CR]tag\-toggle\f[R] (i.e. with \f[CR]tag\-toggle\f[R] (i.e.
\f[CR]cmd tag\-clear :tag; tag\-toggle\f[R]). \f[CR]cmd tag\-clear :tag; tag\-toggle\f[R]).
.SS tag\-toggle (default \f[CR]t\f[R]) .SS tag\-toggle (default \f[CR]t\f[R])
Tag a file with \f[CR]*\f[R] or a single width character given in the Tag a file with \f[CR]*\f[R] or a single\-width character given in the
argument if the file is untagged, otherwise remove the tag. argument if the file is untagged, otherwise remove the tag.
.SS echo .SS echo
Print the given arguments to the message line at the bottom. Print the given arguments to the message line at the bottom.
@@ -601,7 +609,7 @@ You can go back with \f[CR]cmd\-delete\-back\f[R]
The command line commands should be mostly compatible with readline The command line commands should be mostly compatible with readline
keybindings. keybindings.
A character refers to a Unicode code point, a word consists of letters A character refers to a Unicode code point, a word consists of letters
and digits, and a unix word consists of any non\-blank characters. and digits, and a Unix word consists of any non\-blank characters.
.SS cmd\-insert .SS cmd\-insert
Insert the character given in the argument. Insert the character given in the argument.
This command is automatically called when required. This command is automatically called when required.
@@ -637,7 +645,7 @@ When at the beginning of a prompt, returns either to Normal mode or to
.SS cmd\-delete\-home (default \f[CR]<c\-u>\f[R]), cmd\-delete\-end (default \f[CR]<c\-k>\f[R]) .SS cmd\-delete\-home (default \f[CR]<c\-u>\f[R]), cmd\-delete\-end (default \f[CR]<c\-k>\f[R])
Delete everything up to the beginning/end of the line. Delete everything up to the beginning/end of the line.
.SS cmd\-delete\-unix\-word (default \f[CR]<c\-w>\f[R]) .SS cmd\-delete\-unix\-word (default \f[CR]<c\-w>\f[R])
Delete the previous unix word. Delete the previous Unix word.
.SS cmd\-yank (default \f[CR]<c\-y>\f[R]) .SS cmd\-yank (default \f[CR]<c\-y>\f[R])
Paste the buffer content containing the last deleted item. Paste the buffer content containing the last deleted item.
.SS cmd\-transpose (default \f[CR]<c\-t>\f[R]), cmd\-transpose\-word (default \f[CR]<a\-t>\f[R]) .SS cmd\-transpose (default \f[CR]<c\-t>\f[R]), cmd\-transpose\-word (default \f[CR]<a\-t>\f[R])
@@ -657,8 +665,8 @@ Character \f[CR]:\f[R] is used as the separator for list options
\f[CR][]int\f[R] and \f[CR][]string\f[R]. \f[CR][]int\f[R] and \f[CR][]string\f[R].
.SS anchorfind (bool) (default true) .SS anchorfind (bool) (default true)
When this option is enabled, the find command starts matching patterns When this option is enabled, the find command starts matching patterns
from the beginning of file names, otherwise, it can match at an from the beginning of filenames, otherwise, it can match at an arbitrary
arbitrary position. position.
.SS autoquit (bool) (default true) .SS autoquit (bool) (default true)
Automatically quit the server when there are no clients left connected. Automatically quit the server when there are no clients left connected.
.SS borderfmt (string) (default \f[CR]\(rs033[0m\f[R]) .SS borderfmt (string) (default \f[CR]\(rs033[0m\f[R])
@@ -669,14 +677,14 @@ Set the path of a cleaner file.
The file should be executable. The file should be executable.
This file is called if previewing is enabled, the previewer is set, and This file is called if previewing is enabled, the previewer is set, and
the previously selected file has its preview cache disabled. the previously selected file has its preview cache disabled.
The following arguments are passed to the file, (1) current file name, The following arguments are passed to the file, (1) current filename,
(2) width, (3) height, (4) horizontal position, (5) vertical position of (2) width, (3) height, (4) horizontal position, (5) vertical position of
preview pane and (6) next file name to be previewed respectively. preview pane and (6) next filename to be previewed respectively.
Preview cleaning is disabled when the value of this option is left Preview cleaning is disabled when the value of this option is left
empty. empty.
.SS copyfmt (string) (default \f[CR]\(rs033[7;33m\f[R]) .SS copyfmt (string) (default \f[CR]\(rs033[7;33m\f[R])
Format string of the indicator for files to be copied. Format string of the indicator for files to be copied.
.SS cursoractivefmt (string) (default \f[CR]\(rs033[7m\f[R]), cursorparentfmt string (default \f[CR]\(rs033[7m\f[R]), cursorpreviewfmt string (default \f[CR]\(rs033[4m\f[R]) .SS cursoractivefmt (string) (default \f[CR]\(rs033[7m\f[R]), cursorparentfmt (string) (default \f[CR]\(rs033[7m\f[R]), cursorpreviewfmt (string) (default \f[CR]\(rs033[4m\f[R])
Format strings for highlighting the cursor. Format strings for highlighting the cursor.
\f[CR]cursoractivefmt\f[R] applies in the current directory pane, \f[CR]cursoractivefmt\f[R] applies in the current directory pane,
\f[CR]cursorparentfmt\f[R] applies in panes that show parents of the \f[CR]cursorparentfmt\f[R] applies in panes that show parents of the
@@ -699,8 +707,6 @@ For example, \f[CR]\(rs033[4m%s\(rs033[0m\f[R] has the same effect as
\f[CR]\(rs033[4m\f[R]. \f[CR]\(rs033[4m\f[R].
.SS cutfmt (string) (default \f[CR]\(rs033[7;31m\f[R]) .SS cutfmt (string) (default \f[CR]\(rs033[7;31m\f[R])
Format string of the indicator for files to be cut. Format string of the indicator for files to be cut.
.SS dircache (bool) (default true)
Cache directory contents.
.SS dircounts (bool) (default false) .SS dircounts (bool) (default false)
When this option is enabled, directory sizes show the number of items When this option is enabled, directory sizes show the number of items
inside instead of the total size of the directory, which needs to be inside instead of the total size of the directory, which needs to be
@@ -725,12 +731,12 @@ This allows custom previews for directories.
.SS drawbox (bool) (default false) .SS drawbox (bool) (default false)
Draw boxes around panes with box drawing characters. Draw boxes around panes with box drawing characters.
.SS dupfilefmt (string) (default \f[CR]%f.\(ti%n\(ti\f[R]) .SS dupfilefmt (string) (default \f[CR]%f.\(ti%n\(ti\f[R])
Format string of file name when creating duplicate files. Format string of filename when creating duplicate files.
With the default format, copying a file \f[CR]abc.txt\f[R] to the same With the default format, copying a file \f[CR]abc.txt\f[R] to the same
directory will result in a duplicate file called directory will result in a duplicate file called
\f[CR]abc.txt.\(ti1\(ti\f[R]. \f[CR]abc.txt.\(ti1\(ti\f[R].
Special expansions are provided, \f[CR]%f\f[R] as the file name, Special expansions are provided, \f[CR]%f\f[R] as the file name,
\f[CR]%b\f[R] for the basename (file name without extension), \f[CR]%b\f[R] for the base name (file name without extension),
\f[CR]%e\f[R] as the extension (including the dot) and \f[CR]%n\f[R] as \f[CR]%e\f[R] as the extension (including the dot) and \f[CR]%n\f[R] as
the number of duplicates. the number of duplicates.
.SS errorfmt (string) (default \f[CR]\(rs033[7;31;47m\f[R]) .SS errorfmt (string) (default \f[CR]\(rs033[7;31;47m\f[R])
@@ -747,8 +753,8 @@ File separator used in environment variables \f[CR]fs\f[R],
.SS filtermethod (string) (default \f[CR]text\f[R]) .SS filtermethod (string) (default \f[CR]text\f[R])
How filter command patterns are treated. How filter command patterns are treated.
Currently supported methods are \f[CR]text\f[R] (i.e. Currently supported methods are \f[CR]text\f[R] (i.e.
string literals), \f[CR]glob\f[R] (i.e shell globs) and \f[CR]regex\f[R] string literals), \f[CR]glob\f[R] (i.e.
(i.e. shell globs) and \f[CR]regex\f[R] (i.e.
regular expressions). regular expressions).
See \f[CR]SEARCHING FILES\f[R] for more details. See \f[CR]SEARCHING FILES\f[R] for more details.
.SS findlen (int) (default 1) .SS findlen (int) (default 1)
@@ -796,12 +802,21 @@ Jump to the first match after each keystroke during searching.
.SS info ([]string) (default \(ga\(ga) .SS info ([]string) (default \(ga\(ga)
A list of information that is shown for directory items at the right A list of information that is shown for directory items at the right
side of the pane. side of the pane.
Currently supported information types are \f[CR]size\f[R], .PP
\f[CR]time\f[R], \f[CR]atime\f[R], \f[CR]btime\f[R], \f[CR]ctime\f[R], The following information types are supported:
\f[CR]perm\f[R], \f[CR]user\f[R], \f[CR]group\f[R] and .IP
\f[CR]custom\f[R]. .EX
The \f[CR]custom\f[R] type is empty by default and can be updated using perm file permission
the \f[CR]addcustominfo\f[R] command. user user name
group group name
size file size
time time of last data modification
atime time of last access
btime time of file birth
ctime time of last status (inode) change
custom property defined via \(gaaddcustominfo\(ga (empty by default)
.EE
.PP
Information is only shown when the pane width is more than twice the Information is only shown when the pane width is more than twice the
width of information. width of information.
.SS infotimefmtnew (string) (default \f[CR]Jan _2 15:04\f[R]) .SS infotimefmtnew (string) (default \f[CR]Jan _2 15:04\f[R])
@@ -810,14 +825,12 @@ this year.
.SS infotimefmtold (string) (default \f[CR]Jan _2 2006\f[R]) .SS infotimefmtold (string) (default \f[CR]Jan _2 2006\f[R])
Format string of the file time shown in the info column when it Format string of the file time shown in the info column when it
doesn\(aqt match this year. doesn\(aqt match this year.
.SS locale (string) (default \(ga\(ga) .SS menufmt (string) (default \f[CR]\(rs033[0m\f[R])
An IETF BCP 47 language tag (e.g. Format string of the menu.
\f[CR]zh\-CN\f[R]) for specifying the locale used when using sort type .SS menuheaderfmt (string) (default \f[CR]\(rs033[1m\f[R])
\f[CR]natural\f[R] and \f[CR]name\f[R]. Format string of the header row in the menu.
An empty string means disable locale ordering, and the special value .SS menuselectfmt (string) (default \f[CR]\(rs033[7m\f[R])
\f[CR]*\f[R] is used to indicate reading the locale setting from the Format string of the currently selected item in the menu.
system environment.
This feature is currently experimental.
.SS mouse (bool) (default false) .SS mouse (bool) (default false)
Send mouse events as input. Send mouse events as input.
.SS number (bool) (default false) .SS number (bool) (default false)
@@ -853,7 +866,7 @@ considered binary files and displayed as \f[CR]binary\f[R].
Set the path of a previewer file to filter the content of regular files Set the path of a previewer file to filter the content of regular files
for previewing. for previewing.
The file should be executable. The file should be executable.
The following arguments are passed to the file, (1) current file name, The following arguments are passed to the file, (1) current filename,
(2) width, (3) height, (4) horizontal position, and (5) vertical (2) width, (3) height, (4) horizontal position, and (5) vertical
position of preview pane respectively. position of preview pane respectively.
SIGPIPE signal is sent when enough lines are read. SIGPIPE signal is sent when enough lines are read.
@@ -865,12 +878,19 @@ Preview filtering is disabled and files are displayed as they are when
the value of this option is left empty. the value of this option is left empty.
.SS promptfmt (string) (default \f[CR]\(rs033[32;1m%u\(at%h\(rs033[0m:\(rs033[34;1m%d\(rs033[0m\(rs033[1m%f\(rs033[0m\f[R]) .SS promptfmt (string) (default \f[CR]\(rs033[32;1m%u\(at%h\(rs033[0m:\(rs033[34;1m%d\(rs033[0m\(rs033[1m%f\(rs033[0m\f[R])
Format string of the prompt shown in the top line. Format string of the prompt shown in the top line.
Special expansions are provided, \f[CR]%u\f[R] as the user name, .PP
\f[CR]%h\f[R] as the hostname, \f[CR]%w\f[R] as the working directory, The following special expansions are supported:
\f[CR]%d\f[R] as the working directory with a trailing path separator, .IP
\f[CR]%f\f[R] as the file name, and \f[CR]%F\f[R] as the current filter. .EX
\f[CR]%S\f[R] may be used once and will provide a spacer so that the %f file name
following parts are right aligned on the screen. %h host name
%u user name
%w working directory
%d working directory (with trailing path separator)
%F current filter
%S spacer to right\-align the following parts (can be used once)
.EE
.PP
The home folder is shown as \f[CR]\(ti\f[R] in the working directory The home folder is shown as \f[CR]\(ti\f[R] in the working directory
expansion. expansion.
Directory names are automatically shortened to a single character Directory names are automatically shortened to a single character
@@ -892,16 +912,24 @@ Draw rounded outer corners when the \f[CR]drawbox\f[R] option is
enabled. enabled.
.SS rulerfmt (string) (default \f[CR] %a| %p| \(rs033[7;31m %m \(rs033[0m| \(rs033[7;33m %c \(rs033[0m| \(rs033[7;35m %s \(rs033[0m| \(rs033[7;36m %v \(rs033[0m| \(rs033[7;34m %f \(rs033[0m| %i/%t\f[R]) .SS rulerfmt (string) (default \f[CR] %a| %p| \(rs033[7;31m %m \(rs033[0m| \(rs033[7;33m %c \(rs033[0m| \(rs033[7;35m %s \(rs033[0m| \(rs033[7;36m %v \(rs033[0m| \(rs033[7;34m %f \(rs033[0m| %i/%t\f[R])
Format string of the ruler shown in the bottom right corner. Format string of the ruler shown in the bottom right corner.
Special expansions are provided, \f[CR]%a\f[R] as the pressed keys, .PP
\f[CR]%p\f[R] as the progress of file operations, \f[CR]%m\f[R] as the The following special expansions are supported:
number of files to be cut (moved), \f[CR]%c\f[R] as the number of files .IP
to be copied, \f[CR]%s\f[R] as the number of selected files, .EX
\f[CR]%v\f[R] as the number of visually selected files, \f[CR]%f\f[R] as %a pressed keys
the filter, \f[CR]%i\f[R] as the position of the cursor, \f[CR]%t\f[R] %p progress of file operations
as the number of files shown in the current directory, \f[CR]%h\f[R] as %m number of files to be cut (moved)
the number of files hidden in the current directory, \f[CR]%P\f[R] as %c number of files to be copied
the scroll percentage, and \f[CR]%d\f[R] as the amount of free disk %s number of selected files
space remaining. %v number of visually selected files
%t number of shown files in the current directory
%h number of hidden files in the current directory
%f current filter
%i cursor position
%P scroll percentage
%d amount of free disk space
.EE
.PP
Additional expansions are provided for environment variables exported by Additional expansions are provided for environment variables exported by
lf, in the form \f[CR]%{lf_<name>}\f[R] (e.g. lf, in the form \f[CR]%{lf_<name>}\f[R] (e.g.
\f[CR]%{lf_selmode}\f[R]). \f[CR]%{lf_selmode}\f[R]).
@@ -916,14 +944,14 @@ discarded and not shown.
Minimum number of offset lines shown at all times at the top and bottom Minimum number of offset lines shown at all times at the top and bottom
of the screen when scrolling. of the screen when scrolling.
The current line is kept in the middle when this option is set to a The current line is kept in the middle when this option is set to a
large value that is bigger than the half of number of lines. large value that is bigger than half the number of lines.
A smaller offset can be used when the current file is close to the A smaller offset can be used when the current file is close to the
beginning or end of the list to show the maximum number of items. beginning or end of the list to show the maximum number of items.
.SS searchmethod (string) default \f[CR]text\f[R]) .SS searchmethod (string) (default \f[CR]text\f[R])
How search command patterns are treated. How search command patterns are treated.
Currently supported methods are \f[CR]text\f[R] (i.e. Currently supported methods are \f[CR]text\f[R] (i.e.
string literals), \f[CR]glob\f[R] (i.e shell globs) and \f[CR]regex\f[R] string literals), \f[CR]glob\f[R] (i.e.
(i.e. shell globs) and \f[CR]regex\f[R] (i.e.
regular expressions). regular expressions).
See \f[CR]SEARCHING FILES\f[R] for more details. See \f[CR]SEARCHING FILES\f[R] for more details.
.SS selectfmt (string) (default \f[CR]\(rs033[7;35m\f[R]) .SS selectfmt (string) (default \f[CR]\(rs033[7;35m\f[R])
@@ -944,8 +972,10 @@ Command line flag used to pass shell commands.
List of shell options to pass to the shell executable. List of shell options to pass to the shell executable.
.SS showbinds (bool) (default true) .SS showbinds (bool) (default true)
Show bindings associated with pressed keys. Show bindings associated with pressed keys.
.SS sixel (bool) (default false) .SS sizeunits (string) (default \f[CR]binary\f[R])
Render sixel images in preview. Determines whether file sizes are displayed using binary units
(\f[CR]1K\f[R] is 1024 bytes) or decimal units (\f[CR]1K\f[R] is 1000
bytes).
.SS smartcase (bool) (default true) .SS smartcase (bool) (default true)
Override \f[CR]ignorecase\f[R] option when the pattern contains an Override \f[CR]ignorecase\f[R] option when the pattern contains an
uppercase character. uppercase character.
@@ -956,41 +986,41 @@ character with diacritic.
This option has no effect when \f[CR]ignoredia\f[R] is disabled. This option has no effect when \f[CR]ignoredia\f[R] is disabled.
.SS sortby (string) (default \f[CR]natural\f[R]) .SS sortby (string) (default \f[CR]natural\f[R])
Sort type for directories. Sort type for directories.
Currently supported sort types are \f[CR]natural\f[R], \f[CR]name\f[R],
\f[CR]size\f[R], \f[CR]time\f[R], \f[CR]atime\f[R], \f[CR]btime\f[R],
\f[CR]ctime\f[R], \f[CR]ext\f[R] and \f[CR]custom\f[R].
.PP .PP
Meaning of each sort type: The following sort types are supported:
.IP .IP
.EX .EX
natural file name (track_2.flac comes before track_10.flac) natural file name (track_2.flac comes before track_10.flac)
name file name (track_10.flac comes before track_2.flac) name file name (track_10.flac comes before track_2.flac)
ext file extension
size file size size file size
time time of last data modification time time of last data modification
atime time of last access atime time of last access
btime time of file birth btime time of file birth
ctime time of last status (inode) change ctime time of last status (inode) change
ext file extension custom property defined via \(gaaddcustominfo\(ga (empty by default)
custom property defined via \(gaaddcustominfo\(ga
.EE .EE
.SS statfmt (string) (default \f[CR]\(rs033[36m%p\(rs033[0m| %c| %u| %g| %S| %t| \-> %l\f[R]) .SS statfmt (string) (default \f[CR]\(rs033[36m%p\(rs033[0m| %c| %u| %g| %S| %t| \-> %l\f[R])
Format string of the file info shown in the bottom left corner. Format string of the file info shown in the bottom left corner.
Special expansions are provided, \f[CR]%p\f[R] as the file permissions, .PP
\f[CR]%c\f[R] as the link count, \f[CR]%u\f[R] as the user, The following special expansions are supported:
\f[CR]%g\f[R] as the group, \f[CR]%s\f[R] as the file size, .IP
\f[CR]%S\f[R] as the file size but with a fixed width of five characters .EX
(left\-padded with spaces), \f[CR]%t\f[R] as the last modified time, %p file permission
\f[CR]%l\f[R] as the link target, \f[CR]%m\f[R] as the current mode and %c link count
\f[CR]%M\f[R] as the current mode but also shown in Normal mode %u user name
(displaying \f[CR]NORMAL\f[R] instead of a blank string). %g group name
%s file size
%S file size (left\-padded with spaces to a fixed width of 5 characters)
%t time of last data modification
%l link target
%m current mode
%M current mode (displaying \(gaNORMAL\(ga instead of a blank string in Normal mode)
.EE
.PP .PP
The \f[CR]|\f[R] character splits the format string into sections. The \f[CR]|\f[R] character splits the format string into sections.
Any section containing a failed expansion (result is a blank string) is Any section containing a failed expansion (result is a blank string) is
discarded and not shown. discarded and not shown.
.PP
File size is formatted using first letter of IEC 80000\-13:2025 prefixes
for binary multiples (i.e.
1024 bytes is \f[CR]1.0K\f[R]).
.SS tabstop (int) (default 8) .SS tabstop (int) (default 8)
Number of space characters to show for horizontal tabulation (U+0009) Number of space characters to show for horizontal tabulation (U+0009)
character. character.
@@ -1013,7 +1043,7 @@ temporary and it does not need to be specified.
.SS timefmt (string) (default \f[CR]Mon Jan _2 15:04:05 2006\f[R]) .SS timefmt (string) (default \f[CR]Mon Jan _2 15:04:05 2006\f[R])
Format string of the file modification time shown in the bottom line. Format string of the file modification time shown in the bottom line.
.SS truncatechar (string) (default \f[CR]\(ti\f[R]) .SS truncatechar (string) (default \f[CR]\(ti\f[R])
The truncate character that is shown at the end when the file name does The truncate character that is shown at the end when the filename does
not fit into the pane. not fit into the pane.
.SS truncatepct (int) (default 100) .SS truncatepct (int) (default 100)
When a filename is too long to be shown completely, the available space When a filename is too long to be shown completely, the available space
@@ -1090,7 +1120,7 @@ in your shell configuration file (e.g.
.SS OPENER .SS OPENER
If this variable is set in the environment, use the same value. If this variable is set in the environment, use the same value.
Otherwise, this is set to \f[CR]start\f[R] in Windows, \f[CR]open\f[R] Otherwise, this is set to \f[CR]start\f[R] in Windows, \f[CR]open\f[R]
in MacOS, \f[CR]xdg\-open\f[R] in others. in macOS, \f[CR]xdg\-open\f[R] in others.
.SS EDITOR .SS EDITOR
If VISUAL is set in the environment, use its value. If VISUAL is set in the environment, use its value.
Otherwise, use the value of the environment variable EDITOR. Otherwise, use the value of the environment variable EDITOR.
@@ -1171,7 +1201,7 @@ This shell command can be defined to be executed before quitting.
The following command prefixes are used by lf: The following command prefixes are used by lf:
.IP .IP
.EX .EX
: read (default) builtin/custom command : read (default) built\-in/custom command
$ shell shell command $ shell shell command
% shell\-pipe shell command running with the UI % shell\-pipe shell command running with the UI
! shell\-wait shell command waiting for a key press ! shell\-wait shell command waiting for a key press
@@ -1206,8 +1236,8 @@ set nohidden # boolean disable
set hidden false # boolean disable set hidden false # boolean disable
set hidden! # boolean toggle set hidden! # boolean toggle
set scrolloff 10 # integer value set scrolloff 10 # integer value
set sortby time # string value w/o quotes set sortby time # string value without quotes
set sortby \(aqtime\(aq # string value with single quotes (whitespaces) set sortby \(aqtime\(aq # string value with single quotes (whitespace)
set sortby \(dqtime\(dq # string value with double quotes (backslash escapes) set sortby \(dqtime\(dq # string value with double quotes (backslash escapes)
.EE .EE
.PP .PP
@@ -1215,8 +1245,7 @@ Command \f[CR]setlocal\f[R] is used to set a local option for a
directory which can be a boolean or string. directory which can be a boolean or string.
Currently supported local options are \f[CR]dircounts\f[R], Currently supported local options are \f[CR]dircounts\f[R],
\f[CR]dirfirst\f[R], \f[CR]dironly\f[R], \f[CR]hidden\f[R], \f[CR]dirfirst\f[R], \f[CR]dironly\f[R], \f[CR]hidden\f[R],
\f[CR]info\f[R], \f[CR]locale\f[R], \f[CR]reverse\f[R] and \f[CR]info\f[R], \f[CR]reverse\f[R] and \f[CR]sortby\f[R].
\f[CR]sortby\f[R].
Adding a trailing path separator (i.e. Adding a trailing path separator (i.e.
\f[CR]/\f[R] for Unix and \f[CR]\(rs\f[R] for Windows) sets the option \f[CR]/\f[R] for Unix and \f[CR]\(rs\f[R] for Windows) sets the option
for the given directory along with its subdirectories: for the given directory along with its subdirectories:
@@ -1227,19 +1256,19 @@ setlocal /foo/bar hidden true # boolean enable
setlocal /foo/bar nohidden # boolean disable setlocal /foo/bar nohidden # boolean disable
setlocal /foo/bar hidden false # boolean disable setlocal /foo/bar hidden false # boolean disable
setlocal /foo/bar hidden! # boolean toggle setlocal /foo/bar hidden! # boolean toggle
setlocal /foo/bar sortby time # string value w/o quotes setlocal /foo/bar sortby time # string value without quotes
setlocal /foo/bar sortby \(aqtime\(aq # string value with single quotes (whitespaces) setlocal /foo/bar sortby \(aqtime\(aq # string value with single quotes (whitespace)
setlocal /foo/bar sortby \(dqtime\(dq # string value with double quotes (backslash escapes) setlocal /foo/bar sortby \(dqtime\(dq # string value with double quotes (backslash escapes)
setlocal /foo/bar hidden # for only \(aq/foo/bar\(aq directory setlocal /foo/bar hidden # for only \(aq/foo/bar\(aq directory
setlocal /foo/bar/ hidden # for \(aq/foo/bar\(aq and its subdirectories (e.g. \(aq/foo/bar/baz\(aq) setlocal /foo/bar/ hidden # for \(aq/foo/bar\(aq and its subdirectories (e.g. \(aq/foo/bar/baz\(aq)
.EE .EE
.PP .PP
Command \f[CR]map\f[R] is used to bind a key in Normal and Visual mode Command \f[CR]map\f[R] is used to bind a key in Normal and Visual mode
to a command which can be a builtin command, custom command, or shell to a command which can be a built\-in command, custom command, or shell
command: command:
.IP .IP
.EX .EX
map gh cd \(ti # builtin command map gh cd \(ti # built\-in command
map D trash # custom command map D trash # custom command
map i $less $f # shell command map i $less $f # shell command
map U !du \-csh * # waiting shell command map U !du \-csh * # waiting shell command
@@ -1317,7 +1346,7 @@ Regular keys are assigned to a command with the usual syntax:
map a down map a down
.EE .EE
.PP .PP
Keys combined with the shift key simply use the uppercase letter: Keys combined with the Shift key simply use the uppercase letter:
.IP .IP
.EX .EX
map A down map A down
@@ -1343,17 +1372,17 @@ Function keys are prefixed with \f[CR]f\f[R] character:
map <f\-1> down map <f\-1> down
.EE .EE
.PP .PP
Keys combined with the control key are prefixed with a \f[CR]c\f[R] Keys combined with the Ctrl key are prefixed with a \f[CR]c\f[R]
character: character:
.IP .IP
.EX .EX
map <c\-a> down map <c\-a> down
.EE .EE
.PP .PP
Keys combined with the alt key are assigned in two different ways Keys combined with the Alt key are assigned in two different ways
depending on the behavior of your terminal. depending on the behavior of your terminal.
Older terminals (e.g. Older terminals (e.g.
xterm) may set the 8th bit of a character when the alt key is pressed. xterm) may set the 8th bit of a character when the Alt key is pressed.
On these terminals, you can use the corresponding byte for the mapping: On these terminals, you can use the corresponding byte for the mapping:
.IP .IP
.EX .EX
@@ -1361,11 +1390,11 @@ map á down
.EE .EE
.PP .PP
Newer terminals (e.g. Newer terminals (e.g.
gnome\-terminal) may prefix the key with an escape key when the alt key gnome\-terminal) may prefix the key with an escape character when the
is pressed. Alt key is pressed.
lf uses the escape delaying mechanism to recognize alt keys in these lf uses the escape delaying mechanism to recognize Alt keys in these
terminals (delay is 100ms). terminals (delay is 100ms).
On these terminals, keys combined with the alt key are prefixed with an On these terminals, keys combined with the Alt key are prefixed with an
\f[CR]a\f[R] character: \f[CR]a\f[R] character:
.IP .IP
.EX .EX
@@ -1505,7 +1534,7 @@ the rest of the documentation.
.SH PIPING SHELL COMMANDS .SH PIPING SHELL COMMANDS
Regular shell commands have some limitations in some cases. Regular shell commands have some limitations in some cases.
When an output or error message is given and the command exits When an output or error message is given and the command exits
afterwards, the ui is immediately resumed and there is no way to see the afterwards, the UI is immediately resumed and there is no way to see the
message without dropping to shell again. message without dropping to shell again.
Also, even when there is no output or error, the UI still needs to be Also, even when there is no output or error, the UI still needs to be
paused while the command is running. paused while the command is running.
@@ -1518,15 +1547,15 @@ This can be useful for programs following the Unix philosophy to give no
output in the success case, and brief error messages or prompts in other output in the success case, and brief error messages or prompts in other
cases. cases.
.PP .PP
For example, following rename command prompts for overwrite in the For example, the following rename command prompts for overwrite in the
statline if there is an existing file with the given name: statline if there is an existing file with the given name:
.IP .IP
.EX .EX
cmd rename %mv \-i $f $1 cmd rename %mv \-i $f $1
.EE .EE
.PP .PP
You can also output error messages in the command and it will show up in You can also output error messages in the command and they will show up
the statline. in the statline.
For example, an alternative rename command may look like this: For example, an alternative rename command may look like this:
.IP .IP
.EX .EX
@@ -1585,7 +1614,7 @@ client:
lf \-remote \(aqsend 1234 echo hello world\(aq lf \-remote \(aqsend 1234 echo hello world\(aq
.EE .EE
.PP .PP
All clients have a unique id number but you may not be aware of the id All clients have a unique ID number but you may not be aware of the ID
number when you are writing a command. number when you are writing a command.
For this purpose, an \f[CR]$id\f[R] variable is exported to the For this purpose, an \f[CR]$id\f[R] variable is exported to the
environment for shell commands. environment for shell commands.
@@ -1617,7 +1646,7 @@ cmd recol %{{
.EE .EE
.PP .PP
In addition, the \f[CR]query\f[R] command can be used to obtain In addition, the \f[CR]query\f[R] command can be used to obtain
information about a specific lf instance by providing its id: information about a specific lf instance by providing its ID:
.IP .IP
.EX .EX
lf \-remote \(dqquery $id maps\(dq lf \-remote \(dqquery $id maps\(dq
@@ -1690,7 +1719,7 @@ Moving is performed using the rename operation of the underlying OS.
For cross\-device moving, lf falls back to copying and then deletes the For cross\-device moving, lf falls back to copying and then deletes the
original files if there are no errors. original files if there are no errors.
Operation errors are shown in the message line as well as the log file Operation errors are shown in the message line as well as the log file
and they do not preemptively finish the corresponding file operation. and they do not prematurely terminate the corresponding file operation.
.PP .PP
File operations can be performed on the currently selected file or on File operations can be performed on the currently selected file or on
multiple files by selecting them first. multiple files by selecting them first.
@@ -1785,13 +1814,13 @@ only a single match.
The default values of these two options are set to jump to the first The default values of these two options are set to jump to the first
file with the given initial. file with the given initial.
.PP .PP
Some options effect both searching and finding. Some options affect both searching and finding.
You can disable \f[CR]wrapscan\f[R] option to prevent searches from You can disable \f[CR]wrapscan\f[R] option to prevent searches from
being wrapped around at the end of the file list. being wrapped around at the end of the file list.
You can disable \f[CR]ignorecase\f[R] option to match cases in the You can disable \f[CR]ignorecase\f[R] option to match cases in the
pattern and the filename. pattern and the filename.
This option is already automatically overridden if the pattern contains This option is already automatically overridden if the pattern contains
upper\-case characters. uppercase characters.
You can disable \f[CR]smartcase\f[R] option to disable this behavior. You can disable \f[CR]smartcase\f[R] option to disable this behavior.
Two similar options \f[CR]ignoredia\f[R] and \f[CR]smartdia\f[R] are Two similar options \f[CR]ignoredia\f[R] and \f[CR]smartdia\f[R] are
provided to control matching diacritics in Latin letters. provided to control matching diacritics in Latin letters.
@@ -1812,7 +1841,7 @@ It is possible to use different command types:
cmd open &xdg\-open $f cmd open &xdg\-open $f
.EE .EE
.PP .PP
You may want to use either file extensions or mime types from You may want to use either file extensions or MIME types from
\f[CR]file\f[R] command: \f[CR]file\f[R] command:
.IP .IP
.EX .EX
@@ -1862,13 +1891,13 @@ lf previews files on the preview pane by printing the file until the end
or until the preview pane is filled. or until the preview pane is filled.
This output can be enhanced by providing a custom preview script for This output can be enhanced by providing a custom preview script for
filtering. filtering.
This can be used to highlight source codes, list contents of archive This can be used to highlight source code, list contents of archive
files or view PDF or image files to name a few. files or view PDF or image files to name a few.
For coloring lf recognizes ANSI escape codes. For coloring lf recognizes ANSI escape codes.
.PP .PP
To use this feature, you need to set the value of \f[CR]previewer\f[R] To use this feature, you need to set the value of \f[CR]previewer\f[R]
option to the path of an executable file. option to the path of an executable file.
Five arguments are passed to the file, (1) current file name, (2) width, Five arguments are passed to the file, (1) current filename, (2) width,
(3) height, (4) horizontal position, and (5) vertical position of (3) height, (4) horizontal position, and (5) vertical position of
preview pane respectively. preview pane respectively.
The output of the execution is printed in the preview pane. The output of the execution is printed in the preview pane.
@@ -1891,7 +1920,7 @@ map i $LESSOPEN=\(aq| \(ti/.config/lf/pv.sh %s\(aq less \-R $f
Since this script is called for each file selection change it needs to Since this script is called for each file selection change it needs to
be as efficient as possible and this responsibility is left to the user. be as efficient as possible and this responsibility is left to the user.
You may use file extensions to determine the type of file more You may use file extensions to determine the type of file more
efficiently compared to obtaining mime types from \f[CR]file\f[R] efficiently compared to obtaining MIME types from \f[CR]file\f[R]
command. command.
Extensions can then be used to match cleanly within a conditional: Extensions can then be used to match cleanly within a conditional:
.IP .IP
@@ -2059,7 +2088,7 @@ Colors are set in the following order:
.IP "1." 3 .IP "1." 3
default default
.IP "2." 3 .IP "2." 3
LSCOLORS (Mac/BSD ls) LSCOLORS (macOS/BSD ls)
.IP "3." 3 .IP "3." 3
LS_COLORS (GNU ls) LS_COLORS (GNU ls)
.IP "4." 3 .IP "4." 3
@@ -2242,7 +2271,7 @@ ex=01;32:\(rs
.PP .PP
The \f[CR]ln\f[R] entry supports the special value \f[CR]target\f[R], The \f[CR]ln\f[R] entry supports the special value \f[CR]target\f[R],
which will use the link target to select a style. which will use the link target to select a style.
File name rules will still apply based on the link\(aqs name \-\- this Filename rules will still apply based on the link\(aqs name \-\- this
mirrors GNU\(aqs \f[CR]ls\f[R] and \f[CR]dircolors\f[R] behavior. mirrors GNU\(aqs \f[CR]ls\f[R] and \f[CR]dircolors\f[R] behavior.
Having such a long variable definition in a shell configuration file Having such a long variable definition in a shell configuration file
might be undesirable. might be undesirable.
@@ -2265,11 +2294,11 @@ CONFIGURATION section
.UE \c .UE \c
). ).
The variable uses the same syntax as \f[CR]LS_COLORS/LF_COLORS\f[R]. The variable uses the same syntax as \f[CR]LS_COLORS/LF_COLORS\f[R].
Instead of colors, you should put a single characters as values of Instead of colors, you should use single characters or symbols as
entries. values.
The \f[CR]ln\f[R] entry supports the special value \f[CR]target\f[R], The \f[CR]ln\f[R] entry supports the special value \f[CR]target\f[R],
which will use the link target to select a icon. which will use the link target to select a icon.
File name rules will still apply based on the link\(aqs name \-\- this Filename rules will still apply based on the link\(aqs name \-\- this
mirrors GNU\(aqs \f[CR]ls\f[R] and \f[CR]dircolors\f[R] behavior. mirrors GNU\(aqs \f[CR]ls\f[R] and \f[CR]dircolors\f[R] behavior.
The icons file (refer to the \c The icons file (refer to the \c
.UR https://github.com/gokcehan/lf/blob/master/doc.md#configuration .UR https://github.com/gokcehan/lf/blob/master/doc.md#configuration
@@ -2277,14 +2306,12 @@ CONFIGURATION section
.UE \c .UE \c
) should consist of whitespace\-separated arrays with a \f[CR]#\f[R] ) should consist of whitespace\-separated arrays with a \f[CR]#\f[R]
character to start comments until the end of the line. character to start comments until the end of the line.
Each line should contain 1\-3 columns, first column is filetype or Each line should contain 1\-3 columns: a file type or file name pattern,
filename pattern, second column is the icon, third column is an optional the icon, and an optional icon color.
icon color. Using only one column disables all rules for that type or name.
If there is only one column, means to disable rule for this filetype or
pattern.
Do not forget to add \f[CR]set icons true\f[R] to your \f[CR]lfrc\f[R] Do not forget to add \f[CR]set icons true\f[R] to your \f[CR]lfrc\f[R]
to see the icons. to see the icons.
Default values are as follows given with their matching order in lf: Default values are listed below in the order lf matches them:
.IP .IP
.EX .EX
ln l ln l
+8 -8
View File
@@ -267,41 +267,41 @@ func main() {
remoteCmd := flag.String( remoteCmd := flag.String(
"remote", "remote",
"", "",
"send remote command to server") "send remote `command` to server")
cpuprofile := flag.String( cpuprofile := flag.String(
"cpuprofile", "cpuprofile",
"", "",
"path to the file to write the CPU profile") "`path` to the file to write the CPU profile")
memprofile := flag.String( memprofile := flag.String(
"memprofile", "memprofile",
"", "",
"path to the file to write the memory profile") "`path` to the file to write the memory profile")
flag.StringVar(&gLastDirPath, flag.StringVar(&gLastDirPath,
"last-dir-path", "last-dir-path",
"", "",
"path to the file to write the last dir on exit (to use for cd)") "`path` to the file to write the last dir on exit (to use for cd)")
flag.StringVar(&gSelectionPath, flag.StringVar(&gSelectionPath,
"selection-path", "selection-path",
"", "",
"path to the file to write selected files on open (to use as open file dialog)") "`path` to the file to write selected files on open (to use as open file dialog)")
flag.StringVar(&gConfigPath, flag.StringVar(&gConfigPath,
"config", "config",
"", "",
"path to the config file (instead of the usual paths)") "`path` to the config file (instead of the usual paths)")
flag.Var(&gCommands, flag.Var(&gCommands,
"command", "command",
"command to execute on client initialization") "`command` to execute on client initialization")
flag.StringVar(&gLogPath, flag.StringVar(&gLogPath,
"log", "log",
"", "",
"path to the log file to write messages") "`path` to the log file to write messages")
flag.Parse() flag.Parse()
+131 -74
View File
@@ -2,9 +2,11 @@ package main
import ( import (
"bufio" "bufio"
"bytes"
"fmt" "fmt"
"io" "io"
"io/fs" "io/fs"
"math/big"
"path/filepath" "path/filepath"
"regexp" "regexp"
"strconv" "strconv"
@@ -12,15 +14,20 @@ import (
"unicode" "unicode"
"unicode/utf8" "unicode/utf8"
"github.com/Xuanwo/go-locale" "github.com/gdamore/tcell/v2"
"github.com/mattn/go-runewidth" "github.com/mattn/go-runewidth"
"golang.org/x/text/collate"
"golang.org/x/text/language"
) )
const ( var (
localeStrDisable = "" // disable locale ordering for this locale value reModKey = regexp.MustCompile(`<(c|s|a)-(.+)>`)
localeStrSys = "*" // replace this locale value with locale value read from environment reRulerSub = regexp.MustCompile(`%[apmcsvfithPd]|%\{[^}]+\}`)
reSixelSize = regexp.MustCompile(`"1;1;(\d+);(\d+)`)
)
var (
reWord = regexp.MustCompile(`(\pL|\pN)+`)
reWordBeg = regexp.MustCompile(`([^\pL\pN]|^)(\pL|\pN)`)
reWordEnd = regexp.MustCompile(`(\pL|\pN)([^\pL\pN]|$)`)
) )
func isRoot(name string) bool { return filepath.Dir(name) == name } func isRoot(name string) bool { return filepath.Dir(name) == name }
@@ -236,39 +243,48 @@ func readPairs(r io.Reader) ([][]string, error) {
} }
// This function converts a size in bytes to a human readable form using // This function converts a size in bytes to a human readable form using
// prefixes for binary multiples (e.g., 1 KiB = 1024 B). The output should be // prefixes for either binary (1 KiB = 1024 B) or decimal (1 KB = 1000 B)
// no more than 5 characters long. // multiples. The output should be no more than 5 characters long.
func humanize(size uint64) string { func humanize(size uint64) string {
if size < 1024 { var base uint64 = 1024
if gOpts.sizeunits == "decimal" {
base = 1000
}
if size < base {
return fmt.Sprintf("%dB", size) return fmt.Sprintf("%dB", size)
} }
// Shortened (due to TUI space constraints) version of
// IEC 80000-13:2025 prefixes for binary multiples.
// *Note*: due to [`FileSize.Size()`](https://pkg.go.dev/io/fs#FileInfo) // *Note*: due to [`FileSize.Size()`](https://pkg.go.dev/io/fs#FileInfo)
// being `int64`, maximum possible representable value would be 8 EiB. // being `int64`, the maximum possible representable value would be 8 EiB or
// 9.2 EB.
prefixes := []string{ prefixes := []string{
"K", // kibi (2^10) "K", // kibi (2^10) or kilo (10^3)
"M", // mebi (2^20) "M", // mebi (2^20) or mega (10^6)
"G", // gibi (2^30) "G", // gibi (2^30) or giga (10^9)
"T", // tebi (2^40) "T", // tebi (2^40) or tera (10^2)
"P", // pebi (2^50) "P", // pebi (2^50) or peta (10^15)
"E", // exbi (2^60) "E", // exbi (2^60) or exa (10^18)
"Z", // zebi (2^70) "Z", // zebi (2^70) or zetta (10^21)
"Y", // yobi (2^80) "Y", // yobi (2^80) or yotta (10^24)
"R", // robi (2^90) "R", // robi (2^90) or ronna (10^27)
"Q", // quebi (2^100) "Q", // quebi (2^100) or quetta (10^30)
} }
curr := float64(size) / 1024 curr := big.NewRat(int64(size), int64(base))
for _, prefix := range prefixes { for _, prefix := range prefixes {
if curr < 99.95 { // if curr < 99.95 then round to 1 decimal place
return fmt.Sprintf("%.1f%s", curr, prefix) if curr.Cmp(big.NewRat(9995, 100)) < 0 {
return fmt.Sprintf("%s%s", curr.FloatString(1), prefix)
} }
if curr < 1023.5 {
return fmt.Sprintf("%.0f%s", curr, prefix) // if curr < base-0.5 then round to the nearest integer
if curr.Cmp(new(big.Rat).Sub(big.NewRat(int64(base), 1), big.NewRat(1, 2))) < 0 {
return fmt.Sprintf("%s%s", curr.FloatString(0), prefix)
} }
curr /= 1024
curr.Quo(curr, big.NewRat(int64(base), 1))
} }
return fmt.Sprintf("+999%s", prefixes[len(prefixes)-1]) return fmt.Sprintf("+999%s", prefixes[len(prefixes)-1])
@@ -331,52 +347,6 @@ func getFileExtension(file fs.FileInfo) string {
return filepath.Ext(file.Name()) return filepath.Ext(file.Name())
} }
var (
reModKey = regexp.MustCompile(`<(c|s|a)-(.+)>`)
reRulerSub = regexp.MustCompile(`%[apmcsvfithPd]|%\{[^}]+\}`)
reSixelSize = regexp.MustCompile(`"1;1;(\d+);(\d+)`)
)
var (
reWord = regexp.MustCompile(`(\pL|\pN)+`)
reWordBeg = regexp.MustCompile(`([^\pL\pN]|^)(\pL|\pN)`)
reWordEnd = regexp.MustCompile(`(\pL|\pN)([^\pL\pN]|$)`)
)
// This function parses given locale string into language tag value. Passing empty
// string as locale means reading locale value from environment.
func getLocaleTag(localeStr string) (language.Tag, error) {
if localeStr == localeStrSys {
// read environment locale
return locale.Detect()
}
localeTag, err := language.Parse(localeStr)
if err != nil {
return localeTag, fmt.Errorf("invalid locale %q: %s", localeStr, err)
}
return localeTag, nil
}
// This function creates new collator for given locale. Passing empty string as
// as locale means reading locale value from environment.
//
// *Note*: this function returns error when given `localeStr` has value `localeStrDisable`
// or is an invalid locale tag.
func makeCollator(localeStr string, opts ...collate.Option) (*collate.Collator, error) {
if localeStr == localeStrDisable {
return nil, fmt.Errorf("locale is disabled")
}
localeTag, err := getLocaleTag(localeStr)
if err != nil {
return nil, err
}
return collate.New(localeTag, opts...), nil
}
// This function deletes entries from a map if the key is either the given path // This function deletes entries from a map if the key is either the given path
// or a subpath of it. // or a subpath of it.
// This is useful for clearing cached data when a directory is moved or deleted. // This is useful for clearing cached data when a directory is moved or deleted.
@@ -390,6 +360,26 @@ func deletePathRecursive[T any](m map[string]T, path string) {
} }
} }
// This function takes an escape sequence option (e.g. `\033[1m`) and outputs a
// complete format string (e.g. `\033[1m%s\033[0m`).
func optionToFmtstr(optstr string) string {
if !strings.Contains(optstr, "%s") {
return optstr + "%s\033[0m"
} else {
return optstr
}
}
// This function takes an escape sequence option (e.g. `\033[1m`) and converts
// it to a `tcell.Style` object.
func parseEscapeSequence(s string) tcell.Style {
s = strings.TrimPrefix(s, "\033[")
if i := strings.IndexByte(s, 'm'); i >= 0 {
s = s[:i]
}
return applyAnsiCodes(s, tcell.StyleDefault)
}
// This function is used to remove style-related ANSI escape sequences from // This function is used to remove style-related ANSI escape sequences from
// a given string. // a given string.
// //
@@ -421,6 +411,73 @@ func stripAnsi(s string) string {
return b.String() return b.String()
} }
// This function reads lines from a file to be displayed as a preview.
// The number of lines to read is capped since files can be very large.
// Lines are split on `\n` characters, and `\r` characters are discarded.
// Sixel images are also detected and stored as separate lines.
// The presence of a null byte outside a sixel image indicates a binary file.
func readLines(reader io.ByteReader, maxLines int) (lines []string, binary bool, sixel bool) {
var buf bytes.Buffer
var last byte
inSixel := false
for {
b, err := reader.ReadByte()
if err != nil {
if buf.Len() > 0 {
lines = append(lines, buf.String())
}
return
}
if inSixel {
buf.WriteByte(b)
if b == '\\' && last == '\033' {
lines = append(lines, buf.String())
buf.Reset()
if len(lines) >= maxLines {
return
}
inSixel = false
}
} else {
switch {
case b == 0:
return nil, true, false
case b == '\033':
// withhold as it could be the start of a sixel image
case b == 'P' && last == '\033':
if buf.Len() > 0 {
lines = append(lines, buf.String())
buf.Reset()
if len(lines) >= maxLines {
return
}
}
buf.WriteByte(last)
buf.WriteByte(b)
inSixel = true
sixel = true
case last == '\033':
// not a sixel image
buf.WriteByte(last)
buf.WriteByte(b)
case b == '\r':
case b == '\n':
lines = append(lines, buf.String())
buf.Reset()
if len(lines) >= maxLines {
return
}
default:
buf.WriteByte(b)
}
}
last = b
}
}
// We don't need no generic code // We don't need no generic code
// We don't need no type control // We don't need no type control
// No dark templates in compiler // No dark templates in compiler
+125 -43
View File
@@ -8,7 +8,7 @@ import (
"testing" "testing"
"time" "time"
"golang.org/x/text/collate" "github.com/gdamore/tcell/v2"
) )
func TestIsRoot(t *testing.T) { func TestIsRoot(t *testing.T) {
@@ -289,12 +289,59 @@ func TestHumanize(t *testing.T) {
{1319413953332, "1.2T"}, // 1.2 TiB {1319413953332, "1.2T"}, // 1.2 TiB
{1463669878895412, "1.3P"}, // 1.3 PiB {1463669878895412, "1.3P"}, // 1.3 PiB
{7955158381787244544, "6.9E"}, // 6.9 EiB {7955158381787244544, "6.9E"}, // 6.9 EiB
{math.MaxUint64, "16.0E"}, // 16 EiB {math.MaxInt64, "8.0E"}, // 8 EiB
} }
gOpts.sizeunits = "binary"
for _, test := range tests { for _, test := range tests {
if got := humanize(test.size); got != test.expected { if got := humanize(test.size); got != test.expected {
t.Errorf("at input '%d' expected '%s' but got '%s'", test.size, test.expected, got) t.Errorf("at input ('%d', '%s') expected '%s' but got '%s'", test.size, gOpts.sizeunits, test.expected, got)
}
}
tests = []struct {
size uint64
expected string
}{
{0, "0B"},
{1, "1B"},
{2, "2B"},
{10, "10B"},
{100, "100B"},
{999, "999B"},
{1000, "1.0K"},
{1001, "1.0K"},
{1049, "1.0K"},
{1050, "1.1K"},
{1051, "1.1K"},
{9949, "9.9K"},
{9950, "10.0K"},
{9951, "10.0K"},
{9999, "10.0K"},
{10000, "10.0K"},
{10001, "10.0K"},
{99949, "99.9K"},
{99950, "100K"},
{99951, "100K"},
{999499, "999K"},
{999500, "1.0M"},
{999501, "1.0M"},
{999999, "1.0M"},
{1000000, "1.0M"},
{1000001, "1.0M"},
{999499999, "999M"},
{999500000, "1.0G"},
{999500001, "1.0G"},
{999999999, "1.0G"},
{1000000000, "1.0G"},
{1000000001, "1.0G"},
{math.MaxInt64, "9.2E"},
}
gOpts.sizeunits = "decimal"
for _, test := range tests {
if got := humanize(test.size); got != test.expected {
t.Errorf("at input ('%d', '%s') expected '%s' but got '%s'", test.size, gOpts.sizeunits, test.expected, got)
} }
} }
} }
@@ -363,51 +410,34 @@ func TestGetFileExtension(t *testing.T) {
} }
} }
func TestLocaleNaturalLess(t *testing.T) { func TestOptionToFmtstr(t *testing.T) {
tests := []struct { tests := []struct {
s1 string s string
s2 string exp string
exp bool
}{ }{
// preserving behavior of `naturalLess` {"\033[1m", "\033[1m%s\033[0m"},
{"foo", "bar", false}, {"\033[1;7;31;42m", "\033[1;7;31;42m%s\033[0m"},
{"bar", "baz", true},
{"foo", "123", false},
{"foo1", "foobar", true},
{"foo1", "foo10", true},
{"foo2", "foo10", true},
{"foo1", "foo10bar", true},
{"foo2", "foo10bar", true},
{"foo1bar", "foo10bar", true},
{"foo2bar", "foo10bar", true},
{"foo1bar", "foo10", true},
{"foo2bar", "foo10", true},
// locale sort
{"你好", "他好", true}, // \u4F60\u597D, \u4ED6\u597D
{"到这", "到那", false}, // \u5230\u8FD9, \u5230\u90A3
{"你说", "什么", true}, // \u4f60\u8bf4, \u4ec0\u4e48
{"你好", "World", false}, // \u4F60\u597D, \u57\u6f\u72\u6c\u64
{"甲1", "甲乙", true},
{"甲1", "甲10", true},
{"甲2", "甲10", true},
{"甲1", "甲10乙", true},
{"甲2", "甲10乙", true},
{"甲1乙", "甲10乙", true},
{"甲2乙", "甲10乙", true},
{"甲1乙", "甲10", true},
{"甲2乙", "甲10", true},
}
localeStr := "zh-CN"
collator, err := makeCollator(localeStr, collate.Numeric)
if err != nil {
t.Fatalf("failed to create collator for %q: %s", localeStr, err)
} }
for _, test := range tests { for _, test := range tests {
if got := collator.CompareString(test.s1, test.s2) < 0; got != test.exp { if got := optionToFmtstr(test.s); got != test.exp {
t.Errorf("at input '%s' and '%s' expected '%t' but got '%t'", test.s1, test.s2, test.exp, got) t.Errorf("at input %q expected %q but got %q", test.s, test.exp, got)
}
}
}
func TestParseEscapeSequence(t *testing.T) {
tests := []struct {
s string
exp tcell.Style
}{
{"\033[1m", tcell.StyleDefault.Bold(true)},
{"\033[1;7;31;42m", tcell.StyleDefault.Bold(true).Reverse(true).Foreground(tcell.ColorMaroon).Background(tcell.ColorGreen)},
}
for _, test := range tests {
if got := parseEscapeSequence(test.s); got != test.exp {
t.Errorf("at input %q expected '%v' but got '%v'", test.s, test.exp, got)
} }
} }
} }
@@ -443,3 +473,55 @@ func TestStripAnsi(t *testing.T) {
} }
} }
} }
func TestReadLines(t *testing.T) {
tests := []struct {
s string
maxLines int
lines []string
binary bool
sixel bool
}{
{"", 10, nil, false, false},
{"\r", 10, nil, false, false},
{"\r\n", 10, []string{""}, false, false},
{"\r\r\n", 10, []string{""}, false, false},
{"\n\n", 10, []string{"", ""}, false, false},
{"foo", 10, []string{"foo"}, false, false},
{"foo\n", 10, []string{"foo"}, false, false},
{"foo\r\n", 10, []string{"foo"}, false, false},
{"foo\nbar", 10, []string{"foo", "bar"}, false, false},
{"foo\nbar\n", 10, []string{"foo", "bar"}, false, false},
{"foo\r\nbar", 10, []string{"foo", "bar"}, false, false},
{"foo\r\nbar\r\n", 10, []string{"foo", "bar"}, false, false},
{"\033[31mfoo\033[0m", 10, []string{"\033[31mfoo\033[0m"}, false, false},
{"\000", 10, nil, true, false},
{"foo\r\n\000\r\nbar\r\n", 10, nil, true, false},
{"\033P\033\\", 10, []string{"\033P\033\\"}, false, true},
{"\033Pq\"1;1;1;1#0@\033\\", 10, []string{"\033Pq\"1;1;1;1#0@\033\\"}, false, true},
{"\033P\000\033\\", 10, []string{"\033P\000\033\\"}, false, true},
{"\033P\n\033\\", 10, []string{"\033P\n\033\\"}, false, true},
{"\033P\r\n\033\\", 10, []string{"\033P\r\n\033\\"}, false, true},
{"\033P\033\\\033P\033\\", 10, []string{"\033P\033\\", "\033P\033\\"}, false, true},
{"foo\033P\033\\bar", 10, []string{"foo", "\033P\033\\", "bar"}, false, true},
{"foo\033P\033\\bar\033P\033\\baz", 10, []string{"foo", "\033P\033\\", "bar", "\033P\033\\", "baz"}, false, true},
{"foo\nbar\nbaz", 2, []string{"foo", "bar"}, false, false},
{"foo\nbar\nbaz\n", 2, []string{"foo", "bar"}, false, false},
{"foo\nbar\033P\033\\", 2, []string{"foo", "bar"}, false, false},
{"foo\nbar\nbaz", 3, []string{"foo", "bar", "baz"}, false, false},
{"foo\nbar\nbaz\n", 3, []string{"foo", "bar", "baz"}, false, false},
{"foo\nbar\033P\033\\", 3, []string{"foo", "bar", "\033P\033\\"}, false, true},
}
for _, test := range tests {
lines, binary, sixel := readLines(strings.NewReader(test.s), test.maxLines)
if !reflect.DeepEqual(lines, test.lines) || binary != test.binary || sixel != test.sixel {
t.Errorf(
"at input (%q, %v) expected (%#v, %v, %v) but got (%#v, %v, %v)",
test.s, test.maxLines,
test.lines, test.binary, test.sixel,
lines, binary, sixel,
)
}
}
}
+79 -207
View File
@@ -19,7 +19,6 @@ import (
"time" "time"
"github.com/djherbis/times" "github.com/djherbis/times"
"golang.org/x/text/collate"
) )
type linkState byte type linkState byte
@@ -189,7 +188,6 @@ type dir struct {
filter []string // last filter for this directory filter []string // last filter for this directory
ignorecase bool // ignorecase value from last sort ignorecase bool // ignorecase value from last sort
ignoredia bool // ignoredia value from last sort ignoredia bool // ignoredia value from last sort
locale string // locale value from last sort
noPerm bool // whether lf has no permission to open the directory noPerm bool // whether lf has no permission to open the directory
} }
@@ -228,79 +226,67 @@ func (dir *dir) sort() {
dir.dironly = getDirOnly(dir.path) dir.dironly = getDirOnly(dir.path)
dir.hidden = getHidden(dir.path) dir.hidden = getHidden(dir.path)
dir.reverse = getReverse(dir.path) dir.reverse = getReverse(dir.path)
dir.locale = getLocale(dir.path)
dir.hiddenfiles = gOpts.hiddenfiles dir.hiddenfiles = gOpts.hiddenfiles
dir.ignorecase = gOpts.ignorecase dir.ignorecase = gOpts.ignorecase
dir.ignoredia = gOpts.ignoredia dir.ignoredia = gOpts.ignoredia
dir.files = dir.allFiles dir.files = dir.allFiles
// When applying a filter, move all files not satisfying the predicate to
// the beginning, then take the subslice starting from the first file that
// does satisfy the predicate
applyFilter := func(fn func(f *file) bool) {
slices.SortStableFunc(dir.files, func(i, j *file) int {
switch {
case fn(i) == fn(j):
return 0
case !fn(i) && fn(j):
return -1
default:
return 1
}
})
i := slices.IndexFunc(dir.files, fn)
if i == -1 {
i = len(dir.files)
}
dir.files = dir.files[i:]
}
if dir.dironly {
applyFilter(func(f *file) bool { return f.IsDir() })
}
if !dir.hidden {
applyFilter(func(f *file) bool { return !isHidden(f, dir.path, dir.hiddenfiles) })
}
if len(dir.filter) != 0 {
applyFilter(func(f *file) bool { return !isFiltered(f, dir.filter) })
}
// reverse order cannot be applied after stable sorting, otherwise the order // reverse order cannot be applied after stable sorting, otherwise the order
// of equivalent elements will be reversed // of equivalent elements will be reversed
applySort := func(fn func(i, j int) bool) {
if !dir.reverse {
sort.SliceStable(dir.files, fn)
} else {
sort.SliceStable(dir.files, func(i, j int) bool { return fn(j, i) })
}
}
switch dir.sortby { switch dir.sortby {
case naturalSort: case naturalSort:
if collator, err := makeCollator(dir.locale, collate.Numeric); err == nil { applySort(func(i, j int) bool {
sort.SliceStable(dir.files, func(i, j int) bool {
s1, s2 := normalize(dir.files[i].Name(), dir.files[j].Name(), dir.ignorecase, dir.ignoredia) s1, s2 := normalize(dir.files[i].Name(), dir.files[j].Name(), dir.ignorecase, dir.ignoredia)
result := collator.CompareString(s1, s2)
if !dir.reverse {
return result < 0
} else {
return result > 0
}
})
} else {
sort.SliceStable(dir.files, func(i, j int) bool {
s1, s2 := normalize(dir.files[i].Name(), dir.files[j].Name(), dir.ignorecase, dir.ignoredia)
if !dir.reverse {
return naturalLess(s1, s2) return naturalLess(s1, s2)
} else {
return naturalLess(s2, s1)
}
}) })
}
case customSort:
if collator, err := makeCollator(dir.locale, collate.Numeric); err == nil {
sort.SliceStable(dir.files, func(i, j int) bool {
s1, s2 := normalize(stripAnsi(dir.files[i].customInfo), stripAnsi(dir.files[j].customInfo), dir.ignorecase, dir.ignoredia)
result := collator.CompareString(s1, s2)
if !dir.reverse {
return result < 0
} else {
return result > 0
}
})
} else {
sort.SliceStable(dir.files, func(i, j int) bool {
s1, s2 := normalize(stripAnsi(dir.files[i].customInfo), stripAnsi(dir.files[j].customInfo), dir.ignorecase, dir.ignoredia)
if !dir.reverse {
return naturalLess(s1, s2)
} else {
return naturalLess(s2, s1)
}
})
}
case nameSort: case nameSort:
if collator, err := makeCollator(dir.locale); err == nil { applySort(func(i, j int) bool {
sort.SliceStable(dir.files, func(i, j int) bool {
s1, s2 := normalize(dir.files[i].Name(), dir.files[j].Name(), dir.ignorecase, dir.ignoredia) s1, s2 := normalize(dir.files[i].Name(), dir.files[j].Name(), dir.ignorecase, dir.ignoredia)
result := collator.CompareString(s1, s2)
if !dir.reverse {
return result < 0
} else {
return result > 0
}
})
} else {
sort.SliceStable(dir.files, func(i, j int) bool {
s1, s2 := normalize(dir.files[i].Name(), dir.files[j].Name(), dir.ignorecase, dir.ignoredia)
if !dir.reverse {
return s1 < s2 return s1 < s2
} else {
return s2 < s1
}
}) })
}
case sizeSort: case sizeSort:
sizeVal := func(f *file) int64 { sizeVal := func(f *file) int64 {
if f.IsDir() && dir.dircounts { if f.IsDir() && dir.dircounts {
@@ -308,55 +294,36 @@ func (dir *dir) sort() {
} }
return f.TotalSize() return f.TotalSize()
} }
sort.SliceStable(dir.files, func(i, j int) bool { applySort(func(i, j int) bool {
s1, s2 := sizeVal(dir.files[i]), sizeVal(dir.files[j]) s1, s2 := sizeVal(dir.files[i]), sizeVal(dir.files[j])
if !dir.reverse {
return s1 < s2 return s1 < s2
} else {
return s2 < s1
}
}) })
case timeSort: case timeSort:
sort.SliceStable(dir.files, func(i, j int) bool { applySort(func(i, j int) bool {
if !dir.reverse {
return dir.files[i].ModTime().Before(dir.files[j].ModTime()) return dir.files[i].ModTime().Before(dir.files[j].ModTime())
} else {
return dir.files[j].ModTime().Before(dir.files[i].ModTime())
}
}) })
case atimeSort: case atimeSort:
sort.SliceStable(dir.files, func(i, j int) bool { applySort(func(i, j int) bool {
if !dir.reverse {
return dir.files[i].accessTime.Before(dir.files[j].accessTime) return dir.files[i].accessTime.Before(dir.files[j].accessTime)
} else {
return dir.files[j].accessTime.Before(dir.files[i].accessTime)
}
}) })
case btimeSort: case btimeSort:
sort.SliceStable(dir.files, func(i, j int) bool { applySort(func(i, j int) bool {
if !dir.reverse {
return dir.files[i].birthTime.Before(dir.files[j].birthTime) return dir.files[i].birthTime.Before(dir.files[j].birthTime)
} else {
return dir.files[j].birthTime.Before(dir.files[i].birthTime)
}
}) })
case ctimeSort: case ctimeSort:
sort.SliceStable(dir.files, func(i, j int) bool { applySort(func(i, j int) bool {
if !dir.reverse {
return dir.files[i].changeTime.Before(dir.files[j].changeTime) return dir.files[i].changeTime.Before(dir.files[j].changeTime)
} else {
return dir.files[j].changeTime.Before(dir.files[i].changeTime)
}
}) })
case extSort: case extSort:
sort.SliceStable(dir.files, func(i, j int) bool { applySort(func(i, j int) bool {
ext1, ext2 := normalize(dir.files[i].ext, dir.files[j].ext, dir.ignorecase, dir.ignoredia) ext1, ext2 := normalize(dir.files[i].ext, dir.files[j].ext, dir.ignorecase, dir.ignoredia)
name1, name2 := normalize(dir.files[i].Name(), dir.files[j].Name(), dir.ignorecase, dir.ignoredia) name1, name2 := normalize(dir.files[i].Name(), dir.files[j].Name(), dir.ignorecase, dir.ignoredia)
if !dir.reverse {
return ext1 < ext2 || ext1 == ext2 && name1 < name2 return ext1 < ext2 || ext1 == ext2 && name1 < name2
} else { })
return ext2 < ext1 || ext2 == ext1 && name2 < name1 case customSort:
} applySort(func(i, j int) bool {
s1, s2 := normalize(stripAnsi(dir.files[i].customInfo), stripAnsi(dir.files[j].customInfo), dir.ignorecase, dir.ignoredia)
return naturalLess(s1, s2)
}) })
} }
@@ -371,65 +338,6 @@ func (dir *dir) sort() {
}) })
} }
// when dironly option is enabled, we move files to the beginning of our file
// list and then set the beginning of displayed files to the first directory
// in the list
if dir.dironly {
sort.SliceStable(dir.files, func(i, j int) bool {
if !dir.files[i].IsDir() && !dir.files[j].IsDir() {
return i < j
}
return !dir.files[i].IsDir()
})
dir.files = func() []*file {
for i, f := range dir.files {
if f.IsDir() {
return dir.files[i:]
}
}
return dir.files[len(dir.files):]
}()
}
// when hidden option is disabled, we move hidden files to the
// beginning of our file list and then set the beginning of displayed
// files to the first non-hidden file in the list
if !dir.hidden {
sort.SliceStable(dir.files, func(i, j int) bool {
if isHidden(dir.files[i], dir.path, dir.hiddenfiles) && isHidden(dir.files[j], dir.path, dir.hiddenfiles) {
return i < j
}
return isHidden(dir.files[i], dir.path, dir.hiddenfiles)
})
for i, f := range dir.files {
if !isHidden(f, dir.path, dir.hiddenfiles) {
dir.files = dir.files[i:]
break
}
}
if len(dir.files) > 0 && isHidden(dir.files[len(dir.files)-1], dir.path, dir.hiddenfiles) {
dir.files = dir.files[len(dir.files):]
}
}
if len(dir.filter) != 0 {
sort.SliceStable(dir.files, func(i, j int) bool {
if isFiltered(dir.files[i], dir.filter) && isFiltered(dir.files[j], dir.filter) {
return i < j
}
return isFiltered(dir.files[i], dir.filter)
})
for i, f := range dir.files {
if !isFiltered(f, dir.filter) {
dir.files = dir.files[i:]
break
}
}
if len(dir.files) > 0 && isFiltered(dir.files[len(dir.files)-1], dir.filter) {
dir.files = dir.files[len(dir.files):]
}
}
dir.ind = max(dir.ind, 0) dir.ind = max(dir.ind, 0)
dir.ind = min(dir.ind, len(dir.files)-1) dir.ind = min(dir.ind, len(dir.files)-1)
} }
@@ -538,7 +446,7 @@ type nav struct {
deleteCount int deleteCount int
deleteTotal int deleteTotal int
deleteUpdate int deleteUpdate int
copyJobsChan chan struct{} copyJobsChan chan int
copyBytesChan chan int64 copyBytesChan chan int64
copyTotalChan chan int64 copyTotalChan chan int64
moveCountChan chan int moveCountChan chan int
@@ -574,7 +482,13 @@ type nav struct {
jumpListInd int jumpListInd int
} }
func (nav *nav) loadDirInternal(path string) *dir { func (nav *nav) loadDir(path string) *dir {
d, ok := nav.dirCache[path]
if !ok {
go func() {
nav.dirChan <- newDir(path)
}()
d := &dir{ d := &dir{
loading: true, loading: true,
path: path, path: path,
@@ -584,32 +498,17 @@ func (nav *nav) loadDirInternal(path string) *dir {
dironly: getDirOnly(path), dironly: getDirOnly(path),
hidden: getHidden(path), hidden: getHidden(path),
reverse: getReverse(path), reverse: getReverse(path),
locale: getLocale(path),
visualAnchor: -1, visualAnchor: -1,
hiddenfiles: gOpts.hiddenfiles, hiddenfiles: gOpts.hiddenfiles,
ignorecase: gOpts.ignorecase, ignorecase: gOpts.ignorecase,
ignoredia: gOpts.ignoredia, ignoredia: gOpts.ignoredia,
} }
go func() {
nav.dirChan <- newDir(path)
}()
return d
}
func (nav *nav) loadDir(path string) *dir {
if gOpts.dircache {
d, ok := nav.dirCache[path]
if !ok {
d = nav.loadDirInternal(path)
nav.dirCache[path] = d nav.dirCache[path] = d
return d return d
} }
nav.checkDir(d) nav.checkDir(d)
return d return d
}
return nav.loadDirInternal(path)
} }
func (nav *nav) checkDir(dir *dir) { func (nav *nav) checkDir(dir *dir) {
@@ -648,7 +547,6 @@ func (nav *nav) checkDir(dir *dir) {
dir.dironly != getDirOnly(dir.path) || dir.dironly != getDirOnly(dir.path) ||
dir.hidden != getHidden(dir.path) || dir.hidden != getHidden(dir.path) ||
dir.reverse != getReverse(dir.path) || dir.reverse != getReverse(dir.path) ||
dir.locale != getLocale(dir.path) ||
!reflect.DeepEqual(dir.hiddenfiles, gOpts.hiddenfiles) || !reflect.DeepEqual(dir.hiddenfiles, gOpts.hiddenfiles) ||
dir.ignorecase != gOpts.ignorecase || dir.ignorecase != gOpts.ignorecase ||
dir.ignoredia != gOpts.ignoredia: dir.ignoredia != gOpts.ignoredia:
@@ -684,7 +582,7 @@ func (nav *nav) getDirs(wd string) {
func newNav(height int) *nav { func newNav(height int) *nav {
nav := &nav{ nav := &nav{
copyJobsChan: make(chan struct{}, 1024), copyJobsChan: make(chan int, 1024),
copyBytesChan: make(chan int64, 1024), copyBytesChan: make(chan int64, 1024),
copyTotalChan: make(chan int64, 1024), copyTotalChan: make(chan int64, 1024),
moveCountChan: make(chan int, 1024), moveCountChan: make(chan int, 1024),
@@ -914,43 +812,12 @@ func (nav *nav) preview(path string, win *win) {
reader = bufio.NewReader(f) reader = bufio.NewReader(f)
} }
if gOpts.sixel { lines, binary, sixel := readLines(reader, win.h)
prefix, err := reader.Peek(2) if binary {
if err == nil && string(prefix) == gSixelBegin { lines = []string{"\033[7mbinary\033[0m"}
b, err := io.ReadAll(reader)
if err != nil {
log.Printf("loading sixel: %s", err)
}
str := string(b)
reg.sixel = &str
return
}
}
// bufio.Scanner can't handle files containing long lines if they exceed the
// size of its internal buffer
line := []byte{}
for len(reg.lines) < win.h {
bytes, isPrefix, err := reader.ReadLine()
if err != nil {
if len(line) > 0 {
reg.lines = append(reg.lines, string(line))
}
break
}
if slices.Contains(bytes, 0) {
reg.lines = []string{"\033[7mbinary\033[0m"}
return
}
line = append(line, bytes...)
if !isPrefix {
reg.lines = append(reg.lines, string(line))
line = []byte{}
}
} }
reg.lines = lines
reg.sixel = sixel
} }
func (nav *nav) loadReg(path string, volatile bool) *reg { func (nav *nav) loadReg(path string, volatile bool) *reg {
@@ -1357,15 +1224,15 @@ func (nav *nav) copyAsync(app *app, srcs []string, dstDir string) {
return return
} }
// indicate that a copy operation is in progress // Indicate that a copy operation is in progress. Using the total bytes to
// using the total bytes to determine this instead will mean that it is // determine this instead will mean that it is possible for copySize to take
// possible for copySize to take a while, but not be reflected in the UI // a while, but not be reflected in the UI until it has finished.
// until it has finished nav.copyJobsChan <- 1
nav.copyJobsChan <- struct{}{}
total, err := copySize(srcs) total, err := copySize(srcs)
if err != nil { if err != nil {
sendErr("%v", err) sendErr("%v", err)
nav.copyJobsChan <- -1
return return
} }
@@ -1386,6 +1253,7 @@ loop:
} }
} }
nav.copyJobsChan <- -1
nav.copyTotalChan <- -total nav.copyTotalChan <- -total
if gSingleMode { if gSingleMode {
@@ -1451,9 +1319,12 @@ func (nav *nav) moveAsync(app *app, srcs []string, dstDir string) {
if err := os.Rename(src, dst); err != nil { if err := os.Rename(src, dst); err != nil {
if errCrossDevice(err) { if errCrossDevice(err) {
nav.copyJobsChan <- 1
total, err := copySize([]string{src}) total, err := copySize([]string{src})
if err != nil { if err != nil {
sendErr("%v", err) sendErr("%v", err)
nav.copyJobsChan <- -1
continue continue
} }
@@ -1475,6 +1346,7 @@ func (nav *nav) moveAsync(app *app, srcs []string, dstDir string) {
} }
} }
nav.copyJobsChan <- -1
nav.copyTotalChan <- -total nav.copyTotalChan <- -total
if errCount == oldCount { if errCount == oldCount {
+8 -17
View File
@@ -53,7 +53,6 @@ var gOpts struct {
cursorparentfmt string cursorparentfmt string
cursorpreviewfmt string cursorpreviewfmt string
cutfmt string cutfmt string
dircache bool
dircounts bool dircounts bool
dirfirst bool dirfirst bool
dironly bool dironly bool
@@ -76,7 +75,9 @@ var gOpts struct {
info []string info []string
infotimefmtnew string infotimefmtnew string
infotimefmtold string infotimefmtold string
locale string menufmt string
menuheaderfmt string
menuselectfmt string
mouse bool mouse bool
number bool number bool
numberfmt string numberfmt string
@@ -98,7 +99,7 @@ var gOpts struct {
shellflag string shellflag string
shellopts []string shellopts []string
showbinds bool showbinds bool
sixel bool sizeunits string
smartcase bool smartcase bool
smartdia bool smartdia bool
sortby sortMethod sortby sortMethod
@@ -127,7 +128,6 @@ var gLocalOpts struct {
dironly map[string]bool dironly map[string]bool
hidden map[string]bool hidden map[string]bool
info map[string][]string info map[string][]string
locale map[string]string
reverse map[string]bool reverse map[string]bool
sortby map[string]sortMethod sortby map[string]sortMethod
} }
@@ -185,15 +185,6 @@ func getInfo(path string) []string {
return gOpts.info return gOpts.info
} }
func getLocale(path string) string {
for _, key := range localOptPaths(path) {
if val, ok := gLocalOpts.locale[key]; ok {
return val
}
}
return gOpts.locale
}
func getReverse(path string) bool { func getReverse(path string) bool {
for _, key := range localOptPaths(path) { for _, key := range localOptPaths(path) {
if val, ok := gLocalOpts.reverse[key]; ok { if val, ok := gLocalOpts.reverse[key]; ok {
@@ -222,7 +213,6 @@ func init() {
gOpts.cursorparentfmt = "\033[7m" gOpts.cursorparentfmt = "\033[7m"
gOpts.cursorpreviewfmt = "\033[4m" gOpts.cursorpreviewfmt = "\033[4m"
gOpts.cutfmt = "\033[7;31m" gOpts.cutfmt = "\033[7;31m"
gOpts.dircache = true
gOpts.dircounts = false gOpts.dircounts = false
gOpts.dirfirst = true gOpts.dirfirst = true
gOpts.dironly = false gOpts.dironly = false
@@ -245,7 +235,9 @@ func init() {
gOpts.info = nil gOpts.info = nil
gOpts.infotimefmtnew = "Jan _2 15:04" gOpts.infotimefmtnew = "Jan _2 15:04"
gOpts.infotimefmtold = "Jan _2 2006" gOpts.infotimefmtold = "Jan _2 2006"
gOpts.locale = localeStrDisable gOpts.menufmt = "\033[0m"
gOpts.menuheaderfmt = "\033[1m"
gOpts.menuselectfmt = "\033[7m"
gOpts.mouse = false gOpts.mouse = false
gOpts.number = false gOpts.number = false
gOpts.numberfmt = "\033[33m" gOpts.numberfmt = "\033[33m"
@@ -267,7 +259,7 @@ func init() {
gOpts.shellflag = gDefaultShellFlag gOpts.shellflag = gDefaultShellFlag
gOpts.shellopts = nil gOpts.shellopts = nil
gOpts.showbinds = true gOpts.showbinds = true
gOpts.sixel = false gOpts.sizeunits = "binary"
gOpts.smartcase = true gOpts.smartcase = true
gOpts.smartdia = false gOpts.smartdia = false
gOpts.sortby = naturalSort gOpts.sortby = naturalSort
@@ -421,7 +413,6 @@ func init() {
gLocalOpts.dironly = make(map[string]bool) gLocalOpts.dironly = make(map[string]bool)
gLocalOpts.hidden = make(map[string]bool) gLocalOpts.hidden = make(map[string]bool)
gLocalOpts.info = make(map[string][]string) gLocalOpts.info = make(map[string][]string)
gLocalOpts.locale = make(map[string]string)
gLocalOpts.reverse = make(map[string]bool) gLocalOpts.reverse = make(map[string]bool)
gLocalOpts.sortby = make(map[string]sortMethod) gLocalOpts.sortby = make(map[string]sortMethod)
+3 -3
View File
@@ -164,9 +164,9 @@ func setDefaults() {
gOpts.nkeys["w"] = &execExpr{"$", "$SHELL"} gOpts.nkeys["w"] = &execExpr{"$", "$SHELL"}
gOpts.vkeys["w"] = &execExpr{"$", "$SHELL"} gOpts.vkeys["w"] = &execExpr{"$", "$SHELL"}
gOpts.cmds["doc"] = &execExpr{"$", `"$lf" -doc | $PAGER`} gOpts.cmds["help"] = &execExpr{"$", `"$lf" -doc | $PAGER`}
gOpts.nkeys["<f-1>"] = &callExpr{"doc", nil, 1} gOpts.nkeys["<f-1>"] = &callExpr{"help", nil, 1}
gOpts.vkeys["<f-1>"] = &callExpr{"doc", nil, 1} gOpts.vkeys["<f-1>"] = &callExpr{"help", nil, 1}
gOpts.cmds["maps"] = &execExpr{"$", `"$lf" -remote "query $id maps" | $PAGER`} gOpts.cmds["maps"] = &execExpr{"$", `"$lf" -remote "query $id maps" | $PAGER`}
gOpts.cmds["nmaps"] = &execExpr{"$", `"$lf" -remote "query $id nmaps" | $PAGER`} gOpts.cmds["nmaps"] = &execExpr{"$", `"$lf" -remote "query $id nmaps" | $PAGER`}
+13 -5
View File
@@ -74,7 +74,11 @@ func init() {
Username: username, Username: username,
} }
config := cmp.Or(os.Getenv("LF_CONFIG_HOME"), os.Getenv("APPDATA")) config := cmp.Or(
os.Getenv("LF_CONFIG_HOME"),
os.Getenv("XDG_CONFIG_HOME"),
os.Getenv("APPDATA"),
)
gConfigPaths = []string{ gConfigPaths = []string{
filepath.Join(os.Getenv("ProgramData"), "lf", "lfrc"), filepath.Join(os.Getenv("ProgramData"), "lf", "lfrc"),
@@ -91,7 +95,11 @@ func init() {
filepath.Join(config, "lf", "icons"), filepath.Join(config, "lf", "icons"),
} }
data := cmp.Or(os.Getenv("LF_DATA_HOME"), os.Getenv("LOCALAPPDATA")) data := cmp.Or(
os.Getenv("LF_DATA_HOME"),
os.Getenv("XDG_DATA_HOME"),
os.Getenv("LOCALAPPDATA"),
)
gFilesPath = filepath.Join(data, "lf", "files") gFilesPath = filepath.Join(data, "lf", "files")
gMarksPath = filepath.Join(data, "lf", "marks") gMarksPath = filepath.Join(data, "lf", "marks")
@@ -152,9 +160,9 @@ func setDefaults() {
gOpts.nkeys["w"] = &execExpr{"$", "%SHELL%"} gOpts.nkeys["w"] = &execExpr{"$", "%SHELL%"}
gOpts.vkeys["w"] = &execExpr{"$", "%SHELL%"} gOpts.vkeys["w"] = &execExpr{"$", "%SHELL%"}
gOpts.cmds["doc"] = &execExpr{"!", "%lf% -doc | %PAGER%"} gOpts.cmds["help"] = &execExpr{"!", "%lf% -doc | %PAGER%"}
gOpts.nkeys["<f-1>"] = &callExpr{"doc", nil, 1} gOpts.nkeys["<f-1>"] = &callExpr{"help", nil, 1}
gOpts.vkeys["<f-1>"] = &callExpr{"doc", nil, 1} gOpts.vkeys["<f-1>"] = &callExpr{"help", nil, 1}
gOpts.cmds["maps"] = &execExpr{"!", `%lf% -remote "query %id% maps" | %PAGER%`} gOpts.cmds["maps"] = &execExpr{"!", `%lf% -remote "query %id% maps" | %PAGER%`}
gOpts.cmds["nmaps"] = &execExpr{"!", `%lf% -remote "query %id% nmaps" | %PAGER%`} gOpts.cmds["nmaps"] = &execExpr{"!", `%lf% -remote "query %id% nmaps" | %PAGER%`}
+37 -8
View File
@@ -6,12 +6,11 @@ import (
"log" "log"
"os" "os"
"strconv" "strconv"
"strings"
"github.com/gdamore/tcell/v2" "github.com/gdamore/tcell/v2"
) )
const gSixelBegin = "\033P"
type sixelScreen struct { type sixelScreen struct {
lastFile string lastFile string
lastWin win lastWin win
@@ -29,7 +28,7 @@ func (sxs *sixelScreen) printSixel(win *win, screen tcell.Screen, reg *reg) {
return return
} }
if reg.sixel == nil { if !reg.sixel {
sxs.lastFile = "" sxs.lastFile = ""
return return
} }
@@ -40,11 +39,28 @@ func (sxs *sixelScreen) printSixel(win *win, screen tcell.Screen, reg *reg) {
return return
} }
matches := reSixelSize.FindStringSubmatch(*reg.sixel) y := win.y
var b strings.Builder
for _, line := range reg.lines {
if !strings.HasPrefix(line, "\033P") {
if y >= win.y+win.h {
break
}
screen.LockRegion(win.x, y, printLength(line), 1, true)
fmt.Fprintf(&b, "\033[%d;%dH", y+1, win.x+1)
b.WriteString(line)
y += 1
continue
}
matches := reSixelSize.FindStringSubmatch(line)
if matches == nil { if matches == nil {
log.Printf("sixel: failed to get image size") log.Printf("sixel: failed to get image size")
return continue
} }
iw, _ := strconv.Atoi(matches[1]) iw, _ := strconv.Atoi(matches[1])
ih, _ := strconv.Atoi(matches[2]) ih, _ := strconv.Atoi(matches[2])
@@ -55,11 +71,24 @@ func (sxs *sixelScreen) printSixel(win *win, screen tcell.Screen, reg *reg) {
ih = (ih + 5) / 6 * 6 ih = (ih + 5) / 6 * 6
} }
screen.LockRegion(win.x, win.y, (iw+cw-1)/cw, (ih+ch-1)/ch, true) sw := (iw + cw - 1) / cw
sh := (ih + ch - 1) / ch
if y+sh-1 >= win.y+win.h {
break
}
screen.LockRegion(win.x, y, sw, sh, true)
fmt.Fprintf(&b, "\033[%d;%dH", y+1, win.x+1)
b.WriteString(line)
y += sh
}
fmt.Fprint(os.Stderr, "\033[?2026h") // Begin synchronized update
fmt.Fprint(os.Stderr, "\0337") // Save cursor position fmt.Fprint(os.Stderr, "\0337") // Save cursor position
fmt.Fprintf(os.Stderr, "\033[%d;%dH", win.y+1, win.x+1) // Move cursor to position fmt.Fprint(os.Stderr, b.String()) // Write data
fmt.Fprint(os.Stderr, *reg.sixel) // Print sixel
fmt.Fprint(os.Stderr, "\0338") // Restore cursor position fmt.Fprint(os.Stderr, "\0338") // Restore cursor position
fmt.Fprint(os.Stderr, "\033[?2026l") // End synchronized update
sxs.lastFile = reg.path sxs.lastFile = reg.path
sxs.lastWin = *win sxs.lastWin = *win
+113 -104
View File
@@ -270,12 +270,14 @@ func (win *win) printReg(screen tcell.Screen, reg *reg, previewLoading bool, sxs
return return
} }
if !reg.sixel {
for i, l := range reg.lines { for i, l := range reg.lines {
if i > win.h-1 { if i > win.h-1 {
break break
} }
st = win.print(screen, 2, i, st, l) st = win.print(screen, 0, i, st, l)
}
} }
sxs.printSixel(win, screen, reg) sxs.printSixel(win, screen, reg)
@@ -637,6 +639,11 @@ func getWins(screen tcell.Screen) []*win {
return wins return wins
} }
type menuSelect struct {
x, y int
s string
}
type ui struct { type ui struct {
screen tcell.Screen screen tcell.Screen
sxScreen sixelScreen sxScreen sixelScreen
@@ -646,7 +653,6 @@ type ui struct {
msgWin *win msgWin *win
menuWin *win menuWin *win
msg string msg string
msgIsStat bool
regPrev *reg regPrev *reg
dirPrev *dir dirPrev *dir
exprChan chan expr exprChan chan expr
@@ -654,6 +660,7 @@ type ui struct {
tevChan chan tcell.Event tevChan chan tcell.Event
evChan chan tcell.Event evChan chan tcell.Event
menu string menu string
menuSelect *menuSelect
cmdPrefix string cmdPrefix string
cmdAccLeft []rune cmdAccLeft []rune
cmdAccRight []rune cmdAccRight []rune
@@ -676,7 +683,6 @@ func newUI(screen tcell.Screen) *ui {
promptWin: newWin(wtot, 1, 0, 0), promptWin: newWin(wtot, 1, 0, 0),
msgWin: newWin(wtot, 1, 0, htot-1), msgWin: newWin(wtot, 1, 0, htot-1),
menuWin: newWin(wtot, 1, 0, htot-2), menuWin: newWin(wtot, 1, 0, htot-2),
msgIsStat: true,
exprChan: make(chan expr, 1000), exprChan: make(chan expr, 1000),
keyChan: make(chan string, 1000), keyChan: make(chan string, 1000),
tevChan: make(chan tcell.Event, 1000), tevChan: make(chan tcell.Event, 1000),
@@ -734,7 +740,6 @@ func (ui *ui) sort() {
func (ui *ui) echo(msg string) { func (ui *ui) echo(msg string) {
ui.msg = msg ui.msg = msg
ui.msgIsStat = false
} }
func (ui *ui) echomsg(msg string) { func (ui *ui) echomsg(msg string) {
@@ -742,14 +747,6 @@ func (ui *ui) echomsg(msg string) {
log.Print(msg) log.Print(msg)
} }
func optionToFmtstr(optstr string) string {
if !strings.Contains(optstr, "%s") {
return optstr + "%s\033[0m"
} else {
return optstr
}
}
func (ui *ui) echoerr(msg string) { func (ui *ui) echoerr(msg string) {
ui.echo(fmt.Sprintf(optionToFmtstr(gOpts.errorfmt), msg)) ui.echo(fmt.Sprintf(optionToFmtstr(gOpts.errorfmt), msg))
log.Printf("error: %s", msg) log.Printf("error: %s", msg)
@@ -768,7 +765,7 @@ type reg struct {
loadTime time.Time loadTime time.Time
path string path string
lines []string lines []string
sixel *string sixel bool
} }
func (ui *ui) loadFile(app *app, volatile bool) { func (ui *ui) loadFile(app *app, volatile bool) {
@@ -801,57 +798,6 @@ func (ui *ui) loadFile(app *app, volatile bool) {
} }
} }
func (ui *ui) loadFileInfo(nav *nav) {
if !nav.init {
return
}
ui.msg = ""
ui.msgIsStat = true
curr, err := nav.currFile()
if err != nil {
return
}
if curr.err != nil {
ui.echoerrf("stat: %s", curr.err)
return
}
statfmt := strings.ReplaceAll(gOpts.statfmt, "|", "\x1f")
replace := func(s string, val string) {
if val == "" {
val = "\x00"
}
statfmt = strings.ReplaceAll(statfmt, s, val)
}
if nav.isVisualMode() {
replace("%m", "VISUAL")
replace("%M", "VISUAL")
} else {
replace("%m", "")
replace("%M", "NORMAL")
}
replace("%p", curr.Mode().String())
replace("%c", linkCount(curr))
replace("%u", userName(curr))
replace("%g", groupName(curr))
replace("%s", humanize(uint64(curr.Size())))
replace("%S", fmt.Sprintf("%5s", humanize(uint64(curr.Size()))))
replace("%t", curr.ModTime().Format(gOpts.timefmt))
replace("%l", curr.linkTarget)
var fileInfo strings.Builder
for _, section := range strings.Split(statfmt, "\x1f") {
if !strings.Contains(section, "\x00") {
fileInfo.WriteString(section)
}
}
ui.msg = fileInfo.String()
}
func (ui *ui) drawPromptLine(nav *nav) { func (ui *ui) drawPromptLine(nav *nav) {
st := tcell.StyleDefault st := tcell.StyleDefault
@@ -925,13 +871,61 @@ func formatRulerOpt(name string, val string) string {
return val return val
} }
func (ui *ui) drawStat(nav *nav) {
if ui.msg != "" {
ui.msgWin.print(ui.screen, 0, 0, tcell.StyleDefault, ui.msg)
return
}
curr, err := nav.currFile()
if err != nil {
return
}
if curr.err != nil {
ui.echoerrf("stat: %s", curr.err)
ui.msgWin.print(ui.screen, 0, 0, tcell.StyleDefault, ui.msg)
return
}
statfmt := strings.ReplaceAll(gOpts.statfmt, "|", "\x1f")
replace := func(s string, val string) {
if val == "" {
val = "\x00"
}
statfmt = strings.ReplaceAll(statfmt, s, val)
}
if nav.isVisualMode() {
replace("%m", "VISUAL")
replace("%M", "VISUAL")
} else {
replace("%m", "")
replace("%M", "NORMAL")
}
replace("%p", curr.Mode().String())
replace("%c", linkCount(curr))
replace("%u", userName(curr))
replace("%g", groupName(curr))
replace("%s", humanize(uint64(curr.Size())))
replace("%S", fmt.Sprintf("%5s", humanize(uint64(curr.Size()))))
replace("%t", curr.ModTime().Format(gOpts.timefmt))
replace("%l", curr.linkTarget)
var fileInfo strings.Builder
for _, section := range strings.Split(statfmt, "\x1f") {
if !strings.Contains(section, "\x00") {
fileInfo.WriteString(section)
}
}
ui.msgWin.print(ui.screen, 0, 0, tcell.StyleDefault, fileInfo.String())
}
func (ui *ui) drawRuler(nav *nav) { func (ui *ui) drawRuler(nav *nav) {
st := tcell.StyleDefault st := tcell.StyleDefault
dir := nav.currDir() dir := nav.currDir()
ui.msgWin.print(ui.screen, 0, 0, st, ui.msg)
tot := len(dir.files) tot := len(dir.files)
ind := min(dir.ind+1, tot) ind := min(dir.ind+1, tot)
hid := len(dir.allFiles) - tot hid := len(dir.allFiles) - tot
@@ -1067,6 +1061,38 @@ func (ui *ui) drawBox() {
} }
} }
func (ui *ui) drawMenu() {
if ui.menu == "" {
return
}
lines := strings.Split(ui.menu, "\n")
lines = lines[:len(lines)-1]
ui.menuWin.h = len(lines)
ui.menuWin.y = ui.msgWin.y - ui.menuWin.h
// clear sixel image if it overlaps with the menu
ui.screen.LockRegion(ui.menuWin.x, ui.menuWin.y, ui.menuWin.w, ui.menuWin.h, false)
ui.sxScreen.forceClear = true
for i, line := range lines {
var st tcell.Style
if i == 0 {
st = parseEscapeSequence(gOpts.menuheaderfmt)
} else {
st = parseEscapeSequence(gOpts.menufmt)
}
ui.menuWin.printLine(ui.screen, 0, i, st, line)
}
if ui.menuSelect != nil {
st := parseEscapeSequence(gOpts.menuselectfmt)
ui.menuWin.print(ui.screen, ui.menuSelect.x, ui.menuSelect.y, st, ui.menuSelect.s)
}
}
func (ui *ui) dirOfWin(nav *nav, wind int) *dir { func (ui *ui) dirOfWin(nav *nav, wind int) *dir {
wins := len(ui.wins) wins := len(ui.wins)
if gOpts.preview { if gOpts.preview {
@@ -1104,6 +1130,7 @@ func (ui *ui) draw(nav *nav) {
switch ui.cmdPrefix { switch ui.cmdPrefix {
case "": case "":
ui.drawStat(nav)
ui.drawRuler(nav) ui.drawRuler(nav)
ui.screen.HideCursor() ui.screen.HideCursor()
case ">": case ">":
@@ -1140,25 +1167,7 @@ func (ui *ui) draw(nav *nav) {
ui.drawBox() ui.drawBox()
} }
if ui.menu != "" { ui.drawMenu()
lines := strings.Split(ui.menu, "\n")
lines = lines[:len(lines)-1]
ui.menuWin.h = len(lines) - 1
ui.menuWin.y = ui.wins[0].h - ui.menuWin.h
if gOpts.drawbox {
ui.menuWin.y += 2
}
ui.menuWin.printLine(ui.screen, 0, 0, st.Bold(true), lines[0])
for i, line := range lines[1:] {
ui.menuWin.printLine(ui.screen, 0, i+1, st, "")
ui.menuWin.print(ui.screen, 0, i+1, st, line)
}
}
ui.screen.Show() ui.screen.Show()
} }
@@ -1572,6 +1581,7 @@ func (ui *ui) readNormalEvent(ev tcell.Event, nav *nav) expr {
return &callExpr{"cd", []string{dir.path}, 1} return &callExpr{"cd", []string{dir.path}, 1}
} }
case *tcell.EventResize: case *tcell.EventResize:
clear(nav.regCache)
return &callExpr{"redraw", nil, 1} return &callExpr{"redraw", nil, 1}
case *tcell.EventError: case *tcell.EventError:
log.Printf("Got EventError: '%s' at %s", tev.Error(), tev.When()) log.Printf("Got EventError: '%s' at %s", tev.Error(), tev.When())
@@ -1669,14 +1679,11 @@ func anyKey() {
os.Stdin.Read(b) os.Stdin.Read(b)
} }
func listMatches(screen tcell.Screen, matches []compMatch, selectedInd int) string { func listMatches(screen tcell.Screen, matches []compMatch, selectedInd int) (string, *menuSelect) {
mlen := len(matches) if len(matches) < 2 {
if mlen < 2 { return "", nil
return ""
} }
var b strings.Builder
wtot, _ := screen.Size() wtot, _ := screen.Size()
wcol := 0 wcol := 0
for _, m := range matches { for _, m := range matches {
@@ -1685,21 +1692,23 @@ func listMatches(screen tcell.Screen, matches []compMatch, selectedInd int) stri
wcol += gOpts.tabstop - wcol%gOpts.tabstop wcol += gOpts.tabstop - wcol%gOpts.tabstop
ncol := max(wtot/wcol, 1) ncol := max(wtot/wcol, 1)
b.WriteString("possible matches\n") var b strings.Builder
b.WriteString("possible matches")
for i := 0; i < mlen; { for i, match := range matches {
for j := 0; j < ncol && i < mlen; i, j = i+1, j+1 { if i%ncol == 0 {
name := matches[i].name
w := runeSliceWidth([]rune(name))
if i == selectedInd {
fmt.Fprintf(&b, "\033[7m%s\033[0m%*s", name, wcol-w, "")
} else {
fmt.Fprintf(&b, "%s%*s", name, wcol-w, "")
}
}
b.WriteByte('\n') b.WriteByte('\n')
} }
w := runeSliceWidth([]rune(match.name))
fmt.Fprintf(&b, "%s%*s", match.name, wcol-w, "")
}
return b.String() b.WriteByte('\n')
var selection *menuSelect
if selectedInd != -1 {
selection = &menuSelect{selectedInd % ncol * wcol, selectedInd/ncol + 1, matches[selectedInd].name}
}
return b.String(), selection
} }