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 1806 additions and 790 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:
os: [ubuntu-latest, windows-latest]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 1
- name: Set up Go
uses: actions/setup-go@v2
uses: actions/setup-go@v4
with:
go-version: 1.17
go-version: 1.18
- name: Build
run: go build -v ./...
@@ -29,7 +29,7 @@ jobs:
- name: Test
run: go test -v ./...
- uses: dominikh/staticcheck-action@v1.2.0
- uses: dominikh/staticcheck-action@v1.3.0
with:
version: "2022.1.3"
install-go: false
@@ -37,12 +37,12 @@ jobs:
generate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 1
- name: Set up Go
uses: actions/setup-go@v2
uses: actions/setup-go@v4
with:
go-version: 1.19
+14 -3
View File
@@ -10,12 +10,12 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v2
uses: actions/setup-go@v4
with:
go-version: 1.17
go-version: 1.18
- name: Build
run: gen/xbuild.sh
@@ -26,3 +26,14 @@ jobs:
files: dist/*
env:
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)
- 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
@@ -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/).
On Unix (Go version < 1.17):
```bash
env CGO_ENABLED=0 GO111MODULE=on go get -u -ldflags="-s -w" github.com/gokcehan/lf
```
On Unix (Go version >= 1.17):
On Unix:
```bash
env CGO_ENABLED=0 go install -ldflags="-s -w" github.com/gokcehan/lf@latest
```
On Windows `cmd` (Go version < 1.17):
```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):
On Windows `cmd`:
```cmd
set CGO_ENABLED=0
go install -ldflags="-s -w" github.com/gokcehan/lf@latest
```
On Windows `powershell` (Go version < 1.17):
```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):
On Windows `powershell`:
```powershell
$env:CGO_ENABLED = '0'
+45 -3
View File
@@ -467,10 +467,17 @@ func (app *app) loop() {
app.nav.renew()
app.ui.loadFile(app, false)
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:
//
// 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
// ! Yes No Yes Yes Yes Pause and then resume
// & 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.ui.exportSizes()
exportOpts()
@@ -488,6 +496,24 @@ func (app *app) runShell(s string, args []string, prefix string) {
var out io.Reader
var err error
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 "$", "!":
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
@@ -512,7 +538,7 @@ func (app *app) runShell(s string, args []string, prefix string) {
case "%":
shellSetPG(cmd)
if app.ui.cmdPrefix == ">" {
return
return noopCleanFunc
}
stdin, err := cmd.StdinPipe()
if err != nil {
@@ -540,7 +566,11 @@ func (app *app) runShell(s string, args []string, prefix string) {
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 {
case "%":
@@ -585,5 +615,17 @@ func (app *app) runShell(s string, args []string, prefix string) {
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"
"fmt"
"io"
"io/ioutil"
"log"
"net"
"os"
@@ -34,7 +33,7 @@ func run() {
defer f.Close()
log.SetOutput(f)
} else {
log.SetOutput(ioutil.Discard)
log.SetOutput(io.Discard)
}
log.Print("hi!")
+22 -14
View File
@@ -1,7 +1,6 @@
package main
import (
"io/ioutil"
"log"
"os"
"path/filepath"
@@ -13,7 +12,9 @@ var (
gCmdWords = []string{
"set",
"map",
"maps",
"cmap",
"cmaps",
"cmd",
"quit",
"up",
@@ -28,6 +29,7 @@ var (
"open",
"jump-next",
"jump-prev",
"jumps",
"top",
"bottom",
"high",
@@ -35,6 +37,7 @@ var (
"low",
"toggle",
"invert",
"invert-below",
"unselect",
"glob-select",
"glob-unselect",
@@ -113,6 +116,9 @@ var (
"autoquit",
"noautoquit",
"autoquit!",
"cursoractivefmt",
"cursorparentfmt",
"cursorpreviewfmt",
"dircache",
"nodircache",
"dircache!",
@@ -167,6 +173,7 @@ var (
"reverse",
"noreverse",
"reverse!",
"ruler",
"smartcase",
"nosmartcase",
"smartcase!",
@@ -190,6 +197,7 @@ var (
"history",
"ifs",
"info",
"numberfmt",
"previewer",
"cleaner",
"promptfmt",
@@ -249,7 +257,7 @@ func matchExec(s string) (matches []string, longest []rune) {
continue
}
files, err := ioutil.ReadDir(p)
files, err := os.ReadDir(p)
if err != nil {
log.Printf("reading path: %s", err)
}
@@ -259,18 +267,18 @@ func matchExec(s string) (matches []string, longest []rune) {
continue
}
f, err = os.Stat(filepath.Join(p, f.Name()))
finfo, err := f.Info()
if err != nil {
log.Printf("getting file information: %s", err)
continue
}
if !f.Mode().IsRegular() || !isExecutable(f) {
if !finfo.Mode().IsRegular() || !isExecutable(finfo) {
continue
}
log.Print(f.Name())
words = append(words, f.Name())
log.Print(finfo.Name())
words = append(words, finfo.Name())
}
}
@@ -303,7 +311,7 @@ func matchFile(s string) (matches []string, longest []rune) {
dir = filepath.Dir(unescape(dir))
files, err := ioutil.ReadDir(dir)
files, err := os.ReadDir(dir)
if err != nil {
log.Printf("reading directory: %s", err)
}
@@ -334,14 +342,14 @@ func matchFile(s string) (matches []string, longest []rune) {
}
matches = append(matches, item)
if longest != nil {
longest = matchLongest(longest, []rune(name))
} else if s != "" {
if longest == nil {
if f.Mode().IsRegular() {
longest = []rune(name + " ")
} else {
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)
}
files, err := ioutil.ReadDir(wd)
files, err := os.ReadDir(wd)
if err != nil {
log.Printf("reading directory: %s", err)
}
@@ -433,10 +441,10 @@ func completeFile(acc []rune) (matches []string, longestAcc []rune) {
matches = append(matches, f.Name())
if longestAcc != nil {
longestAcc = matchLongest(longestAcc, []rune(f.Name()))
} else if s != "" {
if longestAcc == nil {
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))
}
+177 -95
View File
@@ -36,6 +36,7 @@ The following commands are provided by lf:
low (default 'L')
toggle
invert (default 'v')
invert-below
unselect (default 'u')
glob-select
glob-unselect
@@ -78,6 +79,9 @@ The following commands are provided by lf:
mark-remove (modal) (default '"')
tag
tag-toggle (default 't')
maps
cmaps
jumps
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-enter (default '<c-j>' and '<enter>')
cmd-interrupt (default '<c-c>')
cmd-history-next (default '<c-n>')
cmd-history-prev (default '<c-p>')
cmd-history-next (default '<c-n>' and '<down>')
cmd-history-prev (default '<c-p>' and '<up>')
cmd-left (default '<c-b>' and '<left>')
cmd-right (default '<c-f>' and '<right>')
cmd-home (default '<c-a>' and '<home>')
@@ -111,57 +115,62 @@ The following command line commands are provided by lf:
The following options can be used to customize the behavior of lf:
anchorfind bool (default on)
autoquit bool (default off)
cleaner string (default '')
dircache bool (default on)
dircounts bool (default off)
dirfirst bool (default on)
dironly bool (default off)
dirpreviews bool (default off)
drawbox bool (default off)
errorfmt string (default "\033[7;31;47m%s\033[0m")
filesep string (default "\n")
findlen int (default 1)
globsearch bool (default off)
hidden bool (default off)
hiddenfiles []string (default '.*')
history bool (default on)
icons bool (default off)
ifs string (default '')
ignorecase bool (default on)
ignoredia bool (default on)
incfilter bool (default off)
incsearch bool (default off)
info []string (default '')
infotimefmtnew string (default 'Jan _2 15:04')
infotimefmtold string (default 'Jan _2 2006')
mouse bool (default off)
number bool (default off)
period int (default 0)
preview bool (default on)
previewer string (default '')
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')
relativenumber bool (default off)
reverse bool (default off)
scrolloff int (default 0)
selmode string (default 'all')
shell string (default 'sh' for Unix and 'cmd' for Windows)
shellflag string (default '-c' for Unix and '/c' for Windows)
shellopts []string (default '')
smartcase bool (default on)
smartdia bool (default off)
sortby string (default 'natural')
tabstop int (default 8)
tagfmt string (default "\033[31m%s\033[0m")
tempmarks string (default '')
timefmt string (default 'Mon Jan _2 15:04:05 2006')
truncatechar string (default '~')
waitmsg string (default 'Press any key to continue')
wrapscan bool (default on)
wrapscroll bool (default off)
user_{option} string (default none)
anchorfind bool (default true)
autoquit bool (default false)
cleaner string (default '')
cursoractivefmt string (default "\033[7m")
cursorparentfmt string (default "\033[7m")
cursorpreviewfmt string (default "\033[4m")
dircache bool (default true)
dircounts bool (default false)
dirfirst bool (default true)
dironly bool (default false)
dirpreviews bool (default false)
drawbox bool (default false)
errorfmt string (default "\033[7;31;47m")
filesep string (default "\n")
findlen int (default 1)
globsearch bool (default false)
hidden bool (default false)
hiddenfiles []string (default '.*')
history bool (default true)
icons bool (default false)
ifs string (default '')
ignorecase bool (default true)
ignoredia bool (default true)
incfilter bool (default false)
incsearch bool (default false)
info []string (default '')
infotimefmtnew string (default 'Jan _2 15:04')
infotimefmtold string (default 'Jan _2 2006')
mouse bool (default false)
number bool (default false)
numberfmt string (default "\033[33m")
period int (default 0)
preview bool (default true)
previewer string (default '')
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')
relativenumber bool (default false)
reverse bool (default false)
ruler []string (default 'acc:progress:selection:filter:ind')
scrolloff int (default 0)
selmode string (default 'all')
shell string (default 'sh' for Unix and 'cmd' for Windows)
shellflag string (default '-c' for Unix and '/c' for Windows)
shellopts []string (default '')
smartcase bool (default true)
smartdia bool (default false)
sortby string (default 'natural')
tabstop int (default 8)
tagfmt string (default "\033[31m")
tempmarks string (default '')
timefmt string (default 'Mon Jan _2 15:04:05 2006')
truncatechar string (default '~')
waitmsg string (default 'Press any key to continue')
wrapscan bool (default true)
wrapscroll bool (default false)
user_{option} string (default none)
The following environment variables are exported for shell commands:
@@ -173,13 +182,16 @@ The following environment variables are exported for shell commands:
OLDPWD
LF_LEVEL
OPENER
VISUAL
EDITOR
PAGER
SHELL
lf
lf_{option}
lf_user_{option}
lf_width
lf_height
lf_count
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.
Scroll wheel
Scroll up or down.
Move up or down. If Ctrl is pressed, scroll up or down.
# Configuration
@@ -317,6 +329,7 @@ Change the current working directory to the next/previous jumplist item.
bottom (default 'G' and '<end>')
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')
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.
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')
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.
cmd-history-next (default '<c-n>')
cmd-history-prev (default '<c-p>')
cmd-history-next (default '<c-n>' and '<down>')
cmd-history-prev (default '<c-p>' and '<up>')
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.
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
This section shows information about options to customize the behavior.
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.
autoquit bool (default off)
autoquit bool (default false)
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.
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.
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'.
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.
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.
dironly bool (default off)
If enabled, directories will also be passed to the previewer script. This allows custom previews for directories.
dirpreviews bool (default off)
dironly bool (default false)
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.
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.
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")
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.
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.
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.
hidden bool (default off)
hidden bool (default false)
Show hidden files.
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.
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.
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'
history bool (default on)
history bool (default true)
Save command history.
icons bool (default off)
icons bool (default false)
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 does not have any effect on Windows.
ignorecase bool (default on)
ignorecase bool (default true)
Ignore case in sorting and search patterns.
ignoredia bool (default on)
ignoredia bool (default true)
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.
incfilter bool (default off)
incfilter bool (default false)
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.
mouse bool (default off)
mouse bool (default false)
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 '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)
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.
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.
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.
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.
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.
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')
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.
smartcase bool (default on)
smartcase bool (default true)
Override 'ignorecase' option when the pattern contains an uppercase character.
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.
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.
tagfmt string (default "\033[31m%s\033[0m")
tagfmt string (default "\033[31m")
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 '')
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.
wrapscan bool (default on)
wrapscan bool (default true)
Searching can wrap around the file list.
wrapscroll bool (default off)
wrapscroll bool (default false)
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
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
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
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
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}
@@ -912,6 +988,10 @@ Value of the user_{option}.
Width/Height of the terminal.
lf_count
Value of the count associated with the current command.
# Special 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:
set hidden # boolean on
set nohidden # boolean off
set hidden # boolean enable
set hidden true # boolean enable
set nohidden # boolean disable
set hidden false # boolean disable
set hidden! # boolean toggle
set scrolloff 10 # integer value
set sortby time # string value w/o quotes
+199 -100
View File
@@ -39,6 +39,7 @@ The following commands are provided by lf:
low (default 'L')
toggle
invert (default 'v')
invert-below
unselect (default 'u')
glob-select
glob-unselect
@@ -81,6 +82,9 @@ The following commands are provided by lf:
mark-remove (modal) (default '"')
tag
tag-toggle (default 't')
maps
cmaps
jumps
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-enter (default '<c-j>' and '<enter>')
cmd-interrupt (default '<c-c>')
cmd-history-next (default '<c-n>')
cmd-history-prev (default '<c-p>')
cmd-history-next (default '<c-n>' and '<down>')
cmd-history-prev (default '<c-p>' and '<up>')
cmd-left (default '<c-b>' and '<left>')
cmd-right (default '<c-f>' and '<right>')
cmd-home (default '<c-a>' and '<home>')
@@ -114,57 +118,62 @@ The following command line commands are provided by lf:
The following options can be used to customize the behavior of lf:
anchorfind bool (default on)
autoquit bool (default off)
cleaner string (default '')
dircache bool (default on)
dircounts bool (default off)
dirfirst bool (default on)
dironly bool (default off)
dirpreviews bool (default off)
drawbox bool (default off)
errorfmt string (default "\033[7;31;47m%s\033[0m")
filesep string (default "\n")
findlen int (default 1)
globsearch bool (default off)
hidden bool (default off)
hiddenfiles []string (default '.*')
history bool (default on)
icons bool (default off)
ifs string (default '')
ignorecase bool (default on)
ignoredia bool (default on)
incfilter bool (default off)
incsearch bool (default off)
info []string (default '')
infotimefmtnew string (default 'Jan _2 15:04')
infotimefmtold string (default 'Jan _2 2006')
mouse bool (default off)
number bool (default off)
period int (default 0)
preview bool (default on)
previewer string (default '')
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')
relativenumber bool (default off)
reverse bool (default off)
scrolloff int (default 0)
selmode string (default 'all')
shell string (default 'sh' for Unix and 'cmd' for Windows)
shellflag string (default '-c' for Unix and '/c' for Windows)
shellopts []string (default '')
smartcase bool (default on)
smartdia bool (default off)
sortby string (default 'natural')
tabstop int (default 8)
tagfmt string (default "\033[31m%s\033[0m")
tempmarks string (default '')
timefmt string (default 'Mon Jan _2 15:04:05 2006')
truncatechar string (default '~')
waitmsg string (default 'Press any key to continue')
wrapscan bool (default on)
wrapscroll bool (default off)
user_{option} string (default none)
anchorfind bool (default true)
autoquit bool (default false)
cleaner string (default '')
cursoractivefmt string (default "\033[7m")
cursorparentfmt string (default "\033[7m")
cursorpreviewfmt string (default "\033[4m")
dircache bool (default true)
dircounts bool (default false)
dirfirst bool (default true)
dironly bool (default false)
dirpreviews bool (default false)
drawbox bool (default false)
errorfmt string (default "\033[7;31;47m")
filesep string (default "\n")
findlen int (default 1)
globsearch bool (default false)
hidden bool (default false)
hiddenfiles []string (default '.*')
history bool (default true)
icons bool (default false)
ifs string (default '')
ignorecase bool (default true)
ignoredia bool (default true)
incfilter bool (default false)
incsearch bool (default false)
info []string (default '')
infotimefmtnew string (default 'Jan _2 15:04')
infotimefmtold string (default 'Jan _2 2006')
mouse bool (default false)
number bool (default false)
numberfmt string (default "\033[33m")
period int (default 0)
preview bool (default true)
previewer string (default '')
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')
relativenumber bool (default false)
reverse bool (default false)
ruler []string (default 'acc:progress:selection:filter:ind')
scrolloff int (default 0)
selmode string (default 'all')
shell string (default 'sh' for Unix and 'cmd' for Windows)
shellflag string (default '-c' for Unix and '/c' for Windows)
shellopts []string (default '')
smartcase bool (default true)
smartdia bool (default false)
sortby string (default 'natural')
tabstop int (default 8)
tagfmt string (default "\033[31m")
tempmarks string (default '')
timefmt string (default 'Mon Jan _2 15:04:05 2006')
truncatechar string (default '~')
waitmsg string (default 'Press any key to continue')
wrapscan bool (default true)
wrapscroll bool (default false)
user_{option} string (default none)
The following environment variables are exported for shell commands:
@@ -176,13 +185,16 @@ The following environment variables are exported for shell commands:
OLDPWD
LF_LEVEL
OPENER
VISUAL
EDITOR
PAGER
SHELL
lf
lf_{option}
lf_user_{option}
lf_width
lf_height
lf_count
The following special shell commands are used to customize the behavior of lf
when defined:
@@ -231,7 +243,7 @@ effects:
Enter a directory or open a file. Also works on the preview window.
Scroll wheel
Scroll up or down.
Move up or down. If Ctrl is pressed, scroll up or down.
# Configuration
@@ -325,7 +337,9 @@ Change the current working directory to the next/previous jumplist item.
top (default 'gg' and '<home>')
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')
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
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')
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.
cmd-history-next (default '<c-n>')
cmd-history-prev (default '<c-p>')
cmd-history-next (default '<c-n>' and '<down>')
cmd-history-prev (default '<c-p>' and '<up>')
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.
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
This section shows information about options to customize the behavior.
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.
autoquit bool (default off)
autoquit bool (default false)
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
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.
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
@@ -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+'.
dirfirst bool (default on)
dirfirst bool (default true)
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
custom previews for directories.
dirpreviews bool (default off)
Show only directories.
drawbox bool (default off)
drawbox bool (default false)
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.
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")
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,
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. 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.
hidden bool (default off)
hidden bool (default false)
Show hidden files. On Unix systems, hidden files are determined by the value
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
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
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.
icons bool (default off)
icons bool (default false)
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
Windows.
ignorecase bool (default on)
ignorecase bool (default true)
Ignore case in sorting and search patterns.
ignoredia bool (default on)
ignoredia bool (default true)
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.
incfilter bool (default off)
incfilter bool (default false)
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
this year.
mouse bool (default off)
mouse bool (default false)
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
'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)
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
zero.
preview bool (default on)
preview bool (default true)
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
@@ -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
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,
current line shows the absolute position, otherwise nothing is shown.
reverse bool (default off)
reverse bool (default false)
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')
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.
smartcase bool (default on)
smartcase bool (default true)
Override 'ignorecase' option when the pattern contains an uppercase character.
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. 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.
tagfmt string (default "\033[31m%s\033[0m")
tagfmt string (default "\033[31m")
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 '')
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.
wrapscan bool (default on)
wrapscan bool (default true)
Searching can wrap around the file list.
wrapscroll bool (default off)
wrapscroll bool (default false)
Scrolling can wrap around the file list.
@@ -937,23 +1024,29 @@ $LF_LEVEL) "' in your shell configuration file (e.g. '~/.bashrc').
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
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
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
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}
@@ -968,6 +1061,10 @@ Value of the user_{option}.
Width/Height of the terminal.
lf_count
Value of the count associated with the current command.
# Special 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:
set hidden # boolean on
set nohidden # boolean off
set hidden # boolean enable
set hidden true # boolean enable
set nohidden # boolean disable
set hidden false # boolean disable
set hidden! # boolean toggle
set scrolloff 10 # integer value
set sortby time # string value w/o quotes
+1 -1
View File
@@ -148,7 +148,7 @@ fi  # FILE
*.tsx 
*.jl 
*.pp 
*.vue ﵂
*.vue
*.elm 
*.swift 
*.xcplayground 
+3 -2
View File
@@ -5,7 +5,7 @@
# mkdir -p ~/.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'
#
@@ -13,7 +13,8 @@
function lfcd
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"
set dir (cat $tmp)
rm -f $tmp
+3 -2
View File
@@ -8,7 +8,7 @@
# source "$LFCD"
# 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
# bindkey -s '^o' 'lfcd\n' # zsh
@@ -16,7 +16,8 @@
lfcd () {
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
dir="$(cat "$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
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
map <enter> shell
# show the result of execution of previous commands
map ` !true
# execute current file (must be executable)
map x $$f
map X !$f
@@ -42,6 +48,9 @@ cmd open &{{
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
# cmd rename %[ -e $1 ] && printf "file exists" || mv $f $1
# map r push :rename<space>
+700 -248
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
go 1.12
go 1.18
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/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/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.5.4-0.20221019011350-d3cbfcfb7aa3/go.mod h1:XmCynGHvvGG7UFI6az9zzoEHBvZB1PGf5APwOJMFUyE=
github.com/gdamore/tcell/v2 v2.6.0 h1:OKbluoP9VYmJwZwq/iLb4BxwKcwGthaa1YNBJIyCySg=
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/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/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.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=
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=
@@ -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-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-20220722155257-8c9f86f7a55f h1:v4INt8xihDGvnrfjMDVXGxw9wrfxYyCjk0KbXjhR55s=
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-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.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.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.4.0 h1:BrVqGRd7+k1DiOgtnFvAkoQEWQvBc25ouMJM6429SFg=
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo=
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-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/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=
+176 -97
View File
@@ -51,6 +51,7 @@ The following commands are provided by lf:
low (default 'L')
toggle
invert (default 'v')
invert-below
unselect (default 'u')
glob-select
glob-unselect
@@ -93,6 +94,9 @@ The following commands are provided by lf:
mark-remove (modal) (default '"')
tag
tag-toggle (default 't')
maps
cmaps
jumps
.EE
.PP
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-enter (default '<c-j>' and '<enter>')
cmd-interrupt (default '<c-c>')
cmd-history-next (default '<c-n>')
cmd-history-prev (default '<c-p>')
cmd-history-next (default '<c-n>' and '<down>')
cmd-history-prev (default '<c-p>' and '<up>')
cmd-left (default '<c-b>' and '<left>')
cmd-right (default '<c-f>' and '<right>')
cmd-home (default '<c-a>' and '<home>')
@@ -130,57 +134,62 @@ The following command line commands are provided by lf:
The following options can be used to customize the behavior of lf:
.PP
.EX
anchorfind bool (default on)
autoquit bool (default off)
cleaner string (default '')
dircache bool (default on)
dircounts bool (default off)
dirfirst bool (default on)
dironly bool (default off)
dirpreviews bool (default off)
drawbox bool (default off)
errorfmt string (default "\e033[7;31;47m%s\e033[0m")
filesep string (default "\en")
findlen int (default 1)
globsearch bool (default off)
hidden bool (default off)
hiddenfiles []string (default '.*')
history bool (default on)
icons bool (default off)
ifs string (default '')
ignorecase bool (default on)
ignoredia bool (default on)
incfilter bool (default off)
incsearch bool (default off)
info []string (default '')
infotimefmtnew string (default 'Jan _2 15:04')
infotimefmtold string (default 'Jan _2 2006')
mouse bool (default off)
number bool (default off)
period int (default 0)
preview bool (default on)
previewer string (default '')
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')
relativenumber bool (default off)
reverse bool (default off)
scrolloff int (default 0)
selmode string (default 'all')
shell string (default 'sh' for Unix and 'cmd' for Windows)
shellflag string (default '-c' for Unix and '/c' for Windows)
shellopts []string (default '')
smartcase bool (default on)
smartdia bool (default off)
sortby string (default 'natural')
tabstop int (default 8)
tagfmt string (default "\e033[31m%s\e033[0m")
tempmarks string (default '')
timefmt string (default 'Mon Jan _2 15:04:05 2006')
truncatechar string (default '~')
waitmsg string (default 'Press any key to continue')
wrapscan bool (default on)
wrapscroll bool (default off)
user_{option} string (default none)
anchorfind bool (default true)
autoquit bool (default false)
cleaner string (default '')
cursoractivefmt string (default "\e033[7m")
cursorparentfmt string (default "\e033[7m")
cursorpreviewfmt string (default "\e033[4m")
dircache bool (default true)
dircounts bool (default false)
dirfirst bool (default true)
dironly bool (default false)
dirpreviews bool (default false)
drawbox bool (default false)
errorfmt string (default "\e033[7;31;47m")
filesep string (default "\en")
findlen int (default 1)
globsearch bool (default false)
hidden bool (default false)
hiddenfiles []string (default '.*')
history bool (default true)
icons bool (default false)
ifs string (default '')
ignorecase bool (default true)
ignoredia bool (default true)
incfilter bool (default false)
incsearch bool (default false)
info []string (default '')
infotimefmtnew string (default 'Jan _2 15:04')
infotimefmtold string (default 'Jan _2 2006')
mouse bool (default false)
number bool (default false)
numberfmt string (default "\e033[33m")
period int (default 0)
preview bool (default true)
previewer string (default '')
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')
relativenumber bool (default false)
reverse bool (default false)
ruler []string (default 'acc:progress:selection:filter:ind')
scrolloff int (default 0)
selmode string (default 'all')
shell string (default 'sh' for Unix and 'cmd' for Windows)
shellflag string (default '-c' for Unix and '/c' for Windows)
shellopts []string (default '')
smartcase bool (default true)
smartdia bool (default false)
sortby string (default 'natural')
tabstop int (default 8)
tagfmt string (default "\e033[31m")
tempmarks string (default '')
timefmt string (default 'Mon Jan _2 15:04:05 2006')
truncatechar string (default '~')
waitmsg string (default 'Press any key to continue')
wrapscan bool (default true)
wrapscroll bool (default false)
user_{option} string (default none)
.EE
.PP
The following environment variables are exported for shell commands:
@@ -194,13 +203,16 @@ The following environment variables are exported for shell commands:
OLDPWD
LF_LEVEL
OPENER
VISUAL
EDITOR
PAGER
SHELL
lf
lf_{option}
lf_user_{option}
lf_width
lf_height
lf_count
.EE
.PP
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
.EX
Scroll wheel
Scroll up or down.
Move up or down. If Ctrl is pressed, scroll up or down.
.EE
.SH CONFIGURATION
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>')
.EE
.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
.EX
high (default 'H')
@@ -392,6 +404,16 @@ Toggle the selection of the current file or files given as arguments.
.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.
.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
unselect (default 'u')
.EE
@@ -648,8 +670,8 @@ Execute the current line.
Interrupt the current shell-pipe command and return to the normal mode.
.PP
.EX
cmd-history-next (default '<c-n>')
cmd-history-prev (default '<c-p>')
cmd-history-next (default '<c-n>' and '<down>')
cmd-history-prev (default '<c-p>' and '<up>')
.EE
.PP
Go to next/previous item in the history.
@@ -726,17 +748,30 @@ Delete the next word in forward direction.
.EE
.PP
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
This section shows information about options to customize the behavior. Character ':' is used as the separator for list options '[]int' and '[]string'.
.PP
.EX
anchorfind bool (default on)
anchorfind bool (default true)
.EE
.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.
.PP
.EX
autoquit bool (default off)
autoquit bool (default false)
.EE
.PP
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.
.PP
.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
.PP
Cache directory contents.
.PP
.EX
dircounts bool (default off)
dircounts bool (default false)
.EE
.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+'.
.PP
.EX
dirfirst bool (default on)
dirfirst bool (default true)
.EE
.PP
Show directories first above regular files.
.PP
.EX
dironly bool (default off)
.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)
dironly bool (default false)
.EE
.PP
Show only directories.
.PP
.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
.PP
Draw boxes around panes with box drawing characters.
.PP
.EX
errorfmt string (default "\e033[7;31;47m%s\e033[0m")
errorfmt string (default "\e033[7;31;47m")
.EE
.PP
Format string of error messages shown in the bottom message line.
.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
filesep string (default "\en")
.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.
.PP
.EX
globsearch bool (default off)
globsearch bool (default false)
.EE
.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
.EX
hidden bool (default off)
hidden bool (default false)
.EE
.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.
@@ -817,16 +868,16 @@ Show hidden files. On Unix systems, hidden files are determined by the value of
hiddenfiles []string (default '.*')
.EE
.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
.EX
history bool (default on)
history bool (default true)
.EE
.PP
Save command history.
.PP
.EX
icons bool (default off)
icons bool (default false)
.EE
.PP
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.
.PP
.EX
ignorecase bool (default on)
ignorecase bool (default true)
.EE
.PP
Ignore case in sorting and search patterns.
.PP
.EX
ignoredia bool (default on)
ignoredia bool (default true)
.EE
.PP
Ignore diacritics in sorting and search patterns.
.PP
.EX
incsearch bool (default off)
incsearch bool (default false)
.EE
.PP
Jump to the first match after each keystroke during searching.
.PP
.EX
incfilter bool (default off)
incfilter bool (default false)
.EE
.PP
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.
.PP
.EX
mouse bool (default off)
mouse bool (default false)
.EE
.PP
Send mouse events as input.
.PP
.EX
number bool (default off)
number bool (default false)
.EE
.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.
.PP
.EX
numberfmt string (default "\e033[33m")
.EE
.PP
Format string of the position number for each line.
.PP
.EX
period int (default 0)
.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.
.PP
.EX
preview bool (default on)
preview bool (default true)
.EE
.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'.
@@ -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.
.PP
.EX
relativenumber bool (default off)
relativenumber bool (default false)
.EE
.PP
Show the position number relative to the current line. When 'number' is enabled, current line shows the absolute position, otherwise nothing is shown.
.PP
.EX
reverse bool (default off)
reverse bool (default false)
.EE
.PP
Reverse the direction of sort.
.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
selmode string (default 'all')
.EE
@@ -964,13 +1027,13 @@ Command line flag used to pass shell commands.
List of shell options to pass to the shell executable.
.PP
.EX
smartcase bool (default on)
smartcase bool (default true)
.EE
.PP
Override 'ignorecase' option when the pattern contains an uppercase character. This option has no effect when 'ignorecase' is disabled.
.PP
.EX
smartdia bool (default off)
smartdia bool (default false)
.EE
.PP
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.
.PP
.EX
tagfmt string (default "\e033[31m%s\e033[0m")
tagfmt string (default "\e033[31m")
.EE
.PP
Format string of the tags.
.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
tempmarks string (default '')
.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.
.PP
.EX
wrapscan bool (default on)
wrapscan bool (default true)
.EE
.PP
Searching can wrap around the file list.
.PP
.EX
wrapscroll bool (default off)
wrapscroll bool (default false)
.EE
.PP
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
.EE
.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
.EX
EDITOR
.EE
.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
.EX
PAGER
.EE
.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
.EX
SHELL
.EE
.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
.EX
lf_{option}
@@ -1121,6 +1192,12 @@ Value of the user_{option}.
.EE
.PP
Width/Height of the terminal.
.PP
.EX
lf_count
.EE
.PP
Value of the count associated with the current command.
.SH SPECIAL COMMANDS
This section shows information about special shell commands.
.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:
.PP
.EX
set hidden # boolean on
set nohidden # boolean off
set hidden # boolean enable
set hidden true # boolean enable
set nohidden # boolean disable
set hidden false # boolean disable
set hidden! # boolean toggle
set scrolloff 10 # integer value
set sortby time # string value w/o quotes
+13 -7
View File
@@ -79,6 +79,13 @@ func exportEnvVars() {
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
@@ -109,12 +116,12 @@ func fieldToString(field reflect.Value) string {
}
func exportOpts() {
e := reflect.ValueOf(&gOpts).Elem()
v := reflect.ValueOf(gOpts)
t := v.Type()
for i := 0; i < e.NumField(); i++ {
// Get name and prefix it with lf_
name := e.Type().Field(i).Name
name = fmt.Sprintf("lf_%s", name)
for i := 0; i < v.NumField(); i++ {
// Get field name and prefix it with lf_
name := "lf_" + t.Field(i).Name
// Skip maps
if name == "lf_keys" || name == "lf_cmdkeys" || name == "lf_cmds" {
@@ -158,9 +165,8 @@ func exportOpts() {
os.Setenv(name+"_"+key, value)
}
} else {
field := e.Field(i)
field := v.Field(i)
value := fieldToString(field)
os.Setenv(name, value)
}
}
+64 -14
View File
@@ -388,11 +388,15 @@ type nav struct {
searchPos int
prevFilter []string
volatilePreview bool
previewTimer *time.Timer
previewLoading bool
jumpList []string
jumpListInd int
}
func (nav *nav) loadDirInternal(path string) *dir {
nav.startPreview()
d := &dir{
loading: true,
loadTime: time.Now(),
@@ -448,6 +452,7 @@ func (nav *nav) checkDir(dir *dir) {
return
}
nav.startPreview()
dir.loading = true
dir.loadTime = now
go func() {
@@ -465,10 +470,11 @@ func (nav *nav) checkDir(dir *dir) {
dir.ignorecase != gOpts.ignorecase ||
dir.ignoredia != gOpts.ignoredia:
dir.loading = true
sd := *dir
go func() {
dir.sort()
dir.loading = false
nav.dirChan <- dir
sd.sort()
sd.loading = false
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) {
dir := nav.loadDir(curr)
dir.sel(base, nav.height)
if base != "" {
dir.sel(base, nav.height)
}
dirs = append(dirs, dir)
}
@@ -511,6 +519,7 @@ func newNav(height int) *nav {
tags: make(map[string]string),
selectionInd: 0,
height: height,
previewTimer: time.NewTimer(0),
jumpList: make([]string, 0),
jumpListInd: -1,
}
@@ -534,7 +543,6 @@ func (nav *nav) addJumpList() {
}
func (nav *nav) cdJumpListPrev() {
// currPath := nav.currDir().path
if nav.jumpListInd > 0 {
nav.jumpListInd -= 1
nav.cd(nav.jumpList[nav.jumpListInd])
@@ -814,6 +822,7 @@ func (nav *nav) loadReg(path string, volatile bool) *reg {
if !ok || (volatile && r.volatile) {
r := &reg{loading: true, loadTime: time.Now(), path: path, volatile: true}
nav.regCache[path] = r
nav.startPreview()
nav.previewChan <- path
return r
}
@@ -839,10 +848,17 @@ func (nav *nav) checkReg(reg *reg) {
if s.ModTime().After(reg.loadTime) {
reg.loadTime = now
nav.startPreview()
nav.previewChan <- reg.path
}
}
func (nav *nav) startPreview() {
nav.previewTimer.Stop()
nav.previewLoading = false
nav.previewTimer.Reset(100 * time.Millisecond)
}
func (nav *nav) sort() {
for _, d := range nav.dirs {
name := d.name()
@@ -912,11 +928,13 @@ func (nav *nav) down(dist int) bool {
dir.ind = min(maxind, dir.ind)
dir.pos += dist
edge := min(min(nav.height/2, gOpts.scrolloff), maxind-dir.ind)
// use a smaller value when the height is even and scrolloff is maxed
// in order to stay at the same row as much as possible while up/down
edge = min(edge, nav.height/2+nav.height%2-1)
// 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
half := nav.height / 2
if nav.height%2 == 0 {
half--
}
edge := min(min(half, gOpts.scrolloff), maxind-dir.ind)
dir.pos = min(dir.pos, nav.height-edge-1)
dir.pos = min(dir.pos, maxind)
@@ -1086,6 +1104,19 @@ func (nav *nav) low() bool {
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) {
if _, ok := nav.selections[path]; ok {
delete(nav.selections, path)
@@ -1149,14 +1180,22 @@ func (nav *nav) tag(tag string) error {
return nil
}
func (nav *nav) invert() {
func (nav *nav) invertAfter(ix int) {
dir := nav.currDir()
for _, f := range dir.files {
for _, f := range dir.files[ix:] {
path := filepath.Join(dir.path, f.Name())
nav.toggleSelection(path)
}
}
func (nav *nav) invert() {
nav.invertAfter(0)
}
func (nav *nav) invertBelow() {
nav.invertAfter(nav.currDir().ind)
}
func (nav *nav) unselect() {
nav.selections = make(map[string]int)
nav.selectionInd = 0
@@ -1426,6 +1465,12 @@ func (nav *nav) rename() error {
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))
if dir.loading {
@@ -1497,13 +1542,18 @@ func (nav *nav) sel(path string) error {
base := filepath.Base(path)
last := nav.dirs[len(nav.dirs)-1]
last := nav.currDir()
if last.loading {
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
}
+67 -53
View File
@@ -28,57 +28,62 @@ type sortType struct {
}
var gOpts struct {
anchorfind bool
autoquit bool
dircache bool
dircounts bool
dironly bool
dirpreviews bool
drawbox bool
globsearch bool
icons bool
ignorecase bool
ignoredia bool
incfilter bool
incsearch bool
mouse bool
number bool
preview bool
relativenumber bool
smartcase bool
smartdia bool
waitmsg string
wrapscan bool
wrapscroll bool
findlen int
period int
scrolloff int
tabstop int
errorfmt string
filesep string
ifs string
previewer string
cleaner string
promptfmt string
selmode string
shell string
shellflag string
timefmt string
infotimefmtnew string
infotimefmtold string
truncatechar string
ratios []int
hiddenfiles []string
history bool
info []string
shellopts []string
keys map[string]expr
cmdkeys map[string]expr
cmds map[string]expr
user map[string]string
sortType sortType
tempmarks string
tagfmt string
anchorfind bool
autoquit bool
cursoractivefmt string
cursorparentfmt string
cursorpreviewfmt string
dircache bool
dircounts bool
dironly bool
dirpreviews bool
drawbox bool
globsearch bool
icons bool
ignorecase bool
ignoredia bool
incfilter bool
incsearch bool
mouse bool
number bool
preview bool
relativenumber bool
smartcase bool
smartdia bool
waitmsg string
wrapscan bool
wrapscroll bool
findlen int
period int
scrolloff int
tabstop int
errorfmt string
filesep string
ifs string
previewer string
cleaner string
promptfmt string
selmode string
shell string
shellflag string
timefmt string
infotimefmtnew string
infotimefmtold string
truncatechar string
ratios []int
hiddenfiles []string
history bool
info []string
ruler []string
shellopts []string
keys map[string]expr
cmdkeys map[string]expr
cmds map[string]expr
user map[string]string
sortType sortType
tempmarks string
numberfmt string
tagfmt string
}
func init() {
@@ -89,6 +94,9 @@ func init() {
gOpts.dironly = false
gOpts.dirpreviews = false
gOpts.drawbox = false
gOpts.cursoractivefmt = "\033[7m"
gOpts.cursorparentfmt = "\033[7m"
gOpts.cursorpreviewfmt = "\033[4m"
gOpts.globsearch = false
gOpts.icons = false
gOpts.ignorecase = true
@@ -108,7 +116,7 @@ func init() {
gOpts.period = 0
gOpts.scrolloff = 0
gOpts.tabstop = 8
gOpts.errorfmt = "\033[7;31;47m%s\033[0m"
gOpts.errorfmt = "\033[7;31;47m"
gOpts.filesep = "\n"
gOpts.ifs = ""
gOpts.previewer = ""
@@ -125,10 +133,12 @@ func init() {
gOpts.hiddenfiles = []string{".*"}
gOpts.history = true
gOpts.info = nil
gOpts.ruler = []string{"acc", "progress", "selection", "filter", "ind"}
gOpts.shellopts = nil
gOpts.sortType = sortType{naturalSort, dirfirstSort}
gOpts.tempmarks = "'"
gOpts.tagfmt = "\033[31m%s\033[0m"
gOpts.numberfmt = "\033[33m"
gOpts.tagfmt = "\033[31m"
gOpts.keys = make(map[string]expr)
@@ -139,6 +149,7 @@ func init() {
gOpts.keys["<c-b>"] = &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-m-up>"] = &callExpr{"scroll-up", nil, 1}
gOpts.keys["j"] = &callExpr{"down", nil, 1}
gOpts.keys["<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["<pgdn>"] = &callExpr{"page-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["<left>"] = &callExpr{"updir", 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["<enter>"] = &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["<up>"] = &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["<c-d>"] = &callExpr{"cmd-delete", nil, 1}
+6 -3
View File
@@ -18,7 +18,7 @@ import (
var (
envOpener = os.Getenv("OPENER")
envEditor = os.Getenv("EDITOR")
envEditor = os.Getenv("VISUAL")
envPager = os.Getenv("PAGER")
envShell = os.Getenv("SHELL")
)
@@ -51,7 +51,10 @@ func init() {
}
if envEditor == "" {
envEditor = "vi"
envEditor = os.Getenv("EDITOR")
if envEditor == "" {
envEditor = "vi"
}
}
if envPager == "" {
@@ -159,7 +162,7 @@ func setDefaults() {
gOpts.keys["i"] = &execExpr{"$", `$PAGER "$f"`}
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}
}
+6 -3
View File
@@ -14,7 +14,7 @@ import (
var (
envOpener = os.Getenv("OPENER")
envEditor = os.Getenv("EDITOR")
envEditor = os.Getenv("VISUAL")
envPager = os.Getenv("PAGER")
envShell = os.Getenv("SHELL")
)
@@ -45,7 +45,10 @@ func init() {
}
if envEditor == "" {
envEditor = "notepad"
envEditor = os.Getenv("EDITOR")
if envEditor == "" {
envEditor = "notepad"
}
}
if envPager == "" {
@@ -115,7 +118,7 @@ func setDefaults() {
gOpts.keys["i"] = &execExpr{"!", "%PAGER% %f%"}
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}
}
+1 -2
View File
@@ -2,7 +2,6 @@ package main
import (
"io"
"io/ioutil"
"log"
"strconv"
)
@@ -38,7 +37,7 @@ type scanner struct {
}
func newScanner(r io.Reader) *scanner {
buf, err := ioutil.ReadAll(r)
buf, err := io.ReadAll(r)
if err != nil {
log.Printf("scanning: %s", err)
}
+169 -96
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)
}
func (win *win) printReg(screen tcell.Screen, reg *reg) {
func (win *win) printReg(screen tcell.Screen, reg *reg, previewLoading bool) {
if reg == nil {
return
}
@@ -260,8 +260,10 @@ func (win *win) printReg(screen tcell.Screen, reg *reg) {
st := tcell.StyleDefault
if reg.loading {
st = st.Reverse(true)
win.print(screen, 2, 0, st, "loading...")
if previewLoading {
st = st.Reverse(true)
win.print(screen, 2, 0, st, "loading...")
}
return
}
@@ -330,19 +332,26 @@ type dirContext struct {
tags map[string]string
}
type dirRole byte
const (
Active dirRole = iota
Parent
Preview
)
type dirStyle struct {
colors styleMap
icons iconMap
previewing bool
colors styleMap
icons iconMap
role dirRole
}
// These colors are not currently customizeable
const LineNumberColor = tcell.ColorOlive
const SelectionColor = tcell.ColorPurple
const YankColor = tcell.ColorOlive
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 {
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")
return
}
if (dir.loading && len(dir.files) == 0) || (dirStyle.previewing && dir.loading && gOpts.dirpreviews) {
win.print(screen, 2, 0, messageStyle, "loading...")
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...")
}
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.
st := tcell.StyleDefault
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 lnformat string
if gOpts.number || gOpts.relativenumber {
lnwidth = 1
if gOpts.number && gOpts.relativenumber {
lnwidth++
}
for j := 10; j < len(dir.files); j *= 10 {
for j := 10; j <= len(dir.files); j *= 10 {
lnwidth++
}
lnformat = fmt.Sprintf("%%%d.d ", lnwidth)
}
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
if gOpts.number && (!gOpts.relativenumber) {
ln = fmt.Sprintf(lnformat, i+1+beg)
ln = fmt.Sprintf("%*d", lnwidth, i+1+beg)
} else if gOpts.relativenumber {
switch {
case i < dir.pos:
ln = fmt.Sprintf(lnformat, dir.pos-i)
ln = fmt.Sprintf("%*d", lnwidth, dir.pos-i)
case i > dir.pos:
ln = fmt.Sprintf(lnformat, i-dir.pos)
ln = fmt.Sprintf("%*d", lnwidth, i-dir.pos)
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:
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())
@@ -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
s = append(s, ' ')
var iwidth int
if gOpts.icons {
s = append(s, []rune(dirStyle.icons.get(f))...)
s = append(s, ' ')
iwidth = 2
}
for _, r := range f.Name() {
@@ -454,39 +456,59 @@ func (win *win) printDir(screen tcell.Screen, dir *dir, context *dirContext, dir
w := runeSliceWidth(s)
if w > win.w-3 {
s = runeSliceWidthRange(s, 0, win.w-4)
// make space for select marker, and leave another space at the end
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)...)
} else {
for i := 0; i < win.w-3-w; i++ {
for i := 0; i < maxlength-w; i++ {
s = append(s, ' ')
}
}
info := fileInfo(f, dir)
if len(info) > 0 && win.w-lnwidth-iwidth-2 > 2*len(info) {
if win.w-2 > w+len(info) {
s = runeSliceWidthRange(s, 0, win.w-3-len(info)-lnwidth)
} else {
s = runeSliceWidthRange(s, 0, win.w-4-len(info)-lnwidth)
if len(info) > 0 && 2*len(info) < maxlength {
if w+len(info) > maxlength {
s = runeSliceWidthRange(s, 0, maxlength-len(info)-1)
s = append(s, []rune(gOpts.truncatechar)...)
} else {
s = runeSliceWidthRange(s, 0, maxlength-len(info))
}
for _, r := range info {
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]
if ok {
if i == dir.pos {
win.print(screen, lnwidth+1, i, st, tag)
win.print(screen, lnwidth+1, i, st, fmt.Sprintf(cursorescapefmt, tag))
} 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)
widths := make([]int, wlen)
if gOpts.drawbox {
wtot -= (wlen + 1)
}
wsum := 0
for i := 0; i < wlen-1; i++ {
widths[i] = gOpts.ratios[i] * wtot / rsum
@@ -508,10 +534,6 @@ func getWidths(wtot int) []int {
}
widths[wlen-1] = wtot - wsum
if gOpts.drawbox {
widths[wlen-1]--
}
return widths
}
@@ -526,7 +548,8 @@ func getWins(screen tcell.Screen) []*win {
wlen := len(widths)
for i := 0; i < wlen; i++ {
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 {
wins = append(wins, newWin(widths[i], htot-2, wacc, 1))
}
@@ -610,21 +633,9 @@ func (ui *ui) pollEvents() {
}
func (ui *ui) renew() {
ui.wins = getWins(ui.screen)
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.msgWin.renew(wtot, 1, 0, htot-1)
ui.menuWin.renew(wtot, 1, 0, htot-2)
@@ -652,8 +663,16 @@ func (ui *ui) echomsg(msg string) {
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) {
ui.msg = fmt.Sprintf(gOpts.errorfmt, msg)
ui.msg = fmt.Sprintf(optionToFmtstr(gOpts.errorfmt), msg)
log.Printf("error: %s", msg)
}
@@ -679,11 +698,10 @@ func (ui *ui) loadFile(app *app, volatile bool) {
return
}
if curr.path == ui.currentFile {
return
if curr.path != ui.currentFile {
ui.currentFile = curr.path
onSelect(app)
}
ui.currentFile = curr.path
onSelect(app)
if !gOpts.preview {
return
@@ -797,7 +815,7 @@ func (ui *ui) drawStatLine(nav *nav) {
ind := min(dir.ind+1, tot)
acc := string(ui.keyCount) + string(ui.keyAcc)
var selection string
selection := []string{}
if len(nav.saves) > 0 {
copy := 0
@@ -810,40 +828,58 @@ func (ui *ui) drawStatLine(nav *nav) {
}
}
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 {
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()
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 {
selection += " \033[34;7m F \033[0m"
}
var progress string
progress := []string{}
if nav.copyTotal > 0 {
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 {
progress += fmt.Sprintf(" [%d/%d]", nav.moveCount, nav.moveTotal)
progress = append(progress, fmt.Sprintf("[%d/%d]", nav.moveCount, nav.moveTotal))
}
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() {
@@ -852,28 +888,28 @@ func (ui *ui) drawBox() {
w, h := ui.screen.Size()
for i := 1; i < w-1; i++ {
ui.screen.SetContent(i, 1, '─', nil, st)
ui.screen.SetContent(i, h-2, '─', nil, st)
ui.screen.SetContent(i, 1, tcell.RuneHLine, nil, st)
ui.screen.SetContent(i, h-2, tcell.RuneHLine, nil, st)
}
for i := 2; i < h-2; i++ {
ui.screen.SetContent(0, i, '│', nil, st)
ui.screen.SetContent(w-1, i, '│', nil, st)
ui.screen.SetContent(0, i, tcell.RuneVLine, nil, st)
ui.screen.SetContent(w-1, i, tcell.RuneVLine, nil, st)
}
ui.screen.SetContent(0, 1, '┌', nil, st)
ui.screen.SetContent(w-1, 1, '┐', nil, st)
ui.screen.SetContent(0, h-2, '└', nil, st)
ui.screen.SetContent(w-1, h-2, '┘', nil, st)
ui.screen.SetContent(0, 1, tcell.RuneULCorner, nil, st)
ui.screen.SetContent(w-1, 1, tcell.RuneURCorner, nil, st)
ui.screen.SetContent(0, h-2, tcell.RuneLLCorner, nil, st)
ui.screen.SetContent(w-1, h-2, tcell.RuneLRCorner, nil, st)
wacc := 0
for wind := 0; wind < len(ui.wins)-1; wind++ {
wacc += ui.wins[wind].w
ui.screen.SetContent(wacc, 1, '┬', nil, st)
wacc += ui.wins[wind].w + 1
ui.screen.SetContent(wacc, 1, tcell.RuneTTee, nil, st)
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
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()
for i := 0; i < wtot; i++ {
for j := 0; j < htot; j++ {
@@ -907,9 +944,14 @@ func (ui *ui) draw(nav *nav) {
wins--
}
for i := 0; i < wins; i++ {
role := Parent
if i == wins-1 {
role = Active
}
if dir := ui.dirOfWin(nav, i); dir != nil {
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() {
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() {
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
}
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 {
t := new(tabwriter.Writer)
b := new(bytes.Buffer)
@@ -1182,12 +1249,18 @@ func (ui *ui) readNormalEvent(ev tcell.Event, nav *nav) expr {
case tcell.ButtonNone:
return nil
}
if tev.Modifiers() == tcell.ModCtrl {
button = "<c-" + button[1:]
}
if expr, ok := gOpts.keys[button]; ok {
return expr
}
if tev.Buttons() != tcell.Button1 && tev.Buttons() != tcell.Button2 {
return nil
if button != "<m-1>" && button != "<m-2>" {
ui.echoerrf("unknown mapping: %s", button)
ui.keyAcc = nil
ui.keyCount = nil
ui.menuBuf = nil
return draw
}
x, y := tev.Position()
@@ -1331,7 +1404,7 @@ func listMatches(screen tcell.Screen, matches []string, selectedInd int) *bytes.
wcol = max(wcol, len(m))
}
wcol += gOpts.tabstop - wcol%gOpts.tabstop
ncol := wtot / wcol
ncol := max(wtot/wcol, 1)
b.WriteString("possible matches\n")