Compare commits

65 Commits
Author SHA1 Message Date
Joe Lim 88b3c999af Fix count when parsing bottom command (#1240)
* Fix count when parsing `bottom` command

* Revert "Fix count when parsing `bottom` command"

This reverts commit a0b6bb5a13.

* Alternate implementation

* Add comment
2023-05-13 16:58:21 +03:00
Joe Lim 24e224ca65 Add jumps command for displaying the jump list (#1233)
* Add `jumps` command for displaying the jump list

* Mention jump count in documentation

* Reverse order
2023-05-13 16:43:08 +03:00
Joe Lim 2a5c54c81a Minor cleanup of reflect code (#1229) 2023-05-13 16:30:19 +03:00
dependabot[bot] db46fb2b37 Bump golang.org/x/term from 0.7.0 to 0.8.0 (#1225)
Bumps [golang.org/x/term](https://github.com/golang/term) from 0.7.0 to 0.8.0.
- [Commits](https://github.com/golang/term/compare/v0.7.0...v0.8.0)

---
updated-dependencies:
- dependency-name: golang.org/x/term
  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>
2023-05-13 16:28:33 +03:00
dependabot[bot] f036e07a5c Bump golang.org/x/sys from 0.7.0 to 0.8.0 (#1224)
Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.7.0 to 0.8.0.
- [Commits](https://github.com/golang/sys/compare/v0.7.0...v0.8.0)

---
updated-dependencies:
- dependency-name: golang.org/x/sys
  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>
2023-05-13 16:18:31 +03:00
Joe Lim 8f630e0cab Separate filter from selections in the ui ruler (#1223) 2023-05-13 14:19:50 +03:00
Joe Lim 35990bed12 Prevent scrolling to bottom when selecting files (#1222)
* Prevent scrolling to bottom when selecting files

* Use nav.currDir()
2023-05-13 13:58:03 +03:00
Gokcehan f04401ba4d build diskfree on all platforms
cc #1168
2023-04-30 22:10:15 +03:00
Gokcehan 2c86577b95 update doc
cc #1176
2023-04-30 16:40:52 +03:00
Joe Lim 4dbc15e4b0 Validate selmode setting (#1206) 2023-04-15 19:52:37 +03:00
Joe Lim c0dfb3c4f5 Fix statusbar spacing (#1205)
* Fix statusbar spacing

* Fix ruler option check
2023-04-15 19:51:51 +03:00
Gokcehan 55ad40ac0a add 'ruler' to completion
cc #1168
2023-04-09 14:58:11 +03:00
Gokcehan c1583032aa update doc
cc #1168
2023-04-09 14:54:41 +03:00
rrveexandrr eb84772032 Customizable statusline, df (#1168)
* opts statusline, df

* renamed infostat -> ruler; removed os_lin, os_bsd

* removed vscode

---------

Co-authored-by: rr <rr@arveex.eu>
2023-04-09 14:50:34 +03:00
Joe Lim 821b2fcd51 Fix crash when sorting files in a directory (#1204) 2023-04-09 14:32:40 +03:00
Joe Lim 734f11d61b Simplify edge calculation when scrolling down (#1194)
* Simplify edge calculation when scrolling down

* Alternate implementation

* Alternate implementation #2
2023-04-09 14:23:43 +03:00
RuMaks 28b550a7ec Use $VISUAL for the e command instead of $EDITOR (#1197)
* Use $VISUAL for the `e` command instead of $EDITOR

* update `os_windows.go` and `doc.go`
2023-04-09 01:44:09 +03:00
Ilya Grigoriev 1e1486fc02 Make :maps work on Windows and add :cmaps. (#1201)
* Make `:maps` work on Windows

This makes the `:maps` command from #1146 work on Windows.

This (as well as `:maps` itself) is based on @jackielli's work in #1146 and
#1152.

I intend to refactor the code in this or a separate PR, but I thought I'd
submit the critical and simple bit first.

* Add `:cmaps` command

After the naming scheme from #1146, it would seem weird to not have a :cmaps
command. This could help with issues like #876.
2023-04-09 00:51:52 +03:00
dependabot[bot] bb45d15b83 Bump golang.org/x/term from 0.6.0 to 0.7.0 (#1198)
Bumps [golang.org/x/term](https://github.com/golang/term) from 0.6.0 to 0.7.0.
- [Release notes](https://github.com/golang/term/releases)
- [Commits](https://github.com/golang/term/compare/v0.6.0...v0.7.0)

---
updated-dependencies:
- dependency-name: golang.org/x/term
  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>
2023-04-08 23:40:31 +03:00
Joe Lim b5c83dbf7a Add support for moving to a specific line (#1196)
* Add support for moving to a specific line

* Update documentation
2023-04-08 23:40:16 +03:00
Ilya Grigoriev 27d316c006 lfrc.example: Add mkdir, add "show execution result" (#1188)
Show how to map `a` to mkdir. `` ` `` maps to "show execution
result". Norton Commander & its successors map it to `<c-o>`,
but I think that's better for something opening-relatred.

Whenever a `$` command gives an unexpected error, I want to see
what happened. There are many ways to do so, but the one I added
here seems the simplest and it took me a while to think of it.
We could also have an option to have `$` commands pause like `!`
commands when there's an error.
2023-04-08 22:35:39 +03:00
Gokcehan 83af3e1cb0 add file operations to non-features in readme
close #887

cc #1179
2023-04-02 19:08:51 +03:00
Ilya Grigoriev 27ab67aab7 Make the :doc command work even if lf is not in the PATH, add lf environment variable (#1176)
* Export a `$lf` environment variable with path to lf binary

If Go fails to find a path to the lf binary, `$lf` is set to the string `lf` so
that running `$lf` in scripts gives a reasonable error message.

* Make the `:doc` command work even if lf is not in the PATH

Previously, `:doc` executed `lf -doc`. Now, it executed `$lf -doc` or `%lf%
-doc`.

Before this change, `:doc` did not work if `lf` is not in the PATH. This is
likely to happen to new users who are trying out `lf` and need docs the most.

Moreover, if you made some changes to the docs and ran `lf` with `go run .`,
`:doc` would return the docs for the version of `lf` in the PATH instead of
what is expected.
2023-04-01 19:49:47 +03:00
Joe Lim 3ae67fc361 Export count as a variable when running commands (#1187) 2023-04-01 19:40:28 +03:00
Paul Ouellette f563263add Completion: always insert longest match (#1184)
Previously, longest common match completion would only apply if there
was a word before the cursor.

Suggested in #1090
2023-04-01 19:25:55 +03:00
Paul Ouellette 70171adf40 Fix infinite loop in listMatches (#1183)
This fixes an issue where listMatches could get stuck in an infinite
loop if one of the matches was longer than the window width.

Fixes #1090
2023-04-01 19:24:55 +03:00
Joe Lim 11caeddb35 Support custom line number colors (#1177)
* Support custom line number colors

* Move eval case
2023-04-01 16:05:44 +03:00
Joe Lim 6ffc4a4c8a Display zero when relativenumber is enabled (#1171) 2023-03-25 18:35:08 +03:00
Gokcehan 0eddc1e724 cleanup
cc #845 #1169
2023-03-25 18:25:09 +03:00
Joe Lim 43fced28e3 Use tcell constants for drawbox (#1170) 2023-03-21 20:30:03 +03:00
Joe Lim 68e2433d48 Improve preview loading message flickering (#1154)
* Improve preview loading

* Change timeout to 100 milliseconds

* Add previewtimeout option

* Start preview outside other goroutines

* Revert previewtimeout option
2023-03-21 19:49:37 +03:00
dependabot[bot] 25288fd90b Bump actions/setup-go from 3 to 4 (#1160)
Bumps [actions/setup-go](https://github.com/actions/setup-go) from 3 to 4.
- [Release notes](https://github.com/actions/setup-go/releases)
- [Commits](https://github.com/actions/setup-go/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/setup-go
  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>
2023-03-20 20:11:45 +03:00
rrveexandrr 122dee1f45 Enhance rename prompt (#1162)
* enhance rename ui

* gofmt

* default rename: cursor on dot

* fix basename length

* fix basename length... again

---------

Co-authored-by: rr <rr@arveex.eu>
2023-03-20 20:11:23 +03:00
Joe Lim 8652707299 Avoid refreshing previews for async shell commands (#1164) 2023-03-20 19:59:39 +03:00
Gokcehan 41cdd02572 update doc
cc #758
2023-03-16 18:11:29 +03:00
Gokcehan 207de6a506 add errors for unexpected boolean option values
cc #758
2023-03-16 17:51:59 +03:00
Gokcehan acb5693b11 cleanup 2023-03-16 17:35:56 +03:00
Gokcehan 85512625f8 add 'true/false' syntax for boolean options
cc #758
2023-03-16 17:24:41 +03:00
Joe Lim 0bf17dd3f0 Fix width used for line numbers (#1151) 2023-03-12 15:35:23 +03:00
Joe Lim db9de4d4de Refactor code for printing directories (#1150) 2023-03-12 15:34:44 +03:00
Joe Lim 9440b1b319 Update file info after reload command (#1149)
* Update status bar after reload

* Add comment
2023-03-12 15:30:16 +03:00
Jackie Li a85ce898a1 try to fix #916 (#1146) 2023-03-12 15:24:44 +03:00
Joe Lim 9f1428582f Remove commented code (#1141) 2023-03-12 15:11:25 +03:00
Joe Lim bcd058ace2 Delete stale dircache entry during rename (#1138)
* Delete stale dircache entry during rename

* Clear `regCache` as well

* Add comment
2023-03-12 15:11:09 +03:00
dependabot[bot] 382534c4ba Bump golang.org/x/term from 0.5.0 to 0.6.0 (#1137)
Bumps [golang.org/x/term](https://github.com/golang/term) from 0.5.0 to 0.6.0.
- [Release notes](https://github.com/golang/term/releases)
- [Commits](https://github.com/golang/term/compare/v0.5.0...v0.6.0)

---
updated-dependencies:
- dependency-name: golang.org/x/term
  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>
2023-03-12 15:07:28 +03:00
dependabot[bot] c2cbc39ce5 Bump golang.org/x/sys from 0.5.0 to 0.6.0 (#1136)
Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.5.0 to 0.6.0.
- [Release notes](https://github.com/golang/sys/releases)
- [Commits](https://github.com/golang/sys/compare/v0.5.0...v0.6.0)

---
updated-dependencies:
- dependency-name: golang.org/x/sys
  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>
2023-03-12 15:04:23 +03:00
István Donkó a8e95ae40a Replace the obsolete Vue icon in the example file (#1123) 2023-03-12 15:04:07 +03:00
dependabot[bot] 3fc1db5d14 Bump github.com/gdamore/tcell/v2 (#1128)
Bumps [github.com/gdamore/tcell/v2](https://github.com/gdamore/tcell) from 2.5.4-0.20221019011350-d3cbfcfb7aa3 to 2.6.0.
- [Release notes](https://github.com/gdamore/tcell/releases)
- [Commits](https://github.com/gdamore/tcell/commits/v2.6.0)

---
updated-dependencies:
- dependency-name: github.com/gdamore/tcell/v2
  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>
2023-02-26 01:04:32 +03:00
Ilya Grigoriev 7a7e81e88c Update the Go version in go.mod to 1.18 (#1132)
* Replace functions from `ioutil` with same functions from `io`

This is demanded by staticcheck if we upgrade the go version in go.mod.

* Replace ioutil.ReadDir with os.ReadDir

* Update Go version to 1.18 in go.mod

This requires abandoning use of the `ioutil` module (see parent commits)
to pass `staticcheck`.
2023-02-26 01:01:04 +03:00
Ilya Grigoriev b02fd42df4 invert-below command to substitute for visual mode (#1101)
This command inverts the selection for the current file and all the files below
it. Using this command twice substitutes for having a "visual" mode. This is
described in more detail in the docs and in
https://github.com/gokcehan/lf/issues/477#issuecomment-1414563834.

Fixes #477. While that's not exactly what was asked for, I hope it's a suitable
replacement and seems more in the spirit of `lf`, at least until a better
replacement is implemented.
2023-02-26 01:00:54 +03:00
Gokcehan 752f059068 remove older than go1.17 instructions from readme 2023-02-25 23:25:52 +03:00
Gokcehan 326930f46f change go version from 1.17 to 1.18 2023-02-25 23:19:07 +03:00
dependabot[bot] 6c3366eec4 Bump actions/checkout from 2 to 3 (#1129)
Bumps [actions/checkout](https://github.com/actions/checkout) from 2 to 3.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v2...v3)

---
updated-dependencies:
- dependency-name: actions/checkout
  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>
2023-02-25 23:12:56 +03:00
dependabot[bot] 28936c7506 Bump dominikh/staticcheck-action from 1.2.0 to 1.3.0 (#1127)
Bumps [dominikh/staticcheck-action](https://github.com/dominikh/staticcheck-action) from 1.2.0 to 1.3.0.
- [Release notes](https://github.com/dominikh/staticcheck-action/releases)
- [Changelog](https://github.com/dominikh/staticcheck-action/blob/master/CHANGES.md)
- [Commits](https://github.com/dominikh/staticcheck-action/compare/v1.2.0...v1.3.0)

---
updated-dependencies:
- dependency-name: dominikh/staticcheck-action
  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>
2023-02-25 23:12:18 +03:00
dependabot[bot] 960f23c288 Bump actions/setup-go from 2 to 3 (#1126)
Bumps [actions/setup-go](https://github.com/actions/setup-go) from 2 to 3.
- [Release notes](https://github.com/actions/setup-go/releases)
- [Commits](https://github.com/actions/setup-go/compare/v2...v3)

---
updated-dependencies:
- dependency-name: actions/setup-go
  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>
2023-02-25 23:10:47 +03:00
sitiom 95a6f9584f Add Winget Releaser workflow (#1107)
* Add Winget Releaser workflow

* Add dependabot

* Update release.yml
2023-02-25 23:01:00 +03:00
David Pedersen cae576bb1d Navigate cmd history with up/down (#1112) 2023-02-25 20:41:32 +03:00
Ilya Grigoriev 6afefa5d09 Option to change look of cursors in parent dirs, rename an option. (#1106)
* Add `cursorparentfmt` option for cursors in parent dirs

The option defaults to the same value as `cursorfmt`, so the default look of `lf` is unchanged. However, I find it useful to make it different, since I seem to have so much trouble figuring out which of my cursors is the active one. :)

For example, here's what it looks like if one has `set cursorparentfmt "\033[7;90m"` in their `lfrc`:

https://user-images.githubusercontent.com/4123047/218299130-09ac411f-307a-489e-a4f0-4691710f8549.png

* Remove `cursorfmt` option to `cursoractivefmt`

This seems appropriate after introducing `cursorparentfmt`
2023-02-25 20:38:41 +03:00
Joe Lim c0c85f206f Fix documentation for dironly/dirpreviews options (#1105) 2023-02-12 14:38:58 +03:00
Ilya Grigoriev 530ab2c40a Allow separate styles for cursor in normal and preview panes, simplify tagfmt and errorfmt (#1086)
* Allow separate styles for cursor in normal and preview panes

This defines new `cursorfmt` and `crusorpreviewfmt` options to style cursor in normal/preview panes. This allows using a different style for the normal and preview cursor. The documentation includes several possible values these options can be set to.

The default behavior is an underline, same as in
https://github.com/gokcehan/lf/pull/1072, since it should not cause severe
problems and be visible on all terminals. It can now be easily changed, as explained in the docs. I also added an example to `etc/lfrc.example`.

See linked issues and PRs for the more context.

Fixes https://github.com/gokcehan/lf/issues/1038

Follows up on:

https://github.com/gokcehan/lf/pull/1072
https://github.com/gokcehan/lf/pull/924
https://github.com/gokcehan/lf/commit/b47cf6d5a5

* Simplify configuration of several formatting options

This simplifies the configuration of `cursorfmt`, `cursorpreviewfmt`, `tagfmt`,
and `errorfmt` options.

In almost all usecases, the value of these options had to end with `%s\033[0m`
to print the contents of filename/tag/error and reset the terminal style. Now,
if `%s` is not part of the option's value, `%s\033[0m` is appended
automatically. This simplifies configuration.

I retained the same behavior as before when `%s` is part of the string for
backwards compatibility. I think it should be considered deprecated, but it
also causes no harm.
2023-02-11 20:11:07 +03:00
Joe Lim 4a443cae58 Refresh preview even if selection doesn't change (#1074) 2023-02-11 20:01:46 +03:00
valoq 0b99aaed4e Add example to hiddenfiles documentation (#1073)
* Improve documentation

* fix missing quote

* update manpage
2023-02-11 20:01:20 +03:00
Ilya Grigoriev 6440281e82 Disallow exiting from rename: mode with backspace (#1060)
After looking at the list of possibilities for `app.ui.cmdPrefix` by searching
through the code, renaming looks to be the only remaining mode where exiting
via backspace doesn't make sense.

In particular, I don't think any commands other than `rename` commonly start
out with some editable text in the prompt. The other dangerous mode is the `>`
mode, but there exit-on-backspace was already disabled.

Fixes #1052, #1059
2023-02-11 20:00:08 +03:00
Ilya Grigoriev 2fe5e4d54e Bind Ctrl+MouseWheel to scroll up/down (#1051)
On my system, Shift+Mouse is captured by the terminal and
Alt+Mouse only works for one of the alt keys. Hence I picked
Ctrl.

This also allows binding of Ctrl+MouseButtons (but doesn't set
any such bindings). 

As a minor bonus, that should allow using Ctrl+Click to select
`lf`'s terminal without moving the cursor no matter where you
click.  On tmux, this doesn't work out of the box and requires
a change to `tmux.conf` along the following lines:

     bind-key -T root  C-MouseDown1Pane  select-pane -t = \; send-keys -M

You can omit the `send-keys -M` if you never want to pass
`Ctrl+Click` to any of your terminal apps. (Then it will work
without this PR).
2023-02-11 19:58:44 +03:00
Ilya Grigoriev a4fa5d36c9 Make lfcd examples safer for people who alias lf to lfcd (#1049)
People keep running into an infinite loop and being confused.
See https://github.com/gokcehan/lf/issues/140#issuecomment-1256368250
and https://github.com/gokcehan/lf/discussions/1043.

This fixes the issues in `lfcd.sh` and `lfcd.fish`. For the other
scripts, I'm not sure whether this issue exists or is fixable.

One of the discussions above also suggested the need to document
the key binding better.
2023-02-11 19:55:49 +03:00
28 changed files with 1666 additions and 650 deletions

No files matched your search

+10
View File
@@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "daily"
+6 -6
View File
@@ -14,14 +14,14 @@ jobs:
matrix: matrix:
os: [ubuntu-latest, windows-latest] os: [ubuntu-latest, windows-latest]
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
with: with:
fetch-depth: 1 fetch-depth: 1
- name: Set up Go - name: Set up Go
uses: actions/setup-go@v2 uses: actions/setup-go@v4
with: with:
go-version: 1.17 go-version: 1.18
- name: Build - name: Build
run: go build -v ./... run: go build -v ./...
@@ -29,7 +29,7 @@ jobs:
- name: Test - name: Test
run: go test -v ./... run: go test -v ./...
- uses: dominikh/staticcheck-action@v1.2.0 - uses: dominikh/staticcheck-action@v1.3.0
with: with:
version: "2022.1.3" version: "2022.1.3"
install-go: false install-go: false
@@ -37,12 +37,12 @@ jobs:
generate: generate:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
with: with:
fetch-depth: 1 fetch-depth: 1
- name: Set up Go - name: Set up Go
uses: actions/setup-go@v2 uses: actions/setup-go@v4
with: with:
go-version: 1.19 go-version: 1.19
+14 -3
View File
@@ -10,12 +10,12 @@ jobs:
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- name: Set up Go - name: Set up Go
uses: actions/setup-go@v2 uses: actions/setup-go@v4
with: with:
go-version: 1.17 go-version: 1.18
- name: Build - name: Build
run: gen/xbuild.sh run: gen/xbuild.sh
@@ -26,3 +26,14 @@ jobs:
files: dist/* files: dist/*
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
winget:
runs-on: windows-latest # Action can only run on Windows
needs: build
steps:
- uses: vedantmgoyal2009/winget-releaser@v2
with:
identifier: gokcehan.lf
version: ${{ github.ref_name }}
installers-regex: '-windows-\w+\.zip$'
token: ${{ secrets.WINGET_TOKEN }}
+4 -25
View File
@@ -31,6 +31,7 @@ See [faq](https://github.com/gokcehan/lf/wiki/FAQ) for more information and [tut
- Tabs or windows (better handled by window manager or terminal multiplexer) - Tabs or windows (better handled by window manager or terminal multiplexer)
- Builtin pager/editor (better handled by your pager/editor of choice) - Builtin pager/editor (better handled by your pager/editor of choice)
- Builtin commands for file operations (better handled by the underlying shell tools including but not limited to `mkdir`, `touch`, `chmod`, `chown`, `chgrp`, and `ln`)
## Installation ## Installation
@@ -40,42 +41,20 @@ See [releases](https://github.com/gokcehan/lf/releases) for pre-built binaries.
Building from the source requires [Go](https://go.dev/). Building from the source requires [Go](https://go.dev/).
On Unix (Go version < 1.17): On Unix:
```bash
env CGO_ENABLED=0 GO111MODULE=on go get -u -ldflags="-s -w" github.com/gokcehan/lf
```
On Unix (Go version >= 1.17):
```bash ```bash
env CGO_ENABLED=0 go install -ldflags="-s -w" github.com/gokcehan/lf@latest env CGO_ENABLED=0 go install -ldflags="-s -w" github.com/gokcehan/lf@latest
``` ```
On Windows `cmd` (Go version < 1.17): On Windows `cmd`:
```cmd
set CGO_ENABLED=0
set GO111MODULE=on
go get -u -ldflags="-s -w" github.com/gokcehan/lf
```
On Windows `cmd` (Go version >= 1.17):
```cmd ```cmd
set CGO_ENABLED=0 set CGO_ENABLED=0
go install -ldflags="-s -w" github.com/gokcehan/lf@latest go install -ldflags="-s -w" github.com/gokcehan/lf@latest
``` ```
On Windows `powershell` (Go version < 1.17): On Windows `powershell`:
```powershell
$env:CGO_ENABLED = '0'
$env:GO111MODULE = 'on'
go get -u -ldflags="-s -w" github.com/gokcehan/lf
```
On Windows `powershell` (Go version >= 1.17):
```powershell ```powershell
$env:CGO_ENABLED = '0' $env:CGO_ENABLED = '0'
+45 -3
View File
@@ -467,10 +467,17 @@ func (app *app) loop() {
app.nav.renew() app.nav.renew()
app.ui.loadFile(app, false) app.ui.loadFile(app, false)
app.ui.draw(app.nav) app.ui.draw(app.nav)
case <-app.nav.previewTimer.C:
app.nav.previewLoading = true
app.ui.draw(app.nav)
} }
} }
} }
type cleanFunc func()
var noopCleanFunc = func() {}
// This function is used to run a shell command. Modes are as follows: // This function is used to run a shell command. Modes are as follows:
// //
// Prefix Wait Async Stdin Stdout Stderr UI action // Prefix Wait Async Stdin Stdout Stderr UI action
@@ -478,7 +485,8 @@ func (app *app) loop() {
// % No No Yes Yes Yes Statline for input/output // % No No Yes Yes Yes Statline for input/output
// ! Yes No Yes Yes Yes Pause and then resume // ! Yes No Yes Yes Yes Pause and then resume
// & No Yes No No No Do nothing // & No Yes No No No Do nothing
func (app *app) runShell(s string, args []string, prefix string) { // $| No No Pipe Yes Yes Pause, Pipe execute, return cleanup to resume
func (app *app) runShell(s string, args []string, prefix string) cleanFunc {
app.nav.exportFiles() app.nav.exportFiles()
app.ui.exportSizes() app.ui.exportSizes()
exportOpts() exportOpts()
@@ -488,6 +496,24 @@ func (app *app) runShell(s string, args []string, prefix string) {
var out io.Reader var out io.Reader
var err error var err error
switch prefix { switch prefix {
case "$|":
var stdin io.WriteCloser
stdin, err = cmd.StdinPipe()
if err != nil {
log.Printf("writing stdin: %s", err)
}
app.cmdIn = stdin
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
app.nav.previewChan <- ""
app.nav.dirPreviewChan <- nil
if err := app.ui.suspend(); err != nil {
log.Printf("suspend: %s", err)
}
err = cmd.Start()
case "$", "!": case "$", "!":
cmd.Stdin = os.Stdin cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout cmd.Stdout = os.Stdout
@@ -512,7 +538,7 @@ func (app *app) runShell(s string, args []string, prefix string) {
case "%": case "%":
shellSetPG(cmd) shellSetPG(cmd)
if app.ui.cmdPrefix == ">" { if app.ui.cmdPrefix == ">" {
return return noopCleanFunc
} }
stdin, err := cmd.StdinPipe() stdin, err := cmd.StdinPipe()
if err != nil { if err != nil {
@@ -540,7 +566,11 @@ func (app *app) runShell(s string, args []string, prefix string) {
anyKey() anyKey()
} }
app.ui.loadFile(app, true) // Asynchronous shell invocations return immediately without waiting for the
// command to finish, so there is no point refreshing the preview if nothing
// has changed yet.
volatile := prefix != "&"
app.ui.loadFile(app, volatile)
switch prefix { switch prefix {
case "%": case "%":
@@ -585,5 +615,17 @@ func (app *app) runShell(s string, args []string, prefix string) {
log.Printf("running shell: %s", err) log.Printf("running shell: %s", err)
} }
}() }()
case "$|":
return func() {
if err := cmd.Wait(); err != nil {
log.Printf("running shell: %s", err)
} }
app.nav.renew()
if err := app.ui.resume(); err != nil {
app.quit()
os.Exit(3)
}
}
}
return noopCleanFunc
} }
+1 -2
View File
@@ -4,7 +4,6 @@ import (
"bufio" "bufio"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"log" "log"
"net" "net"
"os" "os"
@@ -34,7 +33,7 @@ func run() {
defer f.Close() defer f.Close()
log.SetOutput(f) log.SetOutput(f)
} else { } else {
log.SetOutput(ioutil.Discard) log.SetOutput(io.Discard)
} }
log.Print("hi!") log.Print("hi!")
+22 -14
View File
@@ -1,7 +1,6 @@
package main package main
import ( import (
"io/ioutil"
"log" "log"
"os" "os"
"path/filepath" "path/filepath"
@@ -13,7 +12,9 @@ var (
gCmdWords = []string{ gCmdWords = []string{
"set", "set",
"map", "map",
"maps",
"cmap", "cmap",
"cmaps",
"cmd", "cmd",
"quit", "quit",
"up", "up",
@@ -28,6 +29,7 @@ var (
"open", "open",
"jump-next", "jump-next",
"jump-prev", "jump-prev",
"jumps",
"top", "top",
"bottom", "bottom",
"high", "high",
@@ -35,6 +37,7 @@ var (
"low", "low",
"toggle", "toggle",
"invert", "invert",
"invert-below",
"unselect", "unselect",
"glob-select", "glob-select",
"glob-unselect", "glob-unselect",
@@ -113,6 +116,9 @@ var (
"autoquit", "autoquit",
"noautoquit", "noautoquit",
"autoquit!", "autoquit!",
"cursoractivefmt",
"cursorparentfmt",
"cursorpreviewfmt",
"dircache", "dircache",
"nodircache", "nodircache",
"dircache!", "dircache!",
@@ -167,6 +173,7 @@ var (
"reverse", "reverse",
"noreverse", "noreverse",
"reverse!", "reverse!",
"ruler",
"smartcase", "smartcase",
"nosmartcase", "nosmartcase",
"smartcase!", "smartcase!",
@@ -190,6 +197,7 @@ var (
"history", "history",
"ifs", "ifs",
"info", "info",
"numberfmt",
"previewer", "previewer",
"cleaner", "cleaner",
"promptfmt", "promptfmt",
@@ -249,7 +257,7 @@ func matchExec(s string) (matches []string, longest []rune) {
continue continue
} }
files, err := ioutil.ReadDir(p) files, err := os.ReadDir(p)
if err != nil { if err != nil {
log.Printf("reading path: %s", err) log.Printf("reading path: %s", err)
} }
@@ -259,18 +267,18 @@ func matchExec(s string) (matches []string, longest []rune) {
continue continue
} }
f, err = os.Stat(filepath.Join(p, f.Name())) finfo, err := f.Info()
if err != nil { if err != nil {
log.Printf("getting file information: %s", err) log.Printf("getting file information: %s", err)
continue continue
} }
if !f.Mode().IsRegular() || !isExecutable(f) { if !finfo.Mode().IsRegular() || !isExecutable(finfo) {
continue continue
} }
log.Print(f.Name()) log.Print(finfo.Name())
words = append(words, f.Name()) words = append(words, finfo.Name())
} }
} }
@@ -303,7 +311,7 @@ func matchFile(s string) (matches []string, longest []rune) {
dir = filepath.Dir(unescape(dir)) dir = filepath.Dir(unescape(dir))
files, err := ioutil.ReadDir(dir) files, err := os.ReadDir(dir)
if err != nil { if err != nil {
log.Printf("reading directory: %s", err) log.Printf("reading directory: %s", err)
} }
@@ -334,14 +342,14 @@ func matchFile(s string) (matches []string, longest []rune) {
} }
matches = append(matches, item) matches = append(matches, item)
if longest != nil { if longest == nil {
longest = matchLongest(longest, []rune(name))
} else if s != "" {
if f.Mode().IsRegular() { if f.Mode().IsRegular() {
longest = []rune(name + " ") longest = []rune(name + " ")
} else { } else {
longest = []rune(name + escape(string(filepath.Separator))) longest = []rune(name + escape(string(filepath.Separator)))
} }
} else {
longest = matchLongest(longest, []rune(name))
} }
} }
@@ -421,7 +429,7 @@ func completeFile(acc []rune) (matches []string, longestAcc []rune) {
log.Printf("getting current directory: %s", err) log.Printf("getting current directory: %s", err)
} }
files, err := ioutil.ReadDir(wd) files, err := os.ReadDir(wd)
if err != nil { if err != nil {
log.Printf("reading directory: %s", err) log.Printf("reading directory: %s", err)
} }
@@ -433,10 +441,10 @@ func completeFile(acc []rune) (matches []string, longestAcc []rune) {
matches = append(matches, f.Name()) matches = append(matches, f.Name())
if longestAcc != nil { if longestAcc == nil {
longestAcc = matchLongest(longestAcc, []rune(f.Name()))
} else if s != "" {
longestAcc = []rune(f.Name()) longestAcc = []rune(f.Name())
} else {
longestAcc = matchLongest(longestAcc, []rune(f.Name()))
} }
} }
+19
View File
@@ -0,0 +1,19 @@
package main
import (
"log"
"golang.org/x/sys/unix"
)
func diskFree(wd string) string {
var stat unix.Statfs_t
if err := unix.Statfs(wd, &stat); err != nil {
log.Printf("diskfree: %s", err)
return ""
}
// Available blocks * size per block = available space in bytes
return "df: " + humanize(int64(uint64(stat.F_bavail)*uint64(stat.F_bsize)))
}
+21
View File
@@ -0,0 +1,21 @@
//go:build darwin || dragonfly || freebsd || linux
package main
import (
"log"
"golang.org/x/sys/unix"
)
func diskFree(wd string) string {
var stat unix.Statfs_t
if err := unix.Statfs(wd, &stat); err != nil {
log.Printf("diskfree: %s", err)
return ""
}
// Available blocks * size per block = available space in bytes
return "df: " + humanize(int64(uint64(stat.Bavail)*uint64(stat.Bsize)))
}
+21
View File
@@ -0,0 +1,21 @@
//go:build illumos || netbsd || solaris
package main
import (
"log"
"golang.org/x/sys/unix"
)
func diskFree(wd string) string {
var stat unix.Statvfs_t
if err := unix.Statvfs(wd, &stat); err != nil {
log.Printf("diskfree: %s", err)
return ""
}
// Available blocks * size per block = available space in bytes
return "df: " + humanize(int64(uint64(stat.Bavail)*uint64(stat.Bsize)))
}
+23
View File
@@ -0,0 +1,23 @@
package main
import (
"log"
"golang.org/x/sys/windows"
)
func diskFree(wd string) string {
var free uint64
pathPtr, err := windows.UTF16PtrFromString(wd)
if err != nil {
log.Printf("diskfree: %s", err)
return ""
}
err = windows.GetDiskFreeSpaceEx(pathPtr, &free, nil, nil) // cwd, free, total, available
if err != nil {
log.Printf("diskfree: %s", err)
return ""
}
return "df: " + humanize(int64(free))
}
+153 -71
View File
@@ -36,6 +36,7 @@ The following commands are provided by lf:
low (default 'L') low (default 'L')
toggle toggle
invert (default 'v') invert (default 'v')
invert-below
unselect (default 'u') unselect (default 'u')
glob-select glob-select
glob-unselect glob-unselect
@@ -78,6 +79,9 @@ The following commands are provided by lf:
mark-remove (modal) (default '"') mark-remove (modal) (default '"')
tag tag
tag-toggle (default 't') tag-toggle (default 't')
maps
cmaps
jumps
The following command line commands are provided by lf: The following command line commands are provided by lf:
@@ -88,8 +92,8 @@ The following command line commands are provided by lf:
cmd-menu-accept cmd-menu-accept
cmd-enter (default '<c-j>' and '<enter>') cmd-enter (default '<c-j>' and '<enter>')
cmd-interrupt (default '<c-c>') cmd-interrupt (default '<c-c>')
cmd-history-next (default '<c-n>') cmd-history-next (default '<c-n>' and '<down>')
cmd-history-prev (default '<c-p>') cmd-history-prev (default '<c-p>' and '<up>')
cmd-left (default '<c-b>' and '<left>') cmd-left (default '<c-b>' and '<left>')
cmd-right (default '<c-f>' and '<right>') cmd-right (default '<c-f>' and '<right>')
cmd-home (default '<c-a>' and '<home>') cmd-home (default '<c-a>' and '<home>')
@@ -111,56 +115,61 @@ The following command line commands are provided by lf:
The following options can be used to customize the behavior of lf: The following options can be used to customize the behavior of lf:
anchorfind bool (default on) anchorfind bool (default true)
autoquit bool (default off) autoquit bool (default false)
cleaner string (default '') cleaner string (default '')
dircache bool (default on) cursoractivefmt string (default "\033[7m")
dircounts bool (default off) cursorparentfmt string (default "\033[7m")
dirfirst bool (default on) cursorpreviewfmt string (default "\033[4m")
dironly bool (default off) dircache bool (default true)
dirpreviews bool (default off) dircounts bool (default false)
drawbox bool (default off) dirfirst bool (default true)
errorfmt string (default "\033[7;31;47m%s\033[0m") dironly bool (default false)
dirpreviews bool (default false)
drawbox bool (default false)
errorfmt string (default "\033[7;31;47m")
filesep string (default "\n") filesep string (default "\n")
findlen int (default 1) findlen int (default 1)
globsearch bool (default off) globsearch bool (default false)
hidden bool (default off) hidden bool (default false)
hiddenfiles []string (default '.*') hiddenfiles []string (default '.*')
history bool (default on) history bool (default true)
icons bool (default off) icons bool (default false)
ifs string (default '') ifs string (default '')
ignorecase bool (default on) ignorecase bool (default true)
ignoredia bool (default on) ignoredia bool (default true)
incfilter bool (default off) incfilter bool (default false)
incsearch bool (default off) incsearch bool (default false)
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')
mouse bool (default off) mouse bool (default false)
number bool (default off) number bool (default false)
numberfmt string (default "\033[33m")
period int (default 0) period int (default 0)
preview bool (default on) preview bool (default true)
previewer string (default '') previewer string (default '')
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")
ratios []int (default '1:2:3') ratios []int (default '1:2:3')
relativenumber bool (default off) relativenumber bool (default false)
reverse bool (default off) reverse bool (default false)
ruler []string (default 'acc:progress:selection:filter:ind')
scrolloff int (default 0) scrolloff int (default 0)
selmode string (default 'all') selmode string (default 'all')
shell string (default 'sh' for Unix and 'cmd' for Windows) shell string (default 'sh' for Unix and 'cmd' for Windows)
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 '')
smartcase bool (default on) smartcase bool (default true)
smartdia bool (default off) smartdia bool (default false)
sortby string (default 'natural') sortby string (default 'natural')
tabstop int (default 8) tabstop int (default 8)
tagfmt string (default "\033[31m%s\033[0m") tagfmt string (default "\033[31m")
tempmarks string (default '') tempmarks string (default '')
timefmt string (default 'Mon Jan _2 15:04:05 2006') timefmt string (default 'Mon Jan _2 15:04:05 2006')
truncatechar string (default '~') truncatechar string (default '~')
waitmsg string (default 'Press any key to continue') waitmsg string (default 'Press any key to continue')
wrapscan bool (default on) wrapscan bool (default true)
wrapscroll bool (default off) wrapscroll bool (default false)
user_{option} string (default none) user_{option} string (default none)
The following environment variables are exported for shell commands: The following environment variables are exported for shell commands:
@@ -173,13 +182,16 @@ The following environment variables are exported for shell commands:
OLDPWD OLDPWD
LF_LEVEL LF_LEVEL
OPENER OPENER
VISUAL
EDITOR EDITOR
PAGER PAGER
SHELL SHELL
lf
lf_{option} lf_{option}
lf_user_{option} lf_user_{option}
lf_width lf_width
lf_height lf_height
lf_count
The following special shell commands are used to customize the behavior of lf when defined: The following special shell commands are used to customize the behavior of lf when defined:
@@ -226,7 +238,7 @@ If the 'mouse' option is enabled, mouse buttons have the following default effec
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 window.
Scroll wheel Scroll wheel
Scroll up or down. Move up or down. If Ctrl is pressed, scroll up or down.
# Configuration # Configuration
@@ -317,6 +329,7 @@ Change the current working directory to the next/previous jumplist item.
bottom (default 'G' and '<end>') bottom (default 'G' and '<end>')
Move the current file selection to the top/bottom of the directory. Move the current file selection to the top/bottom of the directory.
A count can be specified to move to a specific line, for example use `3G` to move to the third line.
high (default 'H') high (default 'H')
middle (default 'M') middle (default 'M')
@@ -334,6 +347,17 @@ Reverse the selection of all files in the current directory (i.e. 'toggle' all f
Selections in other directories are not effected by this command. Selections in other directories are not effected by this command.
You can define a new command to select all files in the directory by combining 'invert' with 'unselect' (i.e. 'cmd select-all :unselect; invert'), though this will also remove selections in other directories. You can define a new command to select all files in the directory by combining 'invert' with 'unselect' (i.e. 'cmd select-all :unselect; invert'), though this will also remove selections in other directories.
invert-below
Reverse the selection (i.e. 'toggle') of all files at or after the current file in the current directory.
To select a contiguous block of files, use this command on the first file you want to select.
Then, move down to the first file you do *not* want to select (the one after the end of the desired selection) and use this command again.
This achieves an effect similar to the visual mode in vim.
This command is experimental and may be removed once a better replacement for the visual mode is implemented in 'lf'.
If you'd like to experiment with using this command, you should bind it to a key (e.g. 'V') for a better experience.
unselect (default 'u') unselect (default 'u')
Remove the selection of all files in all directories. Remove the selection of all files in all directories.
@@ -528,8 +552,8 @@ Execute the current line.
Interrupt the current shell-pipe command and return to the normal mode. Interrupt the current shell-pipe command and return to the normal mode.
cmd-history-next (default '<c-n>') cmd-history-next (default '<c-n>' and '<down>')
cmd-history-prev (default '<c-p>') cmd-history-prev (default '<c-p>' and '<up>')
Go to next/previous item in the history. Go to next/previous item in the history.
@@ -585,16 +609,27 @@ Delete the next word in forward direction.
Capitalize/uppercase/lowercase the current word and jump to the next word. Capitalize/uppercase/lowercase the current word and jump to the next word.
maps
cmaps
List all key mappings in normal mode or command-line editing mode.
jumps
List the contents of the jump list, in order of the most recently visited locations.
Each location is marked with the count that can be used with the `jump-prev` and `jump-next` commands (e.g. use `3[` to move three spaces backwards in the jump list).
A '>' is used to mark the current location in the jump list.
# Options # Options
This section shows information about options to customize the behavior. This section shows information about options to customize the behavior.
Character ':' is used as the separator for list options '[]int' and '[]string'. Character ':' is used as the separator for list options '[]int' and '[]string'.
anchorfind bool (default on) anchorfind bool (default true)
When this option is enabled, find command starts matching patterns from the beginning of file names, otherwise, it can match at an arbitrary position. When this option is enabled, find command starts matching patterns from the beginning of file names, otherwise, it can match at an arbitrary position.
autoquit bool (default off) autoquit bool (default false)
Automatically quit server when there are no clients left connected. Automatically quit server when there are no clients left connected.
@@ -606,11 +641,27 @@ This file is called if previewing is enabled, the previewer is set, and the prev
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 file name, (2) width, (3) height, (4) horizontal position, and (5) vertical position of preview pane respectively.
Preview clearing is disabled when the value of this option is left empty. Preview clearing is disabled when the value of this option is left empty.
dircache bool (default on) cursoractivefmt string (default "\033[7m")
cursorparentfmt string (default "\033[7m")
cursorpreviewfmt string (default "\033[4m")
Format strings for highlighting the cursor.
`cursoractivefmt` applies in the current directory pane,
`cursorparentfmt` applies in panes that show parents of the current directory,
and `cursorpreviewfmt` applies in panes that preview directories.
The default is to make the active cursor and the parent directory cursor inverted. The preview cursor is underlined.
Some other possibilities to consider for the preview or parent cursors: an empty string for no cursor, "\033[7;2m" for dimmed inverted text (visibility varies by terminal), "\033[7;90m" for inverted text with grey (aka "brightblack") background.
If the format string contains the characters `%s`, it is interpreted as a format string for `fmt.Sprintf`. Such a string should end with the terminal reset sequence.
For example, "\033[4m%s\033[0m" has the same effect as "\033[4m".
dircache bool (default true)
Cache directory contents. Cache directory contents.
dircounts bool (default off) 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'.
This information needs to be calculated by reading the directory and counting the items inside. This information needs to be calculated by reading the directory and counting the items inside.
@@ -618,26 +669,29 @@ Therefore, this option is disabled by default for performance reasons.
This option only has an effect when 'info' has a 'size' field and the pane is wide enough to show the information. This option only has an effect when 'info' has a 'size' field and the pane is wide enough to show the information.
999 items are counted per directory at most, and bigger directories are shown as '999+'. 999 items are counted per directory at most, and bigger directories are shown as '999+'.
dirfirst bool (default on) dirfirst bool (default true)
Show directories first above regular files. Show directories first above regular files.
dironly bool (default off) dironly bool (default false)
If enabled, directories will also be passed to the previewer script. This allows custom previews for directories.
dirpreviews bool (default off)
Show only directories. Show only directories.
drawbox bool (default off) dirpreviews bool (default false)
If enabled, directories will also be passed to the previewer script. This allows custom previews for directories.
drawbox bool (default false)
Draw boxes around panes with box drawing characters. Draw boxes around panes with box drawing characters.
errorfmt string (default "\033[7;31;47m%s\033[0m") errorfmt string (default "\033[7;31;47m")
Format string of error messages shown in the bottom message line. Format string of error messages shown in the bottom message line.
If the format string contains the characters `%s`, it is interpreted as a format string for `fmt.Sprintf`. Such a string should end with the terminal reset sequence.
For example, "\033[4m%s\033[0m" has the same effect as "\033[4m".
filesep string (default "\n") filesep string (default "\n")
File separator used in environment variables 'fs' and 'fx'. File separator used in environment variables 'fs' and 'fx'.
@@ -647,13 +701,13 @@ File separator used in environment variables 'fs' and 'fx'.
Number of characters prompted for the find command. Number of characters prompted for the find command.
When this value is set to 0, find command prompts until there is only a single match left. When this value is set to 0, find command prompts until there is only a single match left.
globsearch bool (default off) globsearch bool (default false)
When this option is enabled, search command patterns are considered as globs, otherwise they are literals. When this option is enabled, search command patterns are considered as globs, otherwise they are literals.
With globbing, '*' matches any sequence, '?' matches any character, and '[...]' or '[^...] matches character sets or ranges. With globbing, '*' matches any sequence, '?' matches any character, and '[...]' or '[^...]' matches character sets or ranges.
Otherwise, these characters are interpreted as they are. Otherwise, these characters are interpreted as they are.
hidden bool (default off) hidden bool (default false)
Show hidden files. Show hidden files.
On Unix systems, hidden files are determined by the value of 'hiddenfiles'. On Unix systems, hidden files are determined by the value of 'hiddenfiles'.
@@ -663,14 +717,14 @@ On Windows, only files with hidden attributes are considered hidden files.
List of hidden file glob patterns. List of hidden file glob patterns.
Patterns can be given as relative or absolute paths. Patterns can be given as relative or absolute paths.
Globbing supports the usual special characters, '*' to match any sequence, '?' to match any character, and '[...]' or '[^...] to match character sets or ranges. Globbing supports the usual special characters, '*' to match any sequence, '?' to match any character, and '[...]' or '[^...]' to match character sets or ranges.
In addition, if a pattern starts with '!', then its matches are excluded from hidden files. In addition, if a pattern starts with '!', then its matches are excluded from hidden files. To add multiple patterns, use ':' as a separator. Example: '.*:lost+found:*.bak'
history bool (default on) history bool (default true)
Save command history. Save command history.
icons bool (default off) icons bool (default false)
Show icons before each item in the list. Show icons before each item in the list.
@@ -683,19 +737,19 @@ This method assumes a POSIX shell syntax and so it can fail for non-POSIX shells
This option has no effect when the value is left empty. This option has no effect when the value is left empty.
This option does not have any effect on Windows. This option does not have any effect on Windows.
ignorecase bool (default on) ignorecase bool (default true)
Ignore case in sorting and search patterns. Ignore case in sorting and search patterns.
ignoredia bool (default on) ignoredia bool (default true)
Ignore diacritics in sorting and search patterns. Ignore diacritics in sorting and search patterns.
incsearch bool (default off) incsearch bool (default false)
Jump to the first match after each keystroke during searching. Jump to the first match after each keystroke during searching.
incfilter bool (default off) incfilter bool (default false)
Apply filter pattern after each keystroke during filtering. Apply filter pattern after each keystroke during filtering.
@@ -713,15 +767,19 @@ 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.
mouse bool (default off) mouse bool (default false)
Send mouse events as input. Send mouse events as input.
number bool (default off) number bool (default false)
Show the position number for directory items at the left side of pane. Show the position number for directory items at the left side of pane.
When 'relativenumber' option is enabled, only the current line shows the absolute position and relative positions are shown for the rest. When 'relativenumber' option is enabled, only the current line shows the absolute position and relative positions are shown for the rest.
numberfmt string (default "\033[33m")
Format string of the position number for each line.
period int (default 0) period int (default 0)
Set the interval in seconds for periodic checks of directory updates. Set the interval in seconds for periodic checks of directory updates.
@@ -730,7 +788,7 @@ Note that directories are already updated automatically in many cases.
This option can be useful when there is an external process changing the displayed directory and you are not doing anything in lf. This option can be useful when there is an external process changing the displayed directory and you are not doing anything in lf.
Periodic checks are disabled when the value of this option is set to zero. Periodic checks are disabled when the value of this option is set to zero.
preview bool (default on) preview bool (default true)
Show previews of files and directories at the right most pane. Show previews of files and directories at the right most pane.
If the file has more lines than the preview pane, rest of the lines are not read. If the file has more lines than the preview pane, rest of the lines are not read.
@@ -759,15 +817,26 @@ List of ratios of pane widths.
Number of items in the list determines the number of panes in the ui. Number of items in the list determines the number of panes in the ui.
When 'preview' option is enabled, the right most number is used for the width of preview pane. When 'preview' option is enabled, the right most number is used for the width of preview pane.
relativenumber bool (default off) relativenumber bool (default false)
Show the position number relative to the current line. Show the position number relative to the current line.
When 'number' is enabled, current line shows the absolute position, otherwise nothing is shown. When 'number' is enabled, current line shows the absolute position, otherwise nothing is shown.
reverse bool (default off) reverse bool (default false)
Reverse the direction of sort. Reverse the direction of sort.
ruler []string (default 'acc:progress:selection:filter:ind')
List of information shown in status line ruler.
Currently supported information types are 'acc', 'progress', 'selection', 'ind' and 'df'.
`acc` shows the pressed keys (e.g. for bindings with multiple key presses or counts given to bindings).
`progress` shows the progress of file operations (e.g. copying a large directory).
`selection` shows the number of files that are selected, or designated for being cut/copied.
`filter` shows 'F' if a filter is currently being applied.
`ind` shows the current position of the cursor as well as the number of files in the current directory.
`df` shows the amount of free disk space remaining.
selmode string (default 'all') selmode string (default 'all')
Selection mode for commands. Selection mode for commands.
@@ -793,12 +862,12 @@ 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.
smartcase bool (default on) smartcase bool (default true)
Override 'ignorecase' option when the pattern contains an uppercase character. Override 'ignorecase' option when the pattern contains an uppercase character.
This option has no effect when 'ignorecase' is disabled. This option has no effect when 'ignorecase' is disabled.
smartdia bool (default off) smartdia bool (default false)
Override 'ignoredia' option when the pattern contains a character with diacritic. Override 'ignoredia' option when the pattern contains a character with diacritic.
This option has no effect when 'ignoredia' is disabled. This option has no effect when 'ignoredia' is disabled.
@@ -812,10 +881,13 @@ Currently supported sort types are 'natural', 'name', 'size', 'time', 'ctime', '
Number of space characters to show for horizontal tabulation (U+0009) character. Number of space characters to show for horizontal tabulation (U+0009) character.
tagfmt string (default "\033[31m%s\033[0m") tagfmt string (default "\033[31m")
Format string of the tags. Format string of the tags.
If the format string contains the characters `%s`, it is interpreted as a format string for `fmt.Sprintf`. Such a string should end with the terminal reset sequence.
For example, "\033[4m%s\033[0m" has the same effect as "\033[4m".
tempmarks string (default '') tempmarks string (default '')
Marks to be considered temporary (e.g. 'abc' refers to marks 'a', 'b', and 'c'). Marks to be considered temporary (e.g. 'abc' refers to marks 'a', 'b', and 'c').
@@ -834,11 +906,11 @@ Truncate character shown at the end when the file name does not fit to the pane.
String shown after commands of shell-wait type. String shown after commands of shell-wait type.
wrapscan bool (default on) wrapscan bool (default true)
Searching can wrap around the file list. Searching can wrap around the file list.
wrapscroll bool (default off) wrapscroll bool (default false)
Scrolling can wrap around the file list. Scrolling can wrap around the file list.
@@ -885,19 +957,23 @@ 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 set the value 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
If this variable is set in the environment, use the same value, otherwise set the value to 'vi' on Unix, 'notepad' in Windows. If VISUAL is set in the environment, use its value. Otherwise, use the value of the environment variable EDITOR. If neither variable is set, this is set to 'vi' on Unix, 'notepad' in Windows.
PAGER PAGER
If this variable is set in the environment, use the same value, otherwise set the value to 'less' on Unix, 'more' in Windows. If this variable is set in the environment, use the same value. Otherwise, this is set to 'less' on Unix, 'more' in Windows.
SHELL SHELL
If this variable is set in the environment, use the same value, otherwise set the value to 'sh' on Unix, 'cmd' in Windows. If this variable is set in the environment, use the same value. Otherwise, this is set to 'sh' on Unix, 'cmd' in Windows.
lf
Absolute path to the currently running lf binary, if it can be found. Otherwise, this is set to the string 'lf'.
lf_{option} lf_{option}
@@ -912,6 +988,10 @@ Value of the user_{option}.
Width/Height of the terminal. Width/Height of the terminal.
lf_count
Value of the count associated with the current command.
# Special Commands # Special Commands
This section shows information about special shell commands. This section shows information about special shell commands.
@@ -973,8 +1053,10 @@ There are four special commands ('set', 'map', 'cmap', and 'cmd') for configurat
Command 'set' is used to set an option which can be boolean, integer, or string: Command 'set' is used to set an option which can be boolean, integer, or string:
set hidden # boolean on set hidden # boolean enable
set nohidden # boolean off set hidden true # boolean enable
set nohidden # 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 w/o quotes
+175 -76
View File
@@ -39,6 +39,7 @@ The following commands are provided by lf:
low (default 'L') low (default 'L')
toggle toggle
invert (default 'v') invert (default 'v')
invert-below
unselect (default 'u') unselect (default 'u')
glob-select glob-select
glob-unselect glob-unselect
@@ -81,6 +82,9 @@ The following commands are provided by lf:
mark-remove (modal) (default '"') mark-remove (modal) (default '"')
tag tag
tag-toggle (default 't') tag-toggle (default 't')
maps
cmaps
jumps
The following command line commands are provided by lf: The following command line commands are provided by lf:
@@ -91,8 +95,8 @@ The following command line commands are provided by lf:
cmd-menu-accept cmd-menu-accept
cmd-enter (default '<c-j>' and '<enter>') cmd-enter (default '<c-j>' and '<enter>')
cmd-interrupt (default '<c-c>') cmd-interrupt (default '<c-c>')
cmd-history-next (default '<c-n>') cmd-history-next (default '<c-n>' and '<down>')
cmd-history-prev (default '<c-p>') cmd-history-prev (default '<c-p>' and '<up>')
cmd-left (default '<c-b>' and '<left>') cmd-left (default '<c-b>' and '<left>')
cmd-right (default '<c-f>' and '<right>') cmd-right (default '<c-f>' and '<right>')
cmd-home (default '<c-a>' and '<home>') cmd-home (default '<c-a>' and '<home>')
@@ -114,56 +118,61 @@ The following command line commands are provided by lf:
The following options can be used to customize the behavior of lf: The following options can be used to customize the behavior of lf:
anchorfind bool (default on) anchorfind bool (default true)
autoquit bool (default off) autoquit bool (default false)
cleaner string (default '') cleaner string (default '')
dircache bool (default on) cursoractivefmt string (default "\033[7m")
dircounts bool (default off) cursorparentfmt string (default "\033[7m")
dirfirst bool (default on) cursorpreviewfmt string (default "\033[4m")
dironly bool (default off) dircache bool (default true)
dirpreviews bool (default off) dircounts bool (default false)
drawbox bool (default off) dirfirst bool (default true)
errorfmt string (default "\033[7;31;47m%s\033[0m") dironly bool (default false)
dirpreviews bool (default false)
drawbox bool (default false)
errorfmt string (default "\033[7;31;47m")
filesep string (default "\n") filesep string (default "\n")
findlen int (default 1) findlen int (default 1)
globsearch bool (default off) globsearch bool (default false)
hidden bool (default off) hidden bool (default false)
hiddenfiles []string (default '.*') hiddenfiles []string (default '.*')
history bool (default on) history bool (default true)
icons bool (default off) icons bool (default false)
ifs string (default '') ifs string (default '')
ignorecase bool (default on) ignorecase bool (default true)
ignoredia bool (default on) ignoredia bool (default true)
incfilter bool (default off) incfilter bool (default false)
incsearch bool (default off) incsearch bool (default false)
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')
mouse bool (default off) mouse bool (default false)
number bool (default off) number bool (default false)
numberfmt string (default "\033[33m")
period int (default 0) period int (default 0)
preview bool (default on) preview bool (default true)
previewer string (default '') previewer string (default '')
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")
ratios []int (default '1:2:3') ratios []int (default '1:2:3')
relativenumber bool (default off) relativenumber bool (default false)
reverse bool (default off) reverse bool (default false)
ruler []string (default 'acc:progress:selection:filter:ind')
scrolloff int (default 0) scrolloff int (default 0)
selmode string (default 'all') selmode string (default 'all')
shell string (default 'sh' for Unix and 'cmd' for Windows) shell string (default 'sh' for Unix and 'cmd' for Windows)
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 '')
smartcase bool (default on) smartcase bool (default true)
smartdia bool (default off) smartdia bool (default false)
sortby string (default 'natural') sortby string (default 'natural')
tabstop int (default 8) tabstop int (default 8)
tagfmt string (default "\033[31m%s\033[0m") tagfmt string (default "\033[31m")
tempmarks string (default '') tempmarks string (default '')
timefmt string (default 'Mon Jan _2 15:04:05 2006') timefmt string (default 'Mon Jan _2 15:04:05 2006')
truncatechar string (default '~') truncatechar string (default '~')
waitmsg string (default 'Press any key to continue') waitmsg string (default 'Press any key to continue')
wrapscan bool (default on) wrapscan bool (default true)
wrapscroll bool (default off) wrapscroll bool (default false)
user_{option} string (default none) user_{option} string (default none)
The following environment variables are exported for shell commands: The following environment variables are exported for shell commands:
@@ -176,13 +185,16 @@ The following environment variables are exported for shell commands:
OLDPWD OLDPWD
LF_LEVEL LF_LEVEL
OPENER OPENER
VISUAL
EDITOR EDITOR
PAGER PAGER
SHELL SHELL
lf
lf_{option} lf_{option}
lf_user_{option} lf_user_{option}
lf_width lf_width
lf_height lf_height
lf_count
The following special shell commands are used to customize the behavior of lf The following special shell commands are used to customize the behavior of lf
when defined: when defined:
@@ -231,7 +243,7 @@ effects:
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 window.
Scroll wheel Scroll wheel
Scroll up or down. Move up or down. If Ctrl is pressed, scroll up or down.
# Configuration # Configuration
@@ -325,7 +337,9 @@ Change the current working directory to the next/previous jumplist item.
top (default 'gg' and '<home>') top (default 'gg' and '<home>')
bottom (default 'G' and '<end>') bottom (default 'G' and '<end>')
Move the current file selection to the top/bottom of the directory. Move the current file selection to the top/bottom of the directory. A count can
be specified to move to a specific line, for example use '3G' to move to the
third line.
high (default 'H') high (default 'H')
middle (default 'M') middle (default 'M')
@@ -345,6 +359,20 @@ You can define a new command to select all files in the directory by combining
'invert' with 'unselect' (i.e. 'cmd select-all :unselect; invert'), though this 'invert' with 'unselect' (i.e. 'cmd select-all :unselect; invert'), though this
will also remove selections in other directories. will also remove selections in other directories.
invert-below
Reverse the selection (i.e. 'toggle') of all files at or after the current file
in the current directory.
To select a contiguous block of files, use this command on the first file you
want to select. Then, move down to the first file you do *not* want to select
(the one after the end of the desired selection) and use this command again.
This achieves an effect similar to the visual mode in vim.
This command is experimental and may be removed once a better replacement for
the visual mode is implemented in 'lf'. If you'd like to experiment with using
this command, you should bind it to a key (e.g. 'V') for a better experience.
unselect (default 'u') unselect (default 'u')
Remove the selection of all files in all directories. Remove the selection of all files in all directories.
@@ -552,8 +580,8 @@ Execute the current line.
Interrupt the current shell-pipe command and return to the normal mode. Interrupt the current shell-pipe command and return to the normal mode.
cmd-history-next (default '<c-n>') cmd-history-next (default '<c-n>' and '<down>')
cmd-history-prev (default '<c-p>') cmd-history-prev (default '<c-p>' and '<up>')
Go to next/previous item in the history. Go to next/previous item in the history.
@@ -609,17 +637,30 @@ Delete the next word in forward direction.
Capitalize/uppercase/lowercase the current word and jump to the next word. Capitalize/uppercase/lowercase the current word and jump to the next word.
maps
cmaps
List all key mappings in normal mode or command-line editing mode.
jumps
List the contents of the jump list, in order of the most recently visited
locations. Each location is marked with the count that can be used with the
'jump-prev' and 'jump-next' commands (e.g. use '3[' to move three spaces
backwards in the jump list). A '>' is used to mark the current location in the
jump list.
# Options # Options
This section shows information about options to customize the behavior. This section shows information about options to customize the behavior.
Character ':' is used as the separator for list options '[]int' and '[]string'. Character ':' is used as the separator for list options '[]int' and '[]string'.
anchorfind bool (default on) anchorfind bool (default true)
When this option is enabled, find command starts matching patterns from the When this option is enabled, find command starts matching patterns from the
beginning of file names, otherwise, it can match at an arbitrary position. beginning of file names, otherwise, it can match at an arbitrary position.
autoquit bool (default off) autoquit bool (default false)
Automatically quit server when there are no clients left connected. Automatically quit server when there are no clients left connected.
@@ -632,11 +673,32 @@ file, (1) current file name, (2) width, (3) height, (4) horizontal position,
and (5) vertical position of preview pane respectively. Preview clearing is and (5) vertical position of preview pane respectively. Preview clearing is
disabled when the value of this option is left empty. disabled when the value of this option is left empty.
dircache bool (default on) cursoractivefmt string (default "\033[7m")
cursorparentfmt string (default "\033[7m")
cursorpreviewfmt string (default "\033[4m")
Format strings for highlighting the cursor. 'cursoractivefmt' applies in the
current directory pane, 'cursorparentfmt' applies in panes that show parents
of the current directory, and 'cursorpreviewfmt' applies in panes that preview
directories.
The default is to make the active cursor and the parent directory cursor
inverted. The preview cursor is underlined.
Some other possibilities to consider for the preview or parent cursors: an empty
string for no cursor, "\033[7;2m" for dimmed inverted text (visibility varies
by terminal), "\033[7;90m" for inverted text with grey (aka "brightblack")
background.
If the format string contains the characters '%s', it is interpreted as a format
string for 'fmt.Sprintf'. Such a string should end with the terminal reset
sequence. For example, "\033[4m%s\033[0m" has the same effect as "\033[4m".
dircache bool (default true)
Cache directory contents. Cache directory contents.
dircounts bool (default off) dircounts bool (default false)
When this option is enabled, directory sizes show the number of items inside 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 instead of the total size of the directory, which needs to be calculated for
@@ -647,27 +709,31 @@ disabled by default for performance reasons. This option only has an effect when
999 items are counted per directory at most, and bigger directories are shown as 999 items are counted per directory at most, and bigger directories are shown as
'999+'. '999+'.
dirfirst bool (default on) dirfirst bool (default true)
Show directories first above regular files. Show directories first above regular files.
dironly bool (default off) dironly bool (default false)
Show only directories.
dirpreviews bool (default false)
If enabled, directories will also be passed to the previewer script. This allows If enabled, directories will also be passed to the previewer script. This allows
custom previews for directories. custom previews for directories.
dirpreviews bool (default off) drawbox bool (default false)
Show only directories.
drawbox bool (default off)
Draw boxes around panes with box drawing characters. Draw boxes around panes with box drawing characters.
errorfmt string (default "\033[7;31;47m%s\033[0m") errorfmt string (default "\033[7;31;47m")
Format string of error messages shown in the bottom message line. Format string of error messages shown in the bottom message line.
If the format string contains the characters '%s', it is interpreted as a format
string for 'fmt.Sprintf'. Such a string should end with the terminal reset
sequence. For example, "\033[4m%s\033[0m" has the same effect as "\033[4m".
filesep string (default "\n") filesep string (default "\n")
File separator used in environment variables 'fs' and 'fx'. File separator used in environment variables 'fs' and 'fx'.
@@ -677,14 +743,14 @@ File separator used in environment variables 'fs' and 'fx'.
Number of characters prompted for the find command. When this value is set to 0, Number of characters prompted for the find command. When this value is set to 0,
find command prompts until there is only a single match left. find command prompts until there is only a single match left.
globsearch bool (default off) globsearch bool (default false)
When this option is enabled, search command patterns are considered as globs, When this option is enabled, search command patterns are considered as globs,
otherwise they are literals. With globbing, '*' matches any sequence, '?' otherwise they are literals. With globbing, '*' matches any sequence, '?'
matches any character, and '[...]' or '[^...] matches character sets or ranges. matches any character, and '[...]' or '[^...]' matches character sets or ranges.
Otherwise, these characters are interpreted as they are. Otherwise, these characters are interpreted as they are.
hidden bool (default off) hidden bool (default false)
Show hidden files. On Unix systems, hidden files are determined by the value Show hidden files. On Unix systems, hidden files are determined by the value
of 'hiddenfiles'. On Windows, only files with hidden attributes are considered of 'hiddenfiles'. On Windows, only files with hidden attributes are considered
@@ -694,15 +760,16 @@ hidden files.
List of hidden file glob patterns. Patterns can be given as relative or List of hidden file glob patterns. Patterns can be given as relative or
absolute paths. Globbing supports the usual special characters, '*' to match any absolute paths. Globbing supports the usual special characters, '*' to match any
sequence, '?' to match any character, and '[...]' or '[^...] to match character sequence, '?' to match any character, and '[...]' or '[^...]' to match character
sets or ranges. In addition, if a pattern starts with '!', then its matches are sets or ranges. In addition, if a pattern starts with '!', then its matches are
excluded from hidden files. excluded from hidden files. To add multiple patterns, use ':' as a separator.
Example: '.*:lost+found:*.bak'
history bool (default on) history bool (default true)
Save command history. Save command history.
icons bool (default off) icons bool (default false)
Show icons before each item in the list. Show icons before each item in the list.
@@ -715,19 +782,19 @@ a POSIX shell syntax and so it can fail for non-POSIX shells. This option has
no effect when the value is left empty. This option does not have any effect on no effect when the value is left empty. This option does not have any effect on
Windows. Windows.
ignorecase bool (default on) ignorecase bool (default true)
Ignore case in sorting and search patterns. Ignore case in sorting and search patterns.
ignoredia bool (default on) ignoredia bool (default true)
Ignore diacritics in sorting and search patterns. Ignore diacritics in sorting and search patterns.
incsearch bool (default off) incsearch bool (default false)
Jump to the first match after each keystroke during searching. Jump to the first match after each keystroke during searching.
incfilter bool (default off) incfilter bool (default false)
Apply filter pattern after each keystroke during filtering. Apply filter pattern after each keystroke during filtering.
@@ -748,16 +815,20 @@ year.
Format string of the file time shown in the info column when it doesn't match Format string of the file time shown in the info column when it doesn't match
this year. this year.
mouse bool (default off) mouse bool (default false)
Send mouse events as input. Send mouse events as input.
number bool (default off) number bool (default false)
Show the position number for directory items at the left side of pane. When Show the position number for directory items at the left side of pane. When
'relativenumber' option is enabled, only the current line shows the absolute 'relativenumber' option is enabled, only the current line shows the absolute
position and relative positions are shown for the rest. position and relative positions are shown for the rest.
numberfmt string (default "\033[33m")
Format string of the position number for each line.
period int (default 0) period int (default 0)
Set the interval in seconds for periodic checks of directory updates. This works Set the interval in seconds for periodic checks of directory updates. This works
@@ -767,7 +838,7 @@ external process changing the displayed directory and you are not doing anything
in lf. Periodic checks are disabled when the value of this option is set to in lf. Periodic checks are disabled when the value of this option is set to
zero. zero.
preview bool (default on) preview bool (default true)
Show previews of files and directories at the right most pane. If the file Show previews of files and directories at the right most pane. If the file
has more lines than the preview pane, rest of the lines are not read. Files has more lines than the preview pane, rest of the lines are not read. Files
@@ -803,15 +874,27 @@ List of ratios of pane widths. Number of items in the list determines the number
of panes in the ui. When 'preview' option is enabled, the right most number is of panes in the ui. When 'preview' option is enabled, the right most number is
used for the width of preview pane. used for the width of preview pane.
relativenumber bool (default off) relativenumber bool (default false)
Show the position number relative to the current line. When 'number' is enabled, Show the position number relative to the current line. When 'number' is enabled,
current line shows the absolute position, otherwise nothing is shown. current line shows the absolute position, otherwise nothing is shown.
reverse bool (default off) reverse bool (default false)
Reverse the direction of sort. Reverse the direction of sort.
ruler []string (default 'acc:progress:selection:filter:ind')
List of information shown in status line ruler. Currently supported information
types are 'acc', 'progress', 'selection', 'ind' and 'df'. 'acc' shows the
pressed keys (e.g. for bindings with multiple key presses or counts given to
bindings). 'progress' shows the progress of file operations (e.g. copying a
large directory). 'selection' shows the number of files that are selected,
or designated for being cut/copied. 'filter' shows 'F' if a filter is currently
being applied. 'ind' shows the current position of the cursor as well as the
number of files in the current directory. 'df' shows the amount of free disk
space remaining.
selmode string (default 'all') selmode string (default 'all')
Selection mode for commands. When set to 'all' it will use the selected files Selection mode for commands. When set to 'all' it will use the selected files
@@ -839,12 +922,12 @@ 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.
smartcase bool (default on) smartcase bool (default true)
Override 'ignorecase' option when the pattern contains an uppercase character. Override 'ignorecase' option when the pattern contains an uppercase character.
This option has no effect when 'ignorecase' is disabled. This option has no effect when 'ignorecase' is disabled.
smartdia bool (default off) smartdia bool (default false)
Override 'ignoredia' option when the pattern contains a character with Override 'ignoredia' option when the pattern contains a character with
diacritic. This option has no effect when 'ignoredia' is disabled. diacritic. This option has no effect when 'ignoredia' is disabled.
@@ -858,10 +941,14 @@ Sort type for directories. Currently supported sort types are 'natural', 'name',
Number of space characters to show for horizontal tabulation (U+0009) character. Number of space characters to show for horizontal tabulation (U+0009) character.
tagfmt string (default "\033[31m%s\033[0m") tagfmt string (default "\033[31m")
Format string of the tags. Format string of the tags.
If the format string contains the characters '%s', it is interpreted as a format
string for 'fmt.Sprintf'. Such a string should end with the terminal reset
sequence. For example, "\033[4m%s\033[0m" has the same effect as "\033[4m".
tempmarks string (default '') tempmarks string (default '')
Marks to be considered temporary (e.g. 'abc' refers to marks 'a', 'b', Marks to be considered temporary (e.g. 'abc' refers to marks 'a', 'b',
@@ -881,11 +968,11 @@ Truncate character shown at the end when the file name does not fit to the pane.
String shown after commands of shell-wait type. String shown after commands of shell-wait type.
wrapscan bool (default on) wrapscan bool (default true)
Searching can wrap around the file list. Searching can wrap around the file list.
wrapscroll bool (default off) wrapscroll bool (default false)
Scrolling can wrap around the file list. Scrolling can wrap around the file list.
@@ -937,23 +1024,29 @@ $LF_LEVEL) "' in your shell configuration file (e.g. '~/.bashrc').
OPENER OPENER
If this variable is set in the environment, use the same value, otherwise set If this variable is set in the environment, use the same value. Otherwise,
the value to 'start' in Windows, 'open' in MacOS, 'xdg-open' in others. this is set to 'start' in Windows, 'open' in MacOS, 'xdg-open' in others.
EDITOR EDITOR
If this variable is set in the environment, use the same value, otherwise set If VISUAL is set in the environment, use its value. Otherwise, use the value of
the value to 'vi' on Unix, 'notepad' in Windows. the environment variable EDITOR. If neither variable is set, this is set to 'vi'
on Unix, 'notepad' in Windows.
PAGER PAGER
If this variable is set in the environment, use the same value, otherwise set If this variable is set in the environment, use the same value. Otherwise,
the value to 'less' on Unix, 'more' in Windows. this is set to 'less' on Unix, 'more' in Windows.
SHELL SHELL
If this variable is set in the environment, use the same value, otherwise set If this variable is set in the environment, use the same value. Otherwise,
the value to 'sh' on Unix, 'cmd' in Windows. this is set to 'sh' on Unix, 'cmd' in Windows.
lf
Absolute path to the currently running lf binary, if it can be found. Otherwise,
this is set to the string 'lf'.
lf_{option} lf_{option}
@@ -968,6 +1061,10 @@ Value of the user_{option}.
Width/Height of the terminal. Width/Height of the terminal.
lf_count
Value of the count associated with the current command.
# Special Commands # Special Commands
This section shows information about special shell commands. This section shows information about special shell commands.
@@ -1031,8 +1128,10 @@ configuration.
Command 'set' is used to set an option which can be boolean, integer, or string: Command 'set' is used to set an option which can be boolean, integer, or string:
set hidden # boolean on set hidden # boolean enable
set nohidden # boolean off set hidden true # boolean enable
set nohidden # 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 w/o quotes
+1 -1
View File
@@ -148,7 +148,7 @@ fi  # FILE
*.tsx  *.tsx 
*.jl  *.jl 
*.pp  *.pp 
*.vue ﵂ *.vue
*.elm  *.elm 
*.swift  *.swift 
*.xcplayground  *.xcplayground 
+3 -2
View File
@@ -5,7 +5,7 @@
# mkdir -p ~/.config/fish/functions # mkdir -p ~/.config/fish/functions
# ln -s "/path/to/lfcd.fish" ~/.config/fish/functions # ln -s "/path/to/lfcd.fish" ~/.config/fish/functions
# #
# You may also like to assign a key to this command: # You may also like to assign a key (Ctrl-O) to this command:
# #
# bind \co 'set old_tty (stty -g); stty sane; lfcd; stty $old_tty; commandline -f repaint' # bind \co 'set old_tty (stty -g); stty sane; lfcd; stty $old_tty; commandline -f repaint'
# #
@@ -13,7 +13,8 @@
function lfcd function lfcd
set tmp (mktemp) set tmp (mktemp)
lf -last-dir-path=$tmp $argv # `command` is needed in case `lfcd` is aliased to `lf`
command lf -last-dir-path=$tmp $argv
if test -f "$tmp" if test -f "$tmp"
set dir (cat $tmp) set dir (cat $tmp)
rm -f $tmp rm -f $tmp
+3 -2
View File
@@ -8,7 +8,7 @@
# source "$LFCD" # source "$LFCD"
# fi # fi
# #
# You may also like to assign a key to this command: # You may also like to assign a key (Ctrl-O) to this command:
# #
# bind '"\C-o":"lfcd\C-m"' # bash # bind '"\C-o":"lfcd\C-m"' # bash
# bindkey -s '^o' 'lfcd\n' # zsh # bindkey -s '^o' 'lfcd\n' # zsh
@@ -16,7 +16,8 @@
lfcd () { lfcd () {
tmp="$(mktemp)" tmp="$(mktemp)"
lf -last-dir-path="$tmp" "$@" # `command` is needed in case `lfcd` is aliased to `lf`
command lf -last-dir-path="$tmp" "$@"
if [ -f "$tmp" ]; then if [ -f "$tmp" ]; then
dir="$(cat "$tmp")" dir="$(cat "$tmp")"
rm -f "$tmp" rm -f "$tmp"
+9
View File
@@ -20,9 +20,15 @@ set ifs "\n"
# 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
# Use the `dim` attribute instead of underline for the cursor in the preview pane
set cursorpreviewfmt "\033[7;2m"
# use enter for shell commands # use enter for shell commands
map <enter> shell map <enter> shell
# show the result of execution of previous commands
map ` !true
# execute current file (must be executable) # execute current file (must be executable)
map x $$f map x $$f
map X !$f map X !$f
@@ -42,6 +48,9 @@ cmd open &{{
esac esac
}} }}
# mkdir command. See wiki if you want it to select created dir
map a :push %mkdir<space>
# define a custom 'rename' command without prompt for overwrite # define a custom 'rename' command without prompt for overwrite
# cmd rename %[ -e $1 ] && printf "file exists" || mv $f $1 # cmd rename %[ -e $1 ] && printf "file exists" || mv $f $1
# map r push :rename<space> # map r push :rename<space>
+692 -240
View File
File diff suppressed because it is too large. Load diff
+12 -5
View File
@@ -1,11 +1,18 @@
module github.com/gokcehan/lf module github.com/gokcehan/lf
go 1.12 go 1.18
require ( require (
github.com/gdamore/tcell/v2 v2.5.4-0.20221019011350-d3cbfcfb7aa3
github.com/mattn/go-runewidth v0.0.14
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211
github.com/djherbis/times v1.5.0 github.com/djherbis/times v1.5.0
github.com/gdamore/tcell/v2 v2.6.0
github.com/mattn/go-runewidth v0.0.14
golang.org/x/sys v0.8.0
golang.org/x/term v0.8.0
)
require (
github.com/gdamore/encoding v1.0.0 // indirect
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
github.com/rivo/uniseg v0.4.3 // indirect
golang.org/x/text v0.7.0 // indirect
) )
+14 -9
View File
@@ -1,13 +1,16 @@
github.com/djherbis/times v1.5.0 h1:79myA211VwPhFTqUk8xehWrsEO+zcIZj0zT8mXPVARU=
github.com/djherbis/times v1.5.0/go.mod h1:5q7FDLvbNg1L/KaBmPcWlVR9NmoKo3+ucqUA3ijQhA0=
github.com/gdamore/encoding v1.0.0 h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdko= github.com/gdamore/encoding v1.0.0 h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdko=
github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg= github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg=
github.com/gdamore/tcell/v2 v2.5.4-0.20221019011350-d3cbfcfb7aa3 h1:e5DXSPPfOBDJY9Z0geFZjEDok0/cUEI5QlPeTmqPV4I= github.com/gdamore/tcell/v2 v2.6.0 h1:OKbluoP9VYmJwZwq/iLb4BxwKcwGthaa1YNBJIyCySg=
github.com/gdamore/tcell/v2 v2.5.4-0.20221019011350-d3cbfcfb7aa3/go.mod h1:XmCynGHvvGG7UFI6az9zzoEHBvZB1PGf5APwOJMFUyE= github.com/gdamore/tcell/v2 v2.6.0/go.mod h1:be9omFATkdr0D9qewWW3d+MEvl5dha+Etb5y65J2H8Y=
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.14 h1:+xnbZSEeDbOIg5/mE6JF0w6n9duR1l3/WmbinWVwUuU= github.com/mattn/go-runewidth v0.0.14 h1:+xnbZSEeDbOIg5/mE6JF0w6n9duR1l3/WmbinWVwUuU=
github.com/mattn/go-runewidth v0.0.14/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/mattn/go-runewidth v0.0.14/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
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 h1:utMvzDsuh3suAEnhH0RdHmoPbU648o6CvXxTx4SBMOw=
github.com/rivo/uniseg v0.4.3/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=
@@ -21,19 +24,21 @@ golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5h
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=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f h1:v4INt8xihDGvnrfjMDVXGxw9wrfxYyCjk0KbXjhR55s=
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.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU=
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
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 h1:JGgROgKl9N8DuW20oFS5gxc+lE67/N3FcwmBPMe7ArY=
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.8.0 h1:n5xxQn2i3PC0yLAbjTpNT85q/Kgzcr2gIoX9OrJUols=
golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
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.4.0 h1:BrVqGRd7+k1DiOgtnFvAkoQEWQvBc25ouMJM6429SFg= golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo=
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
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/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=
github.com/djherbis/times v1.5.0 h1:79myA211VwPhFTqUk8xehWrsEO+zcIZj0zT8mXPVARU=
github.com/djherbis/times v1.5.0/go.mod h1:5q7FDLvbNg1L/KaBmPcWlVR9NmoKo3+ucqUA3ijQhA0=
+152 -73
View File
@@ -51,6 +51,7 @@ The following commands are provided by lf:
low (default 'L') low (default 'L')
toggle toggle
invert (default 'v') invert (default 'v')
invert-below
unselect (default 'u') unselect (default 'u')
glob-select glob-select
glob-unselect glob-unselect
@@ -93,6 +94,9 @@ The following commands are provided by lf:
mark-remove (modal) (default '"') mark-remove (modal) (default '"')
tag tag
tag-toggle (default 't') tag-toggle (default 't')
maps
cmaps
jumps
.EE .EE
.PP .PP
The following command line commands are provided by lf: The following command line commands are provided by lf:
@@ -105,8 +109,8 @@ The following command line commands are provided by lf:
cmd-menu-accept cmd-menu-accept
cmd-enter (default '<c-j>' and '<enter>') cmd-enter (default '<c-j>' and '<enter>')
cmd-interrupt (default '<c-c>') cmd-interrupt (default '<c-c>')
cmd-history-next (default '<c-n>') cmd-history-next (default '<c-n>' and '<down>')
cmd-history-prev (default '<c-p>') cmd-history-prev (default '<c-p>' and '<up>')
cmd-left (default '<c-b>' and '<left>') cmd-left (default '<c-b>' and '<left>')
cmd-right (default '<c-f>' and '<right>') cmd-right (default '<c-f>' and '<right>')
cmd-home (default '<c-a>' and '<home>') cmd-home (default '<c-a>' and '<home>')
@@ -130,56 +134,61 @@ The following command line commands are provided by lf:
The following options can be used to customize the behavior of lf: The following options can be used to customize the behavior of lf:
.PP .PP
.EX .EX
anchorfind bool (default on) anchorfind bool (default true)
autoquit bool (default off) autoquit bool (default false)
cleaner string (default '') cleaner string (default '')
dircache bool (default on) cursoractivefmt string (default "\e033[7m")
dircounts bool (default off) cursorparentfmt string (default "\e033[7m")
dirfirst bool (default on) cursorpreviewfmt string (default "\e033[4m")
dironly bool (default off) dircache bool (default true)
dirpreviews bool (default off) dircounts bool (default false)
drawbox bool (default off) dirfirst bool (default true)
errorfmt string (default "\e033[7;31;47m%s\e033[0m") dironly bool (default false)
dirpreviews bool (default false)
drawbox bool (default false)
errorfmt string (default "\e033[7;31;47m")
filesep string (default "\en") filesep string (default "\en")
findlen int (default 1) findlen int (default 1)
globsearch bool (default off) globsearch bool (default false)
hidden bool (default off) hidden bool (default false)
hiddenfiles []string (default '.*') hiddenfiles []string (default '.*')
history bool (default on) history bool (default true)
icons bool (default off) icons bool (default false)
ifs string (default '') ifs string (default '')
ignorecase bool (default on) ignorecase bool (default true)
ignoredia bool (default on) ignoredia bool (default true)
incfilter bool (default off) incfilter bool (default false)
incsearch bool (default off) incsearch bool (default false)
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')
mouse bool (default off) mouse bool (default false)
number bool (default off) number bool (default false)
numberfmt string (default "\e033[33m")
period int (default 0) period int (default 0)
preview bool (default on) preview bool (default true)
previewer string (default '') previewer string (default '')
promptfmt string (default "\e033[32;1m%u@%h\e033[0m:\e033[34;1m%d\e033[0m\e033[1m%f\e033[0m") promptfmt string (default "\e033[32;1m%u@%h\e033[0m:\e033[34;1m%d\e033[0m\e033[1m%f\e033[0m")
ratios []int (default '1:2:3') ratios []int (default '1:2:3')
relativenumber bool (default off) relativenumber bool (default false)
reverse bool (default off) reverse bool (default false)
ruler []string (default 'acc:progress:selection:filter:ind')
scrolloff int (default 0) scrolloff int (default 0)
selmode string (default 'all') selmode string (default 'all')
shell string (default 'sh' for Unix and 'cmd' for Windows) shell string (default 'sh' for Unix and 'cmd' for Windows)
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 '')
smartcase bool (default on) smartcase bool (default true)
smartdia bool (default off) smartdia bool (default false)
sortby string (default 'natural') sortby string (default 'natural')
tabstop int (default 8) tabstop int (default 8)
tagfmt string (default "\e033[31m%s\e033[0m") tagfmt string (default "\e033[31m")
tempmarks string (default '') tempmarks string (default '')
timefmt string (default 'Mon Jan _2 15:04:05 2006') timefmt string (default 'Mon Jan _2 15:04:05 2006')
truncatechar string (default '~') truncatechar string (default '~')
waitmsg string (default 'Press any key to continue') waitmsg string (default 'Press any key to continue')
wrapscan bool (default on) wrapscan bool (default true)
wrapscroll bool (default off) wrapscroll bool (default false)
user_{option} string (default none) user_{option} string (default none)
.EE .EE
.PP .PP
@@ -194,13 +203,16 @@ The following environment variables are exported for shell commands:
OLDPWD OLDPWD
LF_LEVEL LF_LEVEL
OPENER OPENER
VISUAL
EDITOR EDITOR
PAGER PAGER
SHELL SHELL
lf
lf_{option} lf_{option}
lf_user_{option} lf_user_{option}
lf_width lf_width
lf_height lf_height
lf_count
.EE .EE
.PP .PP
The following special shell commands are used to customize the behavior of lf when defined: The following special shell commands are used to customize the behavior of lf when defined:
@@ -259,7 +271,7 @@ If the 'mouse' option is enabled, mouse buttons have the following default effec
.PP .PP
.EX .EX
Scroll wheel Scroll wheel
Scroll up or down. Move up or down. If Ctrl is pressed, scroll up or down.
.EE .EE
.SH CONFIGURATION .SH CONFIGURATION
Configuration files should be located at: Configuration files should be located at:
@@ -370,7 +382,7 @@ Change the current working directory to the next/previous jumplist item.
bottom (default 'G' and '<end>') bottom (default 'G' and '<end>')
.EE .EE
.PP .PP
Move the current file selection to the top/bottom of the directory. Move the current file selection to the top/bottom of the directory. A count can be specified to move to a specific line, for example use `3G` to move to the third line.
.PP .PP
.EX .EX
high (default 'H') high (default 'H')
@@ -392,6 +404,16 @@ Toggle the selection of the current file or files given as arguments.
.PP .PP
Reverse the selection of all files in the current directory (i.e. 'toggle' all files). Selections in other directories are not effected by this command. You can define a new command to select all files in the directory by combining 'invert' with 'unselect' (i.e. 'cmd select-all :unselect; invert'), though this will also remove selections in other directories. Reverse the selection of all files in the current directory (i.e. 'toggle' all files). Selections in other directories are not effected by this command. You can define a new command to select all files in the directory by combining 'invert' with 'unselect' (i.e. 'cmd select-all :unselect; invert'), though this will also remove selections in other directories.
.PP .PP
.EX
invert-below
.EE
.PP
Reverse the selection (i.e. 'toggle') of all files at or after the current file in the current directory.
.PP
To select a contiguous block of files, use this command on the first file you want to select. Then, move down to the first file you do *not* want to select (the one after the end of the desired selection) and use this command again. This achieves an effect similar to the visual mode in vim.
.PP
This command is experimental and may be removed once a better replacement for the visual mode is implemented in 'lf'. If you'd like to experiment with using this command, you should bind it to a key (e.g. 'V') for a better experience.
.PP
.EX .EX
unselect (default 'u') unselect (default 'u')
.EE .EE
@@ -648,8 +670,8 @@ Execute the current line.
Interrupt the current shell-pipe command and return to the normal mode. Interrupt the current shell-pipe command and return to the normal mode.
.PP .PP
.EX .EX
cmd-history-next (default '<c-n>') cmd-history-next (default '<c-n>' and '<down>')
cmd-history-prev (default '<c-p>') cmd-history-prev (default '<c-p>' and '<up>')
.EE .EE
.PP .PP
Go to next/previous item in the history. Go to next/previous item in the history.
@@ -726,17 +748,30 @@ Delete the next word in forward direction.
.EE .EE
.PP .PP
Capitalize/uppercase/lowercase the current word and jump to the next word. Capitalize/uppercase/lowercase the current word and jump to the next word.
.PP
.EX
maps
cmaps
.EE
.PP
List all key mappings in normal mode or command-line editing mode.
.PP
.EX
jumps
.EE
.PP
List the contents of the jump list, in order of the most recently visited locations. Each location is marked with the count that can be used with the `jump-prev` and `jump-next` commands (e.g. use `3[` to move three spaces backwards in the jump list). A '>' is used to mark the current location in the jump list.
.SH OPTIONS .SH OPTIONS
This section shows information about options to customize the behavior. Character ':' is used as the separator for list options '[]int' and '[]string'. This section shows information about options to customize the behavior. Character ':' is used as the separator for list options '[]int' and '[]string'.
.PP .PP
.EX .EX
anchorfind bool (default on) anchorfind bool (default true)
.EE .EE
.PP .PP
When this option is enabled, find command starts matching patterns from the beginning of file names, otherwise, it can match at an arbitrary position. When this option is enabled, find command starts matching patterns from the beginning of file names, otherwise, it can match at an arbitrary position.
.PP .PP
.EX .EX
autoquit bool (default off) autoquit bool (default false)
.EE .EE
.PP .PP
Automatically quit server when there are no clients left connected. Automatically quit server when there are no clients left connected.
@@ -748,47 +783,63 @@ Automatically quit server when there are no clients left connected.
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 previously selected file had its preview cache disabled. 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. Preview clearing is disabled when the value of this option is left empty. 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 previously selected file had its preview cache disabled. 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. Preview clearing is disabled when the value of this option is left empty.
.PP .PP
.EX .EX
dircache bool (default on) cursoractivefmt string (default "\e033[7m")
cursorparentfmt string (default "\e033[7m")
cursorpreviewfmt string (default "\e033[4m")
.EE
.PP
Format strings for highlighting the cursor. `cursoractivefmt` applies in the current directory pane, `cursorparentfmt` applies in panes that show parents of the current directory, and `cursorpreviewfmt` applies in panes that preview directories.
.PP
The default is to make the active cursor and the parent directory cursor inverted. The preview cursor is underlined.
.PP
Some other possibilities to consider for the preview or parent cursors: an empty string for no cursor, "\e033[7;2m" for dimmed inverted text (visibility varies by terminal), "\e033[7;90m" for inverted text with grey (aka "brightblack") background.
.PP
If the format string contains the characters `%s`, it is interpreted as a format string for `fmt.Sprintf`. Such a string should end with the terminal reset sequence. For example, "\e033[4m%s\e033[0m" has the same effect as "\e033[4m".
.PP
.EX
dircache bool (default true)
.EE .EE
.PP .PP
Cache directory contents. Cache directory contents.
.PP .PP
.EX .EX
dircounts bool (default off) dircounts bool (default false)
.EE .EE
.PP .PP
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'. This information needs to be calculated by reading the directory and counting the items inside. Therefore, this option is disabled by default for performance reasons. This option only has an effect when 'info' has a 'size' field and the pane is wide enough to show the information. 999 items are counted per directory at most, and bigger directories are shown as '999+'. 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'. This information needs to be calculated by reading the directory and counting the items inside. Therefore, this option is disabled by default for performance reasons. This option only has an effect when 'info' has a 'size' field and the pane is wide enough to show the information. 999 items are counted per directory at most, and bigger directories are shown as '999+'.
.PP .PP
.EX .EX
dirfirst bool (default on) dirfirst bool (default true)
.EE .EE
.PP .PP
Show directories first above regular files. Show directories first above regular files.
.PP .PP
.EX .EX
dironly bool (default off) dironly bool (default false)
.EE
.PP
If enabled, directories will also be passed to the previewer script. This allows custom previews for directories.
.PP
.EX
dirpreviews bool (default off)
.EE .EE
.PP .PP
Show only directories. Show only directories.
.PP .PP
.EX .EX
drawbox bool (default off) dirpreviews bool (default false)
.EE
.PP
If enabled, directories will also be passed to the previewer script. This allows custom previews for directories.
.PP
.EX
drawbox bool (default false)
.EE .EE
.PP .PP
Draw boxes around panes with box drawing characters. Draw boxes around panes with box drawing characters.
.PP .PP
.EX .EX
errorfmt string (default "\e033[7;31;47m%s\e033[0m") errorfmt string (default "\e033[7;31;47m")
.EE .EE
.PP .PP
Format string of error messages shown in the bottom message line. Format string of error messages shown in the bottom message line.
.PP .PP
If the format string contains the characters `%s`, it is interpreted as a format string for `fmt.Sprintf`. Such a string should end with the terminal reset sequence. For example, "\e033[4m%s\e033[0m" has the same effect as "\e033[4m".
.PP
.EX .EX
filesep string (default "\en") filesep string (default "\en")
.EE .EE
@@ -802,13 +853,13 @@ File separator used in environment variables 'fs' and 'fx'.
Number of characters prompted for the find command. When this value is set to 0, find command prompts until there is only a single match left. Number of characters prompted for the find command. When this value is set to 0, find command prompts until there is only a single match left.
.PP .PP
.EX .EX
globsearch bool (default off) globsearch bool (default false)
.EE .EE
.PP .PP
When this option is enabled, search command patterns are considered as globs, otherwise they are literals. With globbing, '*' matches any sequence, '?' matches any character, and '[...]' or '[^...] matches character sets or ranges. Otherwise, these characters are interpreted as they are. When this option is enabled, search command patterns are considered as globs, otherwise they are literals. With globbing, '*' matches any sequence, '?' matches any character, and '[...]' or '[^...]' matches character sets or ranges. Otherwise, these characters are interpreted as they are.
.PP .PP
.EX .EX
hidden bool (default off) hidden bool (default false)
.EE .EE
.PP .PP
Show hidden files. On Unix systems, hidden files are determined by the value of 'hiddenfiles'. On Windows, only files with hidden attributes are considered hidden files. Show hidden files. On Unix systems, hidden files are determined by the value of 'hiddenfiles'. On Windows, only files with hidden attributes are considered hidden files.
@@ -817,16 +868,16 @@ Show hidden files. On Unix systems, hidden files are determined by the value of
hiddenfiles []string (default '.*') hiddenfiles []string (default '.*')
.EE .EE
.PP .PP
List of hidden file glob patterns. Patterns can be given as relative or absolute paths. Globbing supports the usual special characters, '*' to match any sequence, '?' to match any character, and '[...]' or '[^...] to match character sets or ranges. In addition, if a pattern starts with '!', then its matches are excluded from hidden files. List of hidden file glob patterns. Patterns can be given as relative or absolute paths. Globbing supports the usual special characters, '*' to match any sequence, '?' to match any character, and '[...]' or '[^...]' to match character sets or ranges. In addition, if a pattern starts with '!', then its matches are excluded from hidden files. To add multiple patterns, use ':' as a separator. Example: '.*:lost+found:*.bak'
.PP .PP
.EX .EX
history bool (default on) history bool (default true)
.EE .EE
.PP .PP
Save command history. Save command history.
.PP .PP
.EX .EX
icons bool (default off) icons bool (default false)
.EE .EE
.PP .PP
Show icons before each item in the list. Show icons before each item in the list.
@@ -838,25 +889,25 @@ Show icons before each item in the list.
Sets 'IFS' variable in shell commands. It works by adding the assignment to the beginning of the command string as "IFS='...'; ...". The reason is that 'IFS' variable is not inherited by the shell for security reasons. This method assumes a POSIX shell syntax and so it can fail for non-POSIX shells. This option has no effect when the value is left empty. This option does not have any effect on Windows. Sets 'IFS' variable in shell commands. It works by adding the assignment to the beginning of the command string as "IFS='...'; ...". The reason is that 'IFS' variable is not inherited by the shell for security reasons. This method assumes a POSIX shell syntax and so it can fail for non-POSIX shells. This option has no effect when the value is left empty. This option does not have any effect on Windows.
.PP .PP
.EX .EX
ignorecase bool (default on) ignorecase bool (default true)
.EE .EE
.PP .PP
Ignore case in sorting and search patterns. Ignore case in sorting and search patterns.
.PP .PP
.EX .EX
ignoredia bool (default on) ignoredia bool (default true)
.EE .EE
.PP .PP
Ignore diacritics in sorting and search patterns. Ignore diacritics in sorting and search patterns.
.PP .PP
.EX .EX
incsearch bool (default off) incsearch bool (default false)
.EE .EE
.PP .PP
Jump to the first match after each keystroke during searching. Jump to the first match after each keystroke during searching.
.PP .PP
.EX .EX
incfilter bool (default off) incfilter bool (default false)
.EE .EE
.PP .PP
Apply filter pattern after each keystroke during filtering. Apply filter pattern after each keystroke during filtering.
@@ -880,17 +931,23 @@ 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.
.PP .PP
.EX .EX
mouse bool (default off) mouse bool (default false)
.EE .EE
.PP .PP
Send mouse events as input. Send mouse events as input.
.PP .PP
.EX .EX
number bool (default off) number bool (default false)
.EE .EE
.PP .PP
Show the position number for directory items at the left side of pane. When 'relativenumber' option is enabled, only the current line shows the absolute position and relative positions are shown for the rest. Show the position number for directory items at the left side of pane. When 'relativenumber' option is enabled, only the current line shows the absolute position and relative positions are shown for the rest.
.PP .PP
.EX
numberfmt string (default "\e033[33m")
.EE
.PP
Format string of the position number for each line.
.PP
.EX .EX
period int (default 0) period int (default 0)
.EE .EE
@@ -898,7 +955,7 @@ Show the position number for directory items at the left side of pane. When 'rel
Set the interval in seconds for periodic checks of directory updates. This works by periodically calling the 'load' command. Note that directories are already updated automatically in many cases. This option can be useful when there is an external process changing the displayed directory and you are not doing anything in lf. Periodic checks are disabled when the value of this option is set to zero. Set the interval in seconds for periodic checks of directory updates. This works by periodically calling the 'load' command. Note that directories are already updated automatically in many cases. This option can be useful when there is an external process changing the displayed directory and you are not doing anything in lf. Periodic checks are disabled when the value of this option is set to zero.
.PP .PP
.EX .EX
preview bool (default on) preview bool (default true)
.EE .EE
.PP .PP
Show previews of files and directories at the right most pane. If the file has more lines than the preview pane, rest of the lines are not read. Files containing the null character (U+0000) in the read portion are considered binary files and displayed as 'binary'. Show previews of files and directories at the right most pane. If the file has more lines than the preview pane, rest of the lines are not read. Files containing the null character (U+0000) in the read portion are considered binary files and displayed as 'binary'.
@@ -922,17 +979,23 @@ Format string of the prompt shown in the top line. Special expansions are provid
List of ratios of pane widths. Number of items in the list determines the number of panes in the ui. When 'preview' option is enabled, the right most number is used for the width of preview pane. List of ratios of pane widths. Number of items in the list determines the number of panes in the ui. When 'preview' option is enabled, the right most number is used for the width of preview pane.
.PP .PP
.EX .EX
relativenumber bool (default off) relativenumber bool (default false)
.EE .EE
.PP .PP
Show the position number relative to the current line. When 'number' is enabled, current line shows the absolute position, otherwise nothing is shown. Show the position number relative to the current line. When 'number' is enabled, current line shows the absolute position, otherwise nothing is shown.
.PP .PP
.EX .EX
reverse bool (default off) reverse bool (default false)
.EE .EE
.PP .PP
Reverse the direction of sort. Reverse the direction of sort.
.PP .PP
.EX
ruler []string (default 'acc:progress:selection:filter:ind')
.EE
.PP
List of information shown in status line ruler. Currently supported information types are 'acc', 'progress', 'selection', 'ind' and 'df'. `acc` shows the pressed keys (e.g. for bindings with multiple key presses or counts given to bindings). `progress` shows the progress of file operations (e.g. copying a large directory). `selection` shows the number of files that are selected, or designated for being cut/copied. `filter` shows 'F' if a filter is currently being applied. `ind` shows the current position of the cursor as well as the number of files in the current directory. `df` shows the amount of free disk space remaining.
.PP
.EX .EX
selmode string (default 'all') selmode string (default 'all')
.EE .EE
@@ -964,13 +1027,13 @@ 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.
.PP .PP
.EX .EX
smartcase bool (default on) smartcase bool (default true)
.EE .EE
.PP .PP
Override 'ignorecase' option when the pattern contains an uppercase character. This option has no effect when 'ignorecase' is disabled. Override 'ignorecase' option when the pattern contains an uppercase character. This option has no effect when 'ignorecase' is disabled.
.PP .PP
.EX .EX
smartdia bool (default off) smartdia bool (default false)
.EE .EE
.PP .PP
Override 'ignoredia' option when the pattern contains a character with diacritic. This option has no effect when 'ignoredia' is disabled. Override 'ignoredia' option when the pattern contains a character with diacritic. This option has no effect when 'ignoredia' is disabled.
@@ -988,11 +1051,13 @@ Sort type for directories. Currently supported sort types are 'natural', 'name',
Number of space characters to show for horizontal tabulation (U+0009) character. Number of space characters to show for horizontal tabulation (U+0009) character.
.PP .PP
.EX .EX
tagfmt string (default "\e033[31m%s\e033[0m") tagfmt string (default "\e033[31m")
.EE .EE
.PP .PP
Format string of the tags. Format string of the tags.
.PP .PP
If the format string contains the characters `%s`, it is interpreted as a format string for `fmt.Sprintf`. Such a string should end with the terminal reset sequence. For example, "\e033[4m%s\e033[0m" has the same effect as "\e033[4m".
.PP
.EX .EX
tempmarks string (default '') tempmarks string (default '')
.EE .EE
@@ -1018,13 +1083,13 @@ Truncate character shown at the end when the file name does not fit to the pane.
String shown after commands of shell-wait type. String shown after commands of shell-wait type.
.PP .PP
.EX .EX
wrapscan bool (default on) wrapscan bool (default true)
.EE .EE
.PP .PP
Searching can wrap around the file list. Searching can wrap around the file list.
.PP .PP
.EX .EX
wrapscroll bool (default off) wrapscroll bool (default false)
.EE .EE
.PP .PP
Scrolling can wrap around the file list. Scrolling can wrap around the file list.
@@ -1083,25 +1148,31 @@ The value of this variable is set to the current nesting level when you run lf f
OPENER OPENER
.EE .EE
.PP .PP
If this variable is set in the environment, use the same value, otherwise set the value 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.
.PP .PP
.EX .EX
EDITOR EDITOR
.EE .EE
.PP .PP
If this variable is set in the environment, use the same value, otherwise set the value to 'vi' on Unix, 'notepad' in Windows. If VISUAL is set in the environment, use its value. Otherwise, use the value of the environment variable EDITOR. If neither variable is set, this is set to 'vi' on Unix, 'notepad' in Windows.
.PP .PP
.EX .EX
PAGER PAGER
.EE .EE
.PP .PP
If this variable is set in the environment, use the same value, otherwise set the value to 'less' on Unix, 'more' in Windows. If this variable is set in the environment, use the same value. Otherwise, this is set to 'less' on Unix, 'more' in Windows.
.PP .PP
.EX .EX
SHELL SHELL
.EE .EE
.PP .PP
If this variable is set in the environment, use the same value, otherwise set the value to 'sh' on Unix, 'cmd' in Windows. If this variable is set in the environment, use the same value. Otherwise, this is set to 'sh' on Unix, 'cmd' in Windows.
.PP
.EX
lf
.EE
.PP
Absolute path to the currently running lf binary, if it can be found. Otherwise, this is set to the string 'lf'.
.PP .PP
.EX .EX
lf_{option} lf_{option}
@@ -1121,6 +1192,12 @@ Value of the user_{option}.
.EE .EE
.PP .PP
Width/Height of the terminal. Width/Height of the terminal.
.PP
.EX
lf_count
.EE
.PP
Value of the count associated with the current command.
.SH SPECIAL COMMANDS .SH SPECIAL COMMANDS
This section shows information about special shell commands. This section shows information about special shell commands.
.PP .PP
@@ -1195,8 +1272,10 @@ There are four special commands ('set', 'map', 'cmap', and 'cmd') for configurat
Command 'set' is used to set an option which can be boolean, integer, or string: Command 'set' is used to set an option which can be boolean, integer, or string:
.PP .PP
.EX .EX
set hidden # boolean on set hidden # boolean enable
set nohidden # boolean off set hidden true # boolean enable
set nohidden # 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 w/o quotes
+13 -7
View File
@@ -79,6 +79,13 @@ func exportEnvVars() {
level++ level++
os.Setenv("LF_LEVEL", strconv.Itoa(level)) os.Setenv("LF_LEVEL", strconv.Itoa(level))
lfPath, err := os.Executable()
if err != nil {
log.Printf("getting path to lf binary: %s", err)
lfPath = "lf"
}
os.Setenv("lf", lfPath)
} }
// used by exportOpts below // used by exportOpts below
@@ -109,12 +116,12 @@ func fieldToString(field reflect.Value) string {
} }
func exportOpts() { func exportOpts() {
e := reflect.ValueOf(&gOpts).Elem() v := reflect.ValueOf(gOpts)
t := v.Type()
for i := 0; i < e.NumField(); i++ { for i := 0; i < v.NumField(); i++ {
// Get name and prefix it with lf_ // Get field name and prefix it with lf_
name := e.Type().Field(i).Name name := "lf_" + t.Field(i).Name
name = fmt.Sprintf("lf_%s", name)
// Skip maps // Skip maps
if name == "lf_keys" || name == "lf_cmdkeys" || name == "lf_cmds" { if name == "lf_keys" || name == "lf_cmdkeys" || name == "lf_cmds" {
@@ -158,9 +165,8 @@ func exportOpts() {
os.Setenv(name+"_"+key, value) os.Setenv(name+"_"+key, value)
} }
} else { } else {
field := e.Field(i) field := v.Field(i)
value := fieldToString(field) value := fieldToString(field)
os.Setenv(name, value) os.Setenv(name, value)
} }
} }
+63 -13
View File
@@ -388,11 +388,15 @@ type nav struct {
searchPos int searchPos int
prevFilter []string prevFilter []string
volatilePreview bool volatilePreview bool
previewTimer *time.Timer
previewLoading bool
jumpList []string jumpList []string
jumpListInd int jumpListInd int
} }
func (nav *nav) loadDirInternal(path string) *dir { func (nav *nav) loadDirInternal(path string) *dir {
nav.startPreview()
d := &dir{ d := &dir{
loading: true, loading: true,
loadTime: time.Now(), loadTime: time.Now(),
@@ -448,6 +452,7 @@ func (nav *nav) checkDir(dir *dir) {
return return
} }
nav.startPreview()
dir.loading = true dir.loading = true
dir.loadTime = now dir.loadTime = now
go func() { go func() {
@@ -465,10 +470,11 @@ func (nav *nav) checkDir(dir *dir) {
dir.ignorecase != gOpts.ignorecase || dir.ignorecase != gOpts.ignorecase ||
dir.ignoredia != gOpts.ignoredia: dir.ignoredia != gOpts.ignoredia:
dir.loading = true dir.loading = true
sd := *dir
go func() { go func() {
dir.sort() sd.sort()
dir.loading = false sd.loading = false
nav.dirChan <- dir nav.dirChan <- &sd
}() }()
} }
} }
@@ -480,7 +486,9 @@ func (nav *nav) getDirs(wd string) {
for curr, base := wd, ""; !isRoot(base); curr, base = filepath.Dir(curr), filepath.Base(curr) { for curr, base := wd, ""; !isRoot(base); curr, base = filepath.Dir(curr), filepath.Base(curr) {
dir := nav.loadDir(curr) dir := nav.loadDir(curr)
if base != "" {
dir.sel(base, nav.height) dir.sel(base, nav.height)
}
dirs = append(dirs, dir) dirs = append(dirs, dir)
} }
@@ -511,6 +519,7 @@ func newNav(height int) *nav {
tags: make(map[string]string), tags: make(map[string]string),
selectionInd: 0, selectionInd: 0,
height: height, height: height,
previewTimer: time.NewTimer(0),
jumpList: make([]string, 0), jumpList: make([]string, 0),
jumpListInd: -1, jumpListInd: -1,
} }
@@ -534,7 +543,6 @@ func (nav *nav) addJumpList() {
} }
func (nav *nav) cdJumpListPrev() { func (nav *nav) cdJumpListPrev() {
// currPath := nav.currDir().path
if nav.jumpListInd > 0 { if nav.jumpListInd > 0 {
nav.jumpListInd -= 1 nav.jumpListInd -= 1
nav.cd(nav.jumpList[nav.jumpListInd]) nav.cd(nav.jumpList[nav.jumpListInd])
@@ -814,6 +822,7 @@ func (nav *nav) loadReg(path string, volatile bool) *reg {
if !ok || (volatile && r.volatile) { if !ok || (volatile && r.volatile) {
r := &reg{loading: true, loadTime: time.Now(), path: path, volatile: true} r := &reg{loading: true, loadTime: time.Now(), path: path, volatile: true}
nav.regCache[path] = r nav.regCache[path] = r
nav.startPreview()
nav.previewChan <- path nav.previewChan <- path
return r return r
} }
@@ -839,10 +848,17 @@ func (nav *nav) checkReg(reg *reg) {
if s.ModTime().After(reg.loadTime) { if s.ModTime().After(reg.loadTime) {
reg.loadTime = now reg.loadTime = now
nav.startPreview()
nav.previewChan <- reg.path nav.previewChan <- reg.path
} }
} }
func (nav *nav) startPreview() {
nav.previewTimer.Stop()
nav.previewLoading = false
nav.previewTimer.Reset(100 * time.Millisecond)
}
func (nav *nav) sort() { func (nav *nav) sort() {
for _, d := range nav.dirs { for _, d := range nav.dirs {
name := d.name() name := d.name()
@@ -912,11 +928,13 @@ func (nav *nav) down(dist int) bool {
dir.ind = min(maxind, dir.ind) dir.ind = min(maxind, dir.ind)
dir.pos += dist dir.pos += dist
edge := min(min(nav.height/2, gOpts.scrolloff), maxind-dir.ind) // use a smaller value for half when the height is even and scrolloff is
// maxed in order to stay at the same row while scrolling up and down
// use a smaller value when the height is even and scrolloff is maxed half := nav.height / 2
// in order to stay at the same row as much as possible while up/down if nav.height%2 == 0 {
edge = min(edge, nav.height/2+nav.height%2-1) half--
}
edge := min(min(half, gOpts.scrolloff), maxind-dir.ind)
dir.pos = min(dir.pos, nav.height-edge-1) dir.pos = min(dir.pos, nav.height-edge-1)
dir.pos = min(dir.pos, maxind) dir.pos = min(dir.pos, maxind)
@@ -1086,6 +1104,19 @@ func (nav *nav) low() bool {
return old != dir.ind return old != dir.ind
} }
func (nav *nav) move(index int) bool {
old := nav.currDir().ind
switch {
case index < old:
return nav.up(old - index)
case index > old:
return nav.down(index - old)
default:
return false
}
}
func (nav *nav) toggleSelection(path string) { func (nav *nav) toggleSelection(path string) {
if _, ok := nav.selections[path]; ok { if _, ok := nav.selections[path]; ok {
delete(nav.selections, path) delete(nav.selections, path)
@@ -1149,14 +1180,22 @@ func (nav *nav) tag(tag string) error {
return nil return nil
} }
func (nav *nav) invert() { func (nav *nav) invertAfter(ix int) {
dir := nav.currDir() dir := nav.currDir()
for _, f := range dir.files { for _, f := range dir.files[ix:] {
path := filepath.Join(dir.path, f.Name()) path := filepath.Join(dir.path, f.Name())
nav.toggleSelection(path) nav.toggleSelection(path)
} }
} }
func (nav *nav) invert() {
nav.invertAfter(0)
}
func (nav *nav) invertBelow() {
nav.invertAfter(nav.currDir().ind)
}
func (nav *nav) unselect() { func (nav *nav) unselect() {
nav.selections = make(map[string]int) nav.selections = make(map[string]int)
nav.selectionInd = 0 nav.selectionInd = 0
@@ -1426,6 +1465,12 @@ func (nav *nav) rename() error {
return err return err
} }
// It is possible for newPath to already have cache entries if it previously
// existed and was deleted. In this case the cache entries should be deleted
// before loading newPath to prevent displaying a stale preview. However,
// this clears only the current instance of lf, and not any other instances.
delete(nav.regCache, newPath)
delete(nav.dirCache, newPath)
dir := nav.loadDir(filepath.Dir(newPath)) dir := nav.loadDir(filepath.Dir(newPath))
if dir.loading { if dir.loading {
@@ -1497,13 +1542,18 @@ func (nav *nav) sel(path string) error {
base := filepath.Base(path) base := filepath.Base(path)
last := nav.dirs[len(nav.dirs)-1] last := nav.currDir()
if last.loading { if last.loading {
last.files = append(last.files, &file{FileInfo: lstat}) last.files = append(last.files, &file{FileInfo: lstat})
} }
last.sel(base, nav.height) for i, f := range last.files {
if f.Name() == base {
nav.move(i)
break
}
}
return nil return nil
} }
+16 -2
View File
@@ -30,6 +30,9 @@ type sortType struct {
var gOpts struct { var gOpts struct {
anchorfind bool anchorfind bool
autoquit bool autoquit bool
cursoractivefmt string
cursorparentfmt string
cursorpreviewfmt string
dircache bool dircache bool
dircounts bool dircounts bool
dironly bool dironly bool
@@ -71,6 +74,7 @@ var gOpts struct {
hiddenfiles []string hiddenfiles []string
history bool history bool
info []string info []string
ruler []string
shellopts []string shellopts []string
keys map[string]expr keys map[string]expr
cmdkeys map[string]expr cmdkeys map[string]expr
@@ -78,6 +82,7 @@ var gOpts struct {
user map[string]string user map[string]string
sortType sortType sortType sortType
tempmarks string tempmarks string
numberfmt string
tagfmt string tagfmt string
} }
@@ -89,6 +94,9 @@ func init() {
gOpts.dironly = false gOpts.dironly = false
gOpts.dirpreviews = false gOpts.dirpreviews = false
gOpts.drawbox = false gOpts.drawbox = false
gOpts.cursoractivefmt = "\033[7m"
gOpts.cursorparentfmt = "\033[7m"
gOpts.cursorpreviewfmt = "\033[4m"
gOpts.globsearch = false gOpts.globsearch = false
gOpts.icons = false gOpts.icons = false
gOpts.ignorecase = true gOpts.ignorecase = true
@@ -108,7 +116,7 @@ func init() {
gOpts.period = 0 gOpts.period = 0
gOpts.scrolloff = 0 gOpts.scrolloff = 0
gOpts.tabstop = 8 gOpts.tabstop = 8
gOpts.errorfmt = "\033[7;31;47m%s\033[0m" gOpts.errorfmt = "\033[7;31;47m"
gOpts.filesep = "\n" gOpts.filesep = "\n"
gOpts.ifs = "" gOpts.ifs = ""
gOpts.previewer = "" gOpts.previewer = ""
@@ -125,10 +133,12 @@ func init() {
gOpts.hiddenfiles = []string{".*"} gOpts.hiddenfiles = []string{".*"}
gOpts.history = true gOpts.history = true
gOpts.info = nil gOpts.info = nil
gOpts.ruler = []string{"acc", "progress", "selection", "filter", "ind"}
gOpts.shellopts = nil gOpts.shellopts = nil
gOpts.sortType = sortType{naturalSort, dirfirstSort} gOpts.sortType = sortType{naturalSort, dirfirstSort}
gOpts.tempmarks = "'" gOpts.tempmarks = "'"
gOpts.tagfmt = "\033[31m%s\033[0m" gOpts.numberfmt = "\033[33m"
gOpts.tagfmt = "\033[31m"
gOpts.keys = make(map[string]expr) gOpts.keys = make(map[string]expr)
@@ -139,6 +149,7 @@ func init() {
gOpts.keys["<c-b>"] = &callExpr{"page-up", nil, 1} gOpts.keys["<c-b>"] = &callExpr{"page-up", nil, 1}
gOpts.keys["<pgup>"] = &callExpr{"page-up", nil, 1} gOpts.keys["<pgup>"] = &callExpr{"page-up", nil, 1}
gOpts.keys["<c-y>"] = &callExpr{"scroll-up", nil, 1} gOpts.keys["<c-y>"] = &callExpr{"scroll-up", nil, 1}
gOpts.keys["<c-m-up>"] = &callExpr{"scroll-up", nil, 1}
gOpts.keys["j"] = &callExpr{"down", nil, 1} gOpts.keys["j"] = &callExpr{"down", nil, 1}
gOpts.keys["<down>"] = &callExpr{"down", nil, 1} gOpts.keys["<down>"] = &callExpr{"down", nil, 1}
gOpts.keys["<m-down>"] = &callExpr{"down", nil, 1} gOpts.keys["<m-down>"] = &callExpr{"down", nil, 1}
@@ -146,6 +157,7 @@ func init() {
gOpts.keys["<c-f>"] = &callExpr{"page-down", nil, 1} gOpts.keys["<c-f>"] = &callExpr{"page-down", nil, 1}
gOpts.keys["<pgdn>"] = &callExpr{"page-down", nil, 1} gOpts.keys["<pgdn>"] = &callExpr{"page-down", nil, 1}
gOpts.keys["<c-e>"] = &callExpr{"scroll-down", nil, 1} gOpts.keys["<c-e>"] = &callExpr{"scroll-down", nil, 1}
gOpts.keys["<c-m-down>"] = &callExpr{"scroll-down", nil, 1}
gOpts.keys["h"] = &callExpr{"updir", nil, 1} gOpts.keys["h"] = &callExpr{"updir", nil, 1}
gOpts.keys["<left>"] = &callExpr{"updir", nil, 1} gOpts.keys["<left>"] = &callExpr{"updir", nil, 1}
gOpts.keys["l"] = &callExpr{"open", nil, 1} gOpts.keys["l"] = &callExpr{"open", nil, 1}
@@ -211,7 +223,9 @@ func init() {
gOpts.cmdkeys["<tab>"] = &callExpr{"cmd-complete", nil, 1} gOpts.cmdkeys["<tab>"] = &callExpr{"cmd-complete", nil, 1}
gOpts.cmdkeys["<enter>"] = &callExpr{"cmd-enter", nil, 1} gOpts.cmdkeys["<enter>"] = &callExpr{"cmd-enter", nil, 1}
gOpts.cmdkeys["<c-j>"] = &callExpr{"cmd-enter", nil, 1} gOpts.cmdkeys["<c-j>"] = &callExpr{"cmd-enter", nil, 1}
gOpts.cmdkeys["<down>"] = &callExpr{"cmd-history-next", nil, 1}
gOpts.cmdkeys["<c-n>"] = &callExpr{"cmd-history-next", nil, 1} gOpts.cmdkeys["<c-n>"] = &callExpr{"cmd-history-next", nil, 1}
gOpts.cmdkeys["<up>"] = &callExpr{"cmd-history-prev", nil, 1}
gOpts.cmdkeys["<c-p>"] = &callExpr{"cmd-history-prev", nil, 1} gOpts.cmdkeys["<c-p>"] = &callExpr{"cmd-history-prev", nil, 1}
gOpts.cmdkeys["<delete>"] = &callExpr{"cmd-delete", nil, 1} gOpts.cmdkeys["<delete>"] = &callExpr{"cmd-delete", nil, 1}
gOpts.cmdkeys["<c-d>"] = &callExpr{"cmd-delete", nil, 1} gOpts.cmdkeys["<c-d>"] = &callExpr{"cmd-delete", nil, 1}
+5 -2
View File
@@ -18,7 +18,7 @@ import (
var ( var (
envOpener = os.Getenv("OPENER") envOpener = os.Getenv("OPENER")
envEditor = os.Getenv("EDITOR") envEditor = os.Getenv("VISUAL")
envPager = os.Getenv("PAGER") envPager = os.Getenv("PAGER")
envShell = os.Getenv("SHELL") envShell = os.Getenv("SHELL")
) )
@@ -50,9 +50,12 @@ func init() {
} }
} }
if envEditor == "" {
envEditor = os.Getenv("EDITOR")
if envEditor == "" { if envEditor == "" {
envEditor = "vi" envEditor = "vi"
} }
}
if envPager == "" { if envPager == "" {
envPager = "less" envPager = "less"
@@ -159,7 +162,7 @@ func setDefaults() {
gOpts.keys["i"] = &execExpr{"$", `$PAGER "$f"`} gOpts.keys["i"] = &execExpr{"$", `$PAGER "$f"`}
gOpts.keys["w"] = &execExpr{"$", "$SHELL"} gOpts.keys["w"] = &execExpr{"$", "$SHELL"}
gOpts.cmds["doc"] = &execExpr{"$", "lf -doc | $PAGER"} gOpts.cmds["doc"] = &execExpr{"$", `"$lf" -doc | $PAGER`}
gOpts.keys["<f-1>"] = &callExpr{"doc", nil, 1} gOpts.keys["<f-1>"] = &callExpr{"doc", nil, 1}
} }
+5 -2
View File
@@ -14,7 +14,7 @@ import (
var ( var (
envOpener = os.Getenv("OPENER") envOpener = os.Getenv("OPENER")
envEditor = os.Getenv("EDITOR") envEditor = os.Getenv("VISUAL")
envPager = os.Getenv("PAGER") envPager = os.Getenv("PAGER")
envShell = os.Getenv("SHELL") envShell = os.Getenv("SHELL")
) )
@@ -44,9 +44,12 @@ func init() {
envOpener = `start ""` envOpener = `start ""`
} }
if envEditor == "" {
envEditor = os.Getenv("EDITOR")
if envEditor == "" { if envEditor == "" {
envEditor = "notepad" envEditor = "notepad"
} }
}
if envPager == "" { if envPager == "" {
envPager = "more" envPager = "more"
@@ -115,7 +118,7 @@ func setDefaults() {
gOpts.keys["i"] = &execExpr{"!", "%PAGER% %f%"} gOpts.keys["i"] = &execExpr{"!", "%PAGER% %f%"}
gOpts.keys["w"] = &execExpr{"$", "%SHELL%"} gOpts.keys["w"] = &execExpr{"$", "%SHELL%"}
gOpts.cmds["doc"] = &execExpr{"!", "lf -doc | %PAGER%"} gOpts.cmds["doc"] = &execExpr{"!", "%lf% -doc | %PAGER%"}
gOpts.keys["<f-1>"] = &callExpr{"doc", nil, 1} gOpts.keys["<f-1>"] = &callExpr{"doc", nil, 1}
} }
+1 -2
View File
@@ -2,7 +2,6 @@ package main
import ( import (
"io" "io"
"io/ioutil"
"log" "log"
"strconv" "strconv"
) )
@@ -38,7 +37,7 @@ type scanner struct {
} }
func newScanner(r io.Reader) *scanner { func newScanner(r io.Reader) *scanner {
buf, err := ioutil.ReadAll(r) buf, err := io.ReadAll(r)
if err != nil { if err != nil {
log.Printf("scanning: %s", err) log.Printf("scanning: %s", err)
} }
+163 -90
View File
@@ -252,7 +252,7 @@ func (win *win) printRight(screen tcell.Screen, y int, st tcell.Style, s string)
win.print(screen, win.w-printLength(s), y, st, s) win.print(screen, win.w-printLength(s), y, st, s)
} }
func (win *win) printReg(screen tcell.Screen, reg *reg) { func (win *win) printReg(screen tcell.Screen, reg *reg, previewLoading bool) {
if reg == nil { if reg == nil {
return return
} }
@@ -260,8 +260,10 @@ func (win *win) printReg(screen tcell.Screen, reg *reg) {
st := tcell.StyleDefault st := tcell.StyleDefault
if reg.loading { if reg.loading {
if previewLoading {
st = st.Reverse(true) st = st.Reverse(true)
win.print(screen, 2, 0, st, "loading...") win.print(screen, 2, 0, st, "loading...")
}
return return
} }
@@ -330,19 +332,26 @@ type dirContext struct {
tags map[string]string tags map[string]string
} }
type dirRole byte
const (
Active dirRole = iota
Parent
Preview
)
type dirStyle struct { type dirStyle struct {
colors styleMap colors styleMap
icons iconMap icons iconMap
previewing bool role dirRole
} }
// These colors are not currently customizeable // These colors are not currently customizeable
const LineNumberColor = tcell.ColorOlive
const SelectionColor = tcell.ColorPurple const SelectionColor = tcell.ColorPurple
const YankColor = tcell.ColorOlive const YankColor = tcell.ColorOlive
const CutColor = tcell.ColorMaroon const CutColor = tcell.ColorMaroon
func (win *win) printDir(screen tcell.Screen, dir *dir, context *dirContext, dirStyle *dirStyle) { func (win *win) printDir(screen tcell.Screen, dir *dir, context *dirContext, dirStyle *dirStyle, previewLoading bool) {
if win.w < 5 || dir == nil { if win.w < 5 || dir == nil {
return return
} }
@@ -353,12 +362,14 @@ func (win *win) printDir(screen tcell.Screen, dir *dir, context *dirContext, dir
win.print(screen, 2, 0, messageStyle, "permission denied") win.print(screen, 2, 0, messageStyle, "permission denied")
return return
} }
if (dir.loading && len(dir.files) == 0) || (dirStyle.previewing && dir.loading && gOpts.dirpreviews) { if (dir.loading && len(dir.files) == 0) || (dirStyle.role == Preview && dir.loading && gOpts.dirpreviews) {
if dirStyle.role != Preview || previewLoading {
win.print(screen, 2, 0, messageStyle, "loading...") win.print(screen, 2, 0, messageStyle, "loading...")
}
return return
} }
if dirStyle.previewing && gOpts.dirpreviews && len(gOpts.previewer) > 0 { if dirStyle.role == Preview && gOpts.dirpreviews && len(gOpts.previewer) > 0 {
// Print previewer result instead of default directory print operation. // Print previewer result instead of default directory print operation.
st := tcell.StyleDefault st := tcell.StyleDefault
for i, l := range dir.lines { for i, l := range dir.lines {
@@ -383,17 +394,15 @@ func (win *win) printDir(screen tcell.Screen, dir *dir, context *dirContext, dir
} }
var lnwidth int var lnwidth int
var lnformat string
if gOpts.number || gOpts.relativenumber { if gOpts.number || gOpts.relativenumber {
lnwidth = 1 lnwidth = 1
if gOpts.number && gOpts.relativenumber { if gOpts.number && gOpts.relativenumber {
lnwidth++ lnwidth++
} }
for j := 10; j < len(dir.files); j *= 10 { for j := 10; j <= len(dir.files); j *= 10 {
lnwidth++ lnwidth++
} }
lnformat = fmt.Sprintf("%%%d.d ", lnwidth)
} }
for i, f := range dir.files[beg:end] { for i, f := range dir.files[beg:end] {
@@ -403,21 +412,21 @@ func (win *win) printDir(screen tcell.Screen, dir *dir, context *dirContext, dir
var ln string var ln string
if gOpts.number && (!gOpts.relativenumber) { if gOpts.number && (!gOpts.relativenumber) {
ln = fmt.Sprintf(lnformat, i+1+beg) ln = fmt.Sprintf("%*d", lnwidth, i+1+beg)
} else if gOpts.relativenumber { } else if gOpts.relativenumber {
switch { switch {
case i < dir.pos: case i < dir.pos:
ln = fmt.Sprintf(lnformat, dir.pos-i) ln = fmt.Sprintf("%*d", lnwidth, dir.pos-i)
case i > dir.pos: case i > dir.pos:
ln = fmt.Sprintf(lnformat, i-dir.pos) ln = fmt.Sprintf("%*d", lnwidth, i-dir.pos)
case gOpts.number: case gOpts.number:
ln = fmt.Sprintf(fmt.Sprintf("%%%d.d ", lnwidth-1), i+1+beg) ln = fmt.Sprintf("%*d ", lnwidth-1, i+1+beg)
default: default:
ln = "" ln = fmt.Sprintf("%*d", lnwidth, 0)
} }
} }
win.print(screen, 0, i, tcell.StyleDefault.Foreground(LineNumberColor), ln) win.print(screen, 0, i, tcell.StyleDefault, fmt.Sprintf(optionToFmtstr(gOpts.numberfmt), ln))
} }
path := filepath.Join(dir.path, f.Name()) path := filepath.Join(dir.path, f.Name())
@@ -432,20 +441,13 @@ func (win *win) printDir(screen tcell.Screen, dir *dir, context *dirContext, dir
} }
} }
if i == dir.pos {
st = st.Reverse(true)
}
var s []rune var s []rune
s = append(s, ' ') s = append(s, ' ')
var iwidth int
if gOpts.icons { if gOpts.icons {
s = append(s, []rune(dirStyle.icons.get(f))...) s = append(s, []rune(dirStyle.icons.get(f))...)
s = append(s, ' ') s = append(s, ' ')
iwidth = 2
} }
for _, r := range f.Name() { for _, r := range f.Name() {
@@ -454,39 +456,59 @@ func (win *win) printDir(screen tcell.Screen, dir *dir, context *dirContext, dir
w := runeSliceWidth(s) w := runeSliceWidth(s)
if w > win.w-3 { // make space for select marker, and leave another space at the end
s = runeSliceWidthRange(s, 0, win.w-4) maxlength := win.w - lnwidth - 2
// make extra space to separate windows if drawbox is not enabled
if !gOpts.drawbox {
maxlength -= 1
}
if w > maxlength {
s = runeSliceWidthRange(s, 0, maxlength-1)
s = append(s, []rune(gOpts.truncatechar)...) s = append(s, []rune(gOpts.truncatechar)...)
} else { } else {
for i := 0; i < win.w-3-w; i++ { for i := 0; i < maxlength-w; i++ {
s = append(s, ' ') s = append(s, ' ')
} }
} }
info := fileInfo(f, dir) info := fileInfo(f, dir)
if len(info) > 0 && win.w-lnwidth-iwidth-2 > 2*len(info) { if len(info) > 0 && 2*len(info) < maxlength {
if win.w-2 > w+len(info) { if w+len(info) > maxlength {
s = runeSliceWidthRange(s, 0, win.w-3-len(info)-lnwidth) s = runeSliceWidthRange(s, 0, maxlength-len(info)-1)
} else {
s = runeSliceWidthRange(s, 0, win.w-4-len(info)-lnwidth)
s = append(s, []rune(gOpts.truncatechar)...) s = append(s, []rune(gOpts.truncatechar)...)
} else {
s = runeSliceWidthRange(s, 0, maxlength-len(info))
} }
for _, r := range info { for _, r := range info {
s = append(s, r) s = append(s, r)
} }
} }
s = append(s, ' ') ce := ""
if i == dir.pos {
switch dirStyle.role {
case Active:
ce = gOpts.cursoractivefmt
case Parent:
ce = gOpts.cursorparentfmt
case Preview:
ce = gOpts.cursorpreviewfmt
}
}
cursorescapefmt := optionToFmtstr(ce)
win.print(screen, lnwidth+1, i, st, string(s)) s = append(s, ' ')
styledFilename := fmt.Sprintf(cursorescapefmt, string(s))
win.print(screen, lnwidth+1, i, st, styledFilename)
tag, ok := context.tags[path] tag, ok := context.tags[path]
if ok { if ok {
if i == dir.pos { if i == dir.pos {
win.print(screen, lnwidth+1, i, st, tag) win.print(screen, lnwidth+1, i, st, fmt.Sprintf(cursorescapefmt, tag))
} else { } else {
win.print(screen, lnwidth+1, i, tcell.StyleDefault, fmt.Sprintf(gOpts.tagfmt, tag)) win.print(screen, lnwidth+1, i, tcell.StyleDefault, fmt.Sprintf(optionToFmtstr(gOpts.tagfmt), tag))
} }
} }
} }
@@ -501,6 +523,10 @@ func getWidths(wtot int) []int {
wlen := len(gOpts.ratios) wlen := len(gOpts.ratios)
widths := make([]int, wlen) widths := make([]int, wlen)
if gOpts.drawbox {
wtot -= (wlen + 1)
}
wsum := 0 wsum := 0
for i := 0; i < wlen-1; i++ { for i := 0; i < wlen-1; i++ {
widths[i] = gOpts.ratios[i] * wtot / rsum widths[i] = gOpts.ratios[i] * wtot / rsum
@@ -508,10 +534,6 @@ func getWidths(wtot int) []int {
} }
widths[wlen-1] = wtot - wsum widths[wlen-1] = wtot - wsum
if gOpts.drawbox {
widths[wlen-1]--
}
return widths return widths
} }
@@ -526,7 +548,8 @@ func getWins(screen tcell.Screen) []*win {
wlen := len(widths) wlen := len(widths)
for i := 0; i < wlen; i++ { for i := 0; i < wlen; i++ {
if gOpts.drawbox { if gOpts.drawbox {
wins = append(wins, newWin(widths[i], htot-4, wacc+1, 2)) wacc++
wins = append(wins, newWin(widths[i], htot-4, wacc, 2))
} else { } else {
wins = append(wins, newWin(widths[i], htot-2, wacc, 1)) wins = append(wins, newWin(widths[i], htot-2, wacc, 1))
} }
@@ -610,21 +633,9 @@ func (ui *ui) pollEvents() {
} }
func (ui *ui) renew() { func (ui *ui) renew() {
ui.wins = getWins(ui.screen)
wtot, htot := ui.screen.Size() wtot, htot := ui.screen.Size()
widths := getWidths(wtot)
wacc := 0
wlen := len(widths)
for i := 0; i < wlen; i++ {
if gOpts.drawbox {
ui.wins[i].renew(widths[i], htot-4, wacc+1, 2)
} else {
ui.wins[i].renew(widths[i], htot-2, wacc, 1)
}
wacc += widths[i]
}
ui.promptWin.renew(wtot, 1, 0, 0) ui.promptWin.renew(wtot, 1, 0, 0)
ui.msgWin.renew(wtot, 1, 0, htot-1) ui.msgWin.renew(wtot, 1, 0, htot-1)
ui.menuWin.renew(wtot, 1, 0, htot-2) ui.menuWin.renew(wtot, 1, 0, htot-2)
@@ -652,8 +663,16 @@ 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.msg = fmt.Sprintf(gOpts.errorfmt, msg) ui.msg = fmt.Sprintf(optionToFmtstr(gOpts.errorfmt), msg)
log.Printf("error: %s", msg) log.Printf("error: %s", msg)
} }
@@ -679,11 +698,10 @@ func (ui *ui) loadFile(app *app, volatile bool) {
return return
} }
if curr.path == ui.currentFile { if curr.path != ui.currentFile {
return
}
ui.currentFile = curr.path ui.currentFile = curr.path
onSelect(app) onSelect(app)
}
if !gOpts.preview { if !gOpts.preview {
return return
@@ -797,7 +815,7 @@ func (ui *ui) drawStatLine(nav *nav) {
ind := min(dir.ind+1, tot) ind := min(dir.ind+1, tot)
acc := string(ui.keyCount) + string(ui.keyAcc) acc := string(ui.keyCount) + string(ui.keyAcc)
var selection string selection := []string{}
if len(nav.saves) > 0 { if len(nav.saves) > 0 {
copy := 0 copy := 0
@@ -810,40 +828,58 @@ func (ui *ui) drawStatLine(nav *nav) {
} }
} }
if copy > 0 { if copy > 0 {
selection += fmt.Sprintf(" \033[33;7m %d \033[0m", copy) selection = append(selection, fmt.Sprintf("\033[33;7m %d \033[0m", copy))
} }
if move > 0 { if move > 0 {
selection += fmt.Sprintf(" \033[31;7m %d \033[0m", move) selection = append(selection, fmt.Sprintf("\033[31;7m %d \033[0m", move))
} }
} }
currSelections := nav.currSelections() currSelections := nav.currSelections()
if len(currSelections) > 0 { if len(currSelections) > 0 {
selection += fmt.Sprintf(" \033[35;7m %d \033[0m", len(currSelections)) selection = append(selection, fmt.Sprintf("\033[35;7m %d \033[0m", len(currSelections)))
} }
if len(dir.filter) != 0 { progress := []string{}
selection += " \033[34;7m F \033[0m"
}
var progress string
if nav.copyTotal > 0 { if nav.copyTotal > 0 {
percentage := int((100 * float64(nav.copyBytes)) / float64(nav.copyTotal)) percentage := int((100 * float64(nav.copyBytes)) / float64(nav.copyTotal))
progress += fmt.Sprintf(" [%d%%]", percentage) progress = append(progress, fmt.Sprintf("[%d%%]", percentage))
} }
if nav.moveTotal > 0 { if nav.moveTotal > 0 {
progress += fmt.Sprintf(" [%d/%d]", nav.moveCount, nav.moveTotal) progress = append(progress, fmt.Sprintf("[%d/%d]", nav.moveCount, nav.moveTotal))
} }
if nav.deleteTotal > 0 { if nav.deleteTotal > 0 {
progress += fmt.Sprintf(" [%d/%d]", nav.deleteCount, nav.deleteTotal) progress = append(progress, fmt.Sprintf("[%d/%d]", nav.deleteCount, nav.deleteTotal))
} }
ruler := fmt.Sprintf("%s%s%s %d/%d", acc, progress, selection, ind, tot) ruler := []string{}
for _, s := range gOpts.ruler {
switch s {
case "df":
df := diskFree(dir.path)
if df != "" {
ruler = append(ruler, df)
}
case "acc":
ruler = append(ruler, acc)
case "progress":
ruler = append(ruler, progress...)
case "selection":
ruler = append(ruler, selection...)
case "filter":
if len(dir.filter) != 0 {
ruler = append(ruler, "\033[34;7m F \033[0m")
}
case "ind":
ruler = append(ruler, fmt.Sprintf("%d/%d", ind, tot))
}
ui.msgWin.printRight(ui.screen, 0, st, ruler) }
ui.msgWin.printRight(ui.screen, 0, st, strings.Join(ruler, " "))
} }
func (ui *ui) drawBox() { func (ui *ui) drawBox() {
@@ -852,28 +888,28 @@ func (ui *ui) drawBox() {
w, h := ui.screen.Size() w, h := ui.screen.Size()
for i := 1; i < w-1; i++ { for i := 1; i < w-1; i++ {
ui.screen.SetContent(i, 1, '─', nil, st) ui.screen.SetContent(i, 1, tcell.RuneHLine, nil, st)
ui.screen.SetContent(i, h-2, '─', nil, st) ui.screen.SetContent(i, h-2, tcell.RuneHLine, nil, st)
} }
for i := 2; i < h-2; i++ { for i := 2; i < h-2; i++ {
ui.screen.SetContent(0, i, '│', nil, st) ui.screen.SetContent(0, i, tcell.RuneVLine, nil, st)
ui.screen.SetContent(w-1, i, '│', nil, st) ui.screen.SetContent(w-1, i, tcell.RuneVLine, nil, st)
} }
ui.screen.SetContent(0, 1, '┌', nil, st) ui.screen.SetContent(0, 1, tcell.RuneULCorner, nil, st)
ui.screen.SetContent(w-1, 1, '┐', nil, st) ui.screen.SetContent(w-1, 1, tcell.RuneURCorner, nil, st)
ui.screen.SetContent(0, h-2, '└', nil, st) ui.screen.SetContent(0, h-2, tcell.RuneLLCorner, nil, st)
ui.screen.SetContent(w-1, h-2, '┘', nil, st) ui.screen.SetContent(w-1, h-2, tcell.RuneLRCorner, nil, st)
wacc := 0 wacc := 0
for wind := 0; wind < len(ui.wins)-1; wind++ { for wind := 0; wind < len(ui.wins)-1; wind++ {
wacc += ui.wins[wind].w wacc += ui.wins[wind].w + 1
ui.screen.SetContent(wacc, 1, '┬', nil, st) ui.screen.SetContent(wacc, 1, tcell.RuneTTee, nil, st)
for i := 2; i < h-2; i++ { for i := 2; i < h-2; i++ {
ui.screen.SetContent(wacc, i, '│', nil, st) ui.screen.SetContent(wacc, i, tcell.RuneVLine, nil, st)
} }
ui.screen.SetContent(wacc, h-2, '┴', nil, st) ui.screen.SetContent(wacc, h-2, tcell.RuneBTee, nil, st)
} }
} }
@@ -893,6 +929,7 @@ func (ui *ui) draw(nav *nav) {
st := tcell.StyleDefault st := tcell.StyleDefault
context := dirContext{selections: nav.selections, saves: nav.saves, tags: nav.tags} context := dirContext{selections: nav.selections, saves: nav.saves, tags: nav.tags}
// XXX: manual clean without flush to avoid flicker on Windows
wtot, htot := ui.screen.Size() wtot, htot := ui.screen.Size()
for i := 0; i < wtot; i++ { for i := 0; i < wtot; i++ {
for j := 0; j < htot; j++ { for j := 0; j < htot; j++ {
@@ -907,9 +944,14 @@ func (ui *ui) draw(nav *nav) {
wins-- wins--
} }
for i := 0; i < wins; i++ { for i := 0; i < wins; i++ {
role := Parent
if i == wins-1 {
role = Active
}
if dir := ui.dirOfWin(nav, i); dir != nil { if dir := ui.dirOfWin(nav, i); dir != nil {
ui.wins[i].printDir(ui.screen, dir, &context, ui.wins[i].printDir(ui.screen, dir, &context,
&dirStyle{colors: ui.styles, icons: ui.icons, previewing: false}) &dirStyle{colors: ui.styles, icons: ui.icons, role: role},
nav.previewLoading)
} }
} }
@@ -945,9 +987,10 @@ func (ui *ui) draw(nav *nav) {
if curr.IsDir() { if curr.IsDir() {
preview.printDir(ui.screen, ui.dirPrev, &context, preview.printDir(ui.screen, ui.dirPrev, &context,
&dirStyle{colors: ui.styles, icons: ui.icons, previewing: true}) &dirStyle{colors: ui.styles, icons: ui.icons, role: Preview},
nav.previewLoading)
} else if curr.Mode().IsRegular() { } else if curr.Mode().IsRegular() {
preview.printReg(ui.screen, ui.regPrev) preview.printReg(ui.screen, ui.regPrev, nav.previewLoading)
} }
} }
} }
@@ -1013,6 +1056,30 @@ func listBinds(binds map[string]expr) *bytes.Buffer {
return b return b
} }
func listJumps(jumps []string, ind int) *bytes.Buffer {
t := new(tabwriter.Writer)
b := new(bytes.Buffer)
maxlength := len(strconv.Itoa(max(ind, len(jumps)-1-ind)))
t.Init(b, 0, gOpts.tabstop, 2, '\t', 0)
fmt.Fprintln(t, " jump\tpath")
// print jumps in order of most recent, Vim uses the opposite order
for i := len(jumps) - 1; i >= 0; i-- {
switch {
case i < ind:
fmt.Fprintf(t, " %*d\t%s\n", maxlength, ind-i, jumps[i])
case i > ind:
fmt.Fprintf(t, " %*d\t%s\n", maxlength, i-ind, jumps[i])
default:
fmt.Fprintf(t, "> %*d\t%s\n", maxlength, 0, jumps[i])
}
}
t.Flush()
return b
}
func listMarks(marks map[string]string) *bytes.Buffer { func listMarks(marks map[string]string) *bytes.Buffer {
t := new(tabwriter.Writer) t := new(tabwriter.Writer)
b := new(bytes.Buffer) b := new(bytes.Buffer)
@@ -1182,12 +1249,18 @@ func (ui *ui) readNormalEvent(ev tcell.Event, nav *nav) expr {
case tcell.ButtonNone: case tcell.ButtonNone:
return nil return nil
} }
if tev.Modifiers() == tcell.ModCtrl {
button = "<c-" + button[1:]
}
if expr, ok := gOpts.keys[button]; ok { if expr, ok := gOpts.keys[button]; ok {
return expr return expr
} }
if button != "<m-1>" && button != "<m-2>" {
if tev.Buttons() != tcell.Button1 && tev.Buttons() != tcell.Button2 { ui.echoerrf("unknown mapping: %s", button)
return nil ui.keyAcc = nil
ui.keyCount = nil
ui.menuBuf = nil
return draw
} }
x, y := tev.Position() x, y := tev.Position()
@@ -1331,7 +1404,7 @@ func listMatches(screen tcell.Screen, matches []string, selectedInd int) *bytes.
wcol = max(wcol, len(m)) wcol = max(wcol, len(m))
} }
wcol += gOpts.tabstop - wcol%gOpts.tabstop wcol += gOpts.tabstop - wcol%gOpts.tabstop
ncol := wtot / wcol ncol := max(wtot/wcol, 1)
b.WriteString("possible matches\n") b.WriteString("possible matches\n")