Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
50f11ad3de | ||
|
|
da7a366584 | ||
|
|
5eb5d9bdb8 | ||
|
|
82dfce2e96 | ||
|
|
69fc98f992 | ||
|
|
fe59f0f30c | ||
|
|
4db1a63b75 | ||
|
|
afa90fe647 | ||
|
|
304026d680 | ||
|
|
9144df10ad | ||
|
|
27a11ae507 | ||
|
|
5a5628d667 | ||
|
|
2f9d840eda | ||
|
|
8c71e5ba9f | ||
|
|
e6a1621261 | ||
|
|
97e7a6239f | ||
|
|
1b82f1db0b | ||
|
|
19aad41b8e | ||
|
|
2ddaf43421 | ||
|
|
5927a506f4 | ||
|
|
c712d304f2 | ||
|
|
076ab8ea9d | ||
|
|
12f0f0da68 | ||
|
|
f66e5824a1 | ||
|
|
fb3c31d3c7 | ||
|
|
089e6dc705 | ||
|
|
8954e9f16a | ||
|
|
07b35def77 | ||
|
|
25476e79ef | ||
|
|
fb66a21577 | ||
|
|
b4637f91aa | ||
|
|
7005815671 | ||
|
|
03de10ba69 | ||
|
|
e3c191acec | ||
|
|
f736f44e4e | ||
|
|
c5bd676c3a | ||
|
|
3e3a4a6386 | ||
|
|
17453f10f5 | ||
|
|
375133e483 | ||
|
|
1718527e90 | ||
|
|
b5de2cd666 | ||
|
|
73f990cdb6 | ||
|
|
b08ab8dfb7 | ||
|
|
cbb80a0d44 | ||
|
|
86e84c9151 | ||
|
|
1703dcc11f | ||
|
|
47620fa680 | ||
|
|
5d393da572 | ||
|
|
26455dca09 | ||
|
|
895e22a1b5 | ||
|
|
761aa23483 | ||
|
|
a4842e19d4 | ||
|
|
958857f4c4 | ||
|
|
18fb632efa | ||
|
|
1bb7a17c81 | ||
|
|
94e06201f9 | ||
|
|
930364ce78 | ||
|
|
85c73978fe | ||
|
|
92e8a247b1 | ||
|
|
76338f1a4d | ||
|
|
081d0585cd | ||
|
|
ac4bdccf8d | ||
|
|
286bf75aa9 | ||
|
|
fea4ededb6 | ||
|
|
673dad9f07 | ||
|
|
d879e8f8f8 | ||
|
|
78d4e3a2b4 | ||
|
|
1a264b2f77 | ||
|
|
7872455021 | ||
|
|
1b71c33afd | ||
|
|
f01fab6257 | ||
|
|
85aa3b9dc6 | ||
|
|
5566f82596 | ||
|
|
0edf0823b7 | ||
|
|
05a48ea315 | ||
|
|
ff0933ca03 | ||
|
|
6c46b217af | ||
|
|
bdd1747e43 | ||
|
|
ee5b3f4813 | ||
|
|
75eba115d2 | ||
|
|
8adbd2b9ef | ||
|
|
55b9189713 | ||
|
|
b763c30cc5 | ||
|
|
61489ad00b | ||
|
|
1ff3910c70 | ||
|
|
1966a30deb | ||
|
|
50e3a6856e | ||
|
|
9885c4be7a | ||
|
|
29aa77aa27 | ||
|
|
6e9f53f4bb | ||
|
|
099cccdcb5 | ||
|
|
4220868cc7 |
No files matched your search
@@ -0,0 +1,28 @@
|
|||||||
|
name: Go
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ master ]
|
||||||
|
pull_request:
|
||||||
|
branches: [ master ]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
|
||||||
|
build:
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-latest, windows-latest]
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Set up Go
|
||||||
|
uses: actions/setup-go@v2
|
||||||
|
with:
|
||||||
|
go-version: 1.17
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
run: go build -v ./...
|
||||||
|
|
||||||
|
- name: Test
|
||||||
|
run: go test -v ./...
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
name: Release
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- '*'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Set up Go
|
||||||
|
uses: actions/setup-go@v2
|
||||||
|
with:
|
||||||
|
go-version: 1.17
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
run: gen/xbuild.sh
|
||||||
|
|
||||||
|
- name: Release
|
||||||
|
uses: softprops/action-gh-release@v1
|
||||||
|
with:
|
||||||
|
files: dist/*
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
-19
@@ -1,19 +0,0 @@
|
|||||||
language: go
|
|
||||||
|
|
||||||
go:
|
|
||||||
- 1.15.x
|
|
||||||
|
|
||||||
before_deploy:
|
|
||||||
- gen/xbuild.sh
|
|
||||||
|
|
||||||
deploy:
|
|
||||||
provider: releases
|
|
||||||
api_key:
|
|
||||||
secure: RdZAOPWooYq73iFQIjqe9+Awr7oA8m0j0tn1tUUfLjP+PGYpuz2lf1SHW/UjPcxySFkkBxnNPC1xgqmxekmvZadBaQbApqko4e47zCF0Pe91QG9OcDFaiJUWb7wcg+UDLoS0lJq8mcKYoi6bV76syOk0gBunLUmuYYpz/hR4lbalfq5//fD6sOOJ9cJPjeuG7LwYqbyw/8VwQWpiWgK9Sb5gu7+ZBgXkLG+/5OSHW8yNHGmtkw5sjMr4jQnNt2ixXVe5OdQ14mvRx0n4vlnzjNjmY6cPjEeqAc9eniOJ5o99k1OnR3H5kmNgI749q+VAkdu/uJfHiLXL1zerReb4SSTU+tTw9c7JYTcjBHlCT11CHlksVu55hHAbFvPkIpLfoRvdqrcjUyEHiCI/HbWiHhsQ+Gve+tpIcgu/aAC2TEsQ+vmmaXbOFcUsG77XP8gn1y+Spkyzou7tUvypIXduDSKFIvI51HYK2F5t5ttG6zJw9lpmmuoUWvCvbGvdAW893O6ef+iZvBoZYRjdeWvIqh/no2gWi1CRa4ZPSZWkn9NoE/2koaCQkrx9RHmEeLIukZVAT6ZViwvhMAOrvXQdKTDwbQ3ovMdtDvGcvjGz9k5xwnWrIcF7MV7nf7sj/JlcX2tulevcSLsYeBvcuTUFzy90erMy70MS01wp0I/IgpY=
|
|
||||||
skip_cleanup: true
|
|
||||||
file_glob: true
|
|
||||||
file: dist/*
|
|
||||||
name: $TRAVIS_TAG
|
|
||||||
on:
|
|
||||||
tags: true
|
|
||||||
repo: gokcehan/lf
|
|
||||||
@@ -2,18 +2,15 @@
|
|||||||
|
|
||||||
[Google Groups](https://groups.google.com/forum/#!forum/lf-fm)
|
[Google Groups](https://groups.google.com/forum/#!forum/lf-fm)
|
||||||
| [Wiki](https://github.com/gokcehan/lf/wiki)
|
| [Wiki](https://github.com/gokcehan/lf/wiki)
|
||||||
| [#lf](https://webchat.freenode.net/?channels=lf) (on Freenode)
|
| [#lf](https://web.libera.chat/#lf) (on Libera.Chat)
|
||||||
| [#lf:matrix.org](https://matrix.to/#/#lf:matrix.org) (with IRC bridge)
|
| [#lf:matrix.org](https://matrix.to/#/#lf:matrix.org) (with IRC bridge)
|
||||||
|
|
||||||
[](https://travis-ci.org/gokcehan/lf)
|
|
||||||
[](https://goreportcard.com/report/github.com/gokcehan/lf)
|
[](https://goreportcard.com/report/github.com/gokcehan/lf)
|
||||||
[](https://pkg.go.dev/github.com/gokcehan/lf)
|
[](https://pkg.go.dev/github.com/gokcehan/lf)
|
||||||
|
|
||||||
> This is a work in progress. Use at your own risk.
|
> This is a work in progress. Use at your own risk.
|
||||||
|
|
||||||
`lf` (as in "list files") is a terminal file manager written in Go.
|
`lf` (as in "list files") is a terminal file manager written in Go with a heavy inspiration from ranger file manager.
|
||||||
It is heavily inspired by ranger with some missing and extra features.
|
|
||||||
Some of the missing features are deliberately omitted since they are better handled by external tools.
|
|
||||||
See [faq](https://github.com/gokcehan/lf/wiki/FAQ) for more information and [tutorial](https://github.com/gokcehan/lf/wiki/Tutorial) for a gentle introduction with screencasts.
|
See [faq](https://github.com/gokcehan/lf/wiki/FAQ) for more information and [tutorial](https://github.com/gokcehan/lf/wiki/Tutorial) for a gentle introduction with screencasts.
|
||||||
|
|
||||||

|

|
||||||
@@ -21,18 +18,19 @@ See [faq](https://github.com/gokcehan/lf/wiki/FAQ) for more information and [tut
|
|||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
- Cross-platform (Linux, OSX, BSDs, Windows (partial))
|
- Cross-platform (Linux, MacOS, BSDs, Windows)
|
||||||
- Single binary without any runtime dependencies (except for terminfo database)
|
- Single binary without any runtime dependencies
|
||||||
- Fast startup and low memory footprint (due to native code and static binaries)
|
- Fast startup and low memory footprint due to native code and static binaries
|
||||||
- Server/client architecture to share file selection between multiple instances
|
- Asynchronous IO operations to avoid UI locking
|
||||||
- Configuration with shell commands
|
- Server/client architecture and remote commands to manage multiple instances
|
||||||
|
- Extendable and configurable with shell commands
|
||||||
- Customizable keybindings (vi and readline defaults)
|
- Customizable keybindings (vi and readline defaults)
|
||||||
- Preview filtering (for source highlight, archives, pdfs/images as text etc.)
|
- A reasonable set of other features (see the [documentation](https://pkg.go.dev/github.com/gokcehan/lf))
|
||||||
|
|
||||||
## Non-Features
|
## Non-Features
|
||||||
|
|
||||||
- Tabs or windows (handled by window manager or terminal multiplexer)
|
- Tabs or windows (better handled by window manager or terminal multiplexer)
|
||||||
- Builtin pager/editor (handled by your pager/editor of choice)
|
- Builtin pager/editor (better handled by your pager/editor of choice)
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
@@ -40,21 +38,49 @@ See [packages](https://github.com/gokcehan/lf/wiki/Packages) for community maint
|
|||||||
|
|
||||||
See [releases](https://github.com/gokcehan/lf/releases) for pre-built binaries.
|
See [releases](https://github.com/gokcehan/lf/releases) for pre-built binaries.
|
||||||
|
|
||||||
If you like to build from the source on unix:
|
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
|
env CGO_ENABLED=0 GO111MODULE=on go get -u -ldflags="-s -w" github.com/gokcehan/lf
|
||||||
|
```
|
||||||
|
|
||||||
On windows `cmd`:
|
On Unix (Go version >= 1.17):
|
||||||
|
|
||||||
|
```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 CGO_ENABLED=0
|
||||||
set GO111MODULE=on
|
set GO111MODULE=on
|
||||||
go get -u -ldflags="-s -w" github.com/gokcehan/lf
|
go get -u -ldflags="-s -w" github.com/gokcehan/lf
|
||||||
|
```
|
||||||
|
|
||||||
On windows `powershell`:
|
On Windows `cmd` (Go version >= 1.17):
|
||||||
|
|
||||||
|
```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:CGO_ENABLED = '0'
|
||||||
$env:GO111MODULE = 'on'
|
$env:GO111MODULE = 'on'
|
||||||
go get -u -ldflags="-s -w" github.com/gokcehan/lf
|
go get -u -ldflags="-s -w" github.com/gokcehan/lf
|
||||||
|
```
|
||||||
|
|
||||||
|
On Windows `powershell` (Go version >= 1.17):
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
$env:CGO_ENABLED = '0'
|
||||||
|
go install -ldflags="-s -w" github.com/gokcehan/lf@latest
|
||||||
|
```
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
@@ -64,8 +90,8 @@ Run `lf -help` to see command line options.
|
|||||||
|
|
||||||
Run `lf -doc` to see the [documentation](https://pkg.go.dev/github.com/gokcehan/lf).
|
Run `lf -doc` to see the [documentation](https://pkg.go.dev/github.com/gokcehan/lf).
|
||||||
|
|
||||||
See [etc](etc) directory to integrate `lf` to your shell or editor.
|
See [etc](etc) directory to integrate `lf` to your shell and/or editor.
|
||||||
An example configuration file can also be found in this directory.
|
Example configuration files along with example colors and icons files can also be found in this directory.
|
||||||
|
|
||||||
See [integrations](https://github.com/gokcehan/lf/wiki/Integrations) to integrate `lf` to other tools.
|
See [integrations](https://github.com/gokcehan/lf/wiki/Integrations) to integrate `lf` to other tools.
|
||||||
|
|
||||||
|
|||||||
@@ -72,7 +72,6 @@ func (app *app) quit() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
os.Remove(gLogPath)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (app *app) readFile(path string) {
|
func (app *app) readFile(path string) {
|
||||||
@@ -137,6 +136,10 @@ func loadFiles() (list []string, cp bool, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func saveFiles(list []string, cp bool) error {
|
func saveFiles(list []string, cp bool) error {
|
||||||
|
if err := os.MkdirAll(filepath.Dir(gFilesPath), os.ModePerm); err != nil {
|
||||||
|
return fmt.Errorf("creating data directory: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
files, err := os.Create(gFilesPath)
|
files, err := os.Create(gFilesPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("opening file selections file: %s", err)
|
return fmt.Errorf("opening file selections file: %s", err)
|
||||||
@@ -242,19 +245,6 @@ func (app *app) loop() {
|
|||||||
|
|
||||||
app.ui.readExpr()
|
app.ui.readExpr()
|
||||||
|
|
||||||
if gSelect != "" {
|
|
||||||
go func() {
|
|
||||||
lstat, err := os.Lstat(gSelect)
|
|
||||||
if err != nil {
|
|
||||||
app.ui.exprChan <- &callExpr{"echoerr", []string{err.Error()}, 1}
|
|
||||||
} else if lstat.IsDir() {
|
|
||||||
app.ui.exprChan <- &callExpr{"cd", []string{gSelect}, 1}
|
|
||||||
} else {
|
|
||||||
app.ui.exprChan <- &callExpr{"select", []string{gSelect}, 1}
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
}
|
|
||||||
|
|
||||||
if gConfigPath != "" {
|
if gConfigPath != "" {
|
||||||
if _, err := os.Stat(gConfigPath); !os.IsNotExist(err) {
|
if _, err := os.Stat(gConfigPath); !os.IsNotExist(err) {
|
||||||
app.readFile(gConfigPath)
|
app.readFile(gConfigPath)
|
||||||
@@ -281,6 +271,28 @@ func (app *app) loop() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wd, err := os.Getwd()
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("getting current directory: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
app.nav.getDirs(wd)
|
||||||
|
app.nav.addJumpList()
|
||||||
|
app.nav.init = true
|
||||||
|
|
||||||
|
if gSelect != "" {
|
||||||
|
go func() {
|
||||||
|
lstat, err := os.Lstat(gSelect)
|
||||||
|
if err != nil {
|
||||||
|
app.ui.exprChan <- &callExpr{"echoerr", []string{err.Error()}, 1}
|
||||||
|
} else if lstat.IsDir() {
|
||||||
|
app.ui.exprChan <- &callExpr{"cd", []string{gSelect}, 1}
|
||||||
|
} else {
|
||||||
|
app.ui.exprChan <- &callExpr{"select", []string{gSelect}, 1}
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-app.quitChan:
|
case <-app.quitChan:
|
||||||
@@ -299,6 +311,10 @@ func (app *app) loop() {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if cmd, ok := gOpts.cmds["on-quit"]; ok {
|
||||||
|
cmd.eval(app, nil)
|
||||||
|
}
|
||||||
|
|
||||||
app.quit()
|
app.quit()
|
||||||
|
|
||||||
app.nav.previewChan <- ""
|
app.nav.previewChan <- ""
|
||||||
@@ -368,6 +384,7 @@ func (app *app) loop() {
|
|||||||
case d := <-app.nav.dirChan:
|
case d := <-app.nav.dirChan:
|
||||||
app.nav.checkDir(d)
|
app.nav.checkDir(d)
|
||||||
|
|
||||||
|
if gOpts.dircache {
|
||||||
prev, ok := app.nav.dirCache[d.path]
|
prev, ok := app.nav.dirCache[d.path]
|
||||||
if ok {
|
if ok {
|
||||||
d.ind = prev.ind
|
d.ind = prev.ind
|
||||||
@@ -375,6 +392,7 @@ func (app *app) loop() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
app.nav.dirCache[d.path] = d
|
app.nav.dirCache[d.path] = d
|
||||||
|
}
|
||||||
|
|
||||||
for i := range app.nav.dirs {
|
for i := range app.nav.dirs {
|
||||||
if app.nav.dirs[i].path == d.path {
|
if app.nav.dirs[i].path == d.path {
|
||||||
@@ -442,17 +460,6 @@ func (app *app) loop() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (app *app) exportFiles() {
|
|
||||||
var currFile string
|
|
||||||
if curr, err := app.nav.currFile(); err == nil {
|
|
||||||
currFile = curr.path
|
|
||||||
}
|
|
||||||
|
|
||||||
currSelections := app.nav.currSelections()
|
|
||||||
|
|
||||||
exportFiles(currFile, currSelections, app.nav.currDir().path)
|
|
||||||
}
|
|
||||||
|
|
||||||
// This function is used to run a shell command. Modes are as follows:
|
// This function is used to run a shell command. Modes are as follows:
|
||||||
//
|
//
|
||||||
// Prefix Wait Async Stdin Stdout Stderr UI action
|
// Prefix Wait Async Stdin Stdout Stderr UI action
|
||||||
@@ -461,7 +468,7 @@ func (app *app) exportFiles() {
|
|||||||
// ! Yes No Yes Yes Yes Pause and then resume
|
// ! Yes No Yes Yes Yes Pause and then resume
|
||||||
// & No Yes No No No Do nothing
|
// & No Yes No No No Do nothing
|
||||||
func (app *app) runShell(s string, args []string, prefix string) {
|
func (app *app) runShell(s string, args []string, prefix string) {
|
||||||
app.exportFiles()
|
app.nav.exportFiles()
|
||||||
exportOpts()
|
exportOpts()
|
||||||
|
|
||||||
cmd := shellCommand(s, args)
|
cmd := shellCommand(s, args)
|
||||||
@@ -489,6 +496,10 @@ func (app *app) runShell(s string, args []string, prefix string) {
|
|||||||
|
|
||||||
err = cmd.Run()
|
err = cmd.Run()
|
||||||
case "%":
|
case "%":
|
||||||
|
shellSetPG(cmd)
|
||||||
|
if app.ui.cmdPrefix == ">" {
|
||||||
|
return
|
||||||
|
}
|
||||||
stdin, err := cmd.StdinPipe()
|
stdin, err := cmd.StdinPipe()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("writing stdin: %s", err)
|
log.Printf("writing stdin: %s", err)
|
||||||
@@ -502,6 +513,7 @@ func (app *app) runShell(s string, args []string, prefix string) {
|
|||||||
cmd.Stderr = cmd.Stdout
|
cmd.Stderr = cmd.Stdout
|
||||||
fallthrough
|
fallthrough
|
||||||
case "&":
|
case "&":
|
||||||
|
shellSetPG(cmd)
|
||||||
err = cmd.Start()
|
err = cmd.Start()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -518,6 +530,7 @@ func (app *app) runShell(s string, args []string, prefix string) {
|
|||||||
|
|
||||||
switch prefix {
|
switch prefix {
|
||||||
case "%":
|
case "%":
|
||||||
|
normal(app)
|
||||||
app.cmd = cmd
|
app.cmd = cmd
|
||||||
app.cmdOutBuf = nil
|
app.cmdOutBuf = nil
|
||||||
app.ui.msg = ""
|
app.ui.msg = ""
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
"bufio"
|
"bufio"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
@@ -25,12 +26,16 @@ func run() {
|
|||||||
screen.EnableMouse()
|
screen.EnableMouse()
|
||||||
}
|
}
|
||||||
|
|
||||||
f, err := os.Create(gLogPath)
|
if gLogPath != "" {
|
||||||
|
f, err := os.OpenFile(gLogPath, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0600)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
log.SetOutput(f)
|
log.SetOutput(f)
|
||||||
|
} else {
|
||||||
|
log.SetOutput(ioutil.Discard)
|
||||||
|
}
|
||||||
|
|
||||||
log.Print("hi!")
|
log.Print("hi!")
|
||||||
|
|
||||||
@@ -46,6 +51,10 @@ func run() {
|
|||||||
app.ui.echoerrf("reading marks file: %s", err)
|
app.ui.echoerrf("reading marks file: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err := app.nav.readTags(); err != nil {
|
||||||
|
app.ui.echoerrf("reading tags file: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
if err := app.readHistory(); err != nil {
|
if err := app.readHistory(); err != nil {
|
||||||
app.ui.echoerrf("reading history file: %s", err)
|
app.ui.echoerrf("reading history file: %s", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,6 +72,12 @@ func parseStyles() styleMap {
|
|||||||
sm.parseGNU(env)
|
sm.parseGNU(env)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for _, path := range gColorsPaths {
|
||||||
|
if _, err := os.Stat(path); !os.IsNotExist(err) {
|
||||||
|
sm.parseFile(path)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return sm
|
return sm
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -158,6 +164,35 @@ func applyAnsiCodes(s string, st tcell.Style) tcell.Style {
|
|||||||
return st
|
return st
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (sm styleMap) parseFile(path string) {
|
||||||
|
log.Printf("reading file: %s", path)
|
||||||
|
|
||||||
|
f, err := os.Open(path)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("opening colors file: %s", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer f.Close()
|
||||||
|
|
||||||
|
pairs, err := readPairs(f)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("reading colors file: %s", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, pair := range pairs {
|
||||||
|
key, val := pair[0], pair[1]
|
||||||
|
|
||||||
|
key = replaceTilde(key)
|
||||||
|
|
||||||
|
if filepath.IsAbs(key) {
|
||||||
|
key = filepath.Clean(key)
|
||||||
|
}
|
||||||
|
|
||||||
|
sm[key] = applyAnsiCodes(val, tcell.StyleDefault)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// This function parses $LS_COLORS environment variable.
|
// This function parses $LS_COLORS environment variable.
|
||||||
func (sm styleMap) parseGNU(env string) {
|
func (sm styleMap) parseGNU(env string) {
|
||||||
for _, entry := range strings.Split(env, ":") {
|
for _, entry := range strings.Split(env, ":") {
|
||||||
@@ -276,6 +311,10 @@ func (sm styleMap) get(f *file) tcell.Style {
|
|||||||
return val
|
return val
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if val, ok := sm["*"+f.Name()]; ok {
|
||||||
|
return val
|
||||||
|
}
|
||||||
|
|
||||||
if val, ok := sm[filepath.Base(f.Name())+".*"]; ok {
|
if val, ok := sm[filepath.Base(f.Name())+".*"]; ok {
|
||||||
return val
|
return val
|
||||||
}
|
}
|
||||||
|
|||||||
+19
@@ -17,9 +17,11 @@ var (
|
|||||||
"up",
|
"up",
|
||||||
"half-up",
|
"half-up",
|
||||||
"page-up",
|
"page-up",
|
||||||
|
"scroll-up",
|
||||||
"down",
|
"down",
|
||||||
"half-down",
|
"half-down",
|
||||||
"page-down",
|
"page-down",
|
||||||
|
"scroll-down",
|
||||||
"updir",
|
"updir",
|
||||||
"open",
|
"open",
|
||||||
"quit",
|
"quit",
|
||||||
@@ -48,6 +50,8 @@ var (
|
|||||||
"search-back",
|
"search-back",
|
||||||
"search-next",
|
"search-next",
|
||||||
"search-prev",
|
"search-prev",
|
||||||
|
"filter",
|
||||||
|
"setfilter",
|
||||||
"mark-save",
|
"mark-save",
|
||||||
"mark-remove",
|
"mark-remove",
|
||||||
"mark-load",
|
"mark-load",
|
||||||
@@ -58,12 +62,15 @@ var (
|
|||||||
"echomsg",
|
"echomsg",
|
||||||
"echoerr",
|
"echoerr",
|
||||||
"cd",
|
"cd",
|
||||||
|
"calcdirsize",
|
||||||
"select",
|
"select",
|
||||||
"glob-select",
|
"glob-select",
|
||||||
"glob-unselect",
|
"glob-unselect",
|
||||||
"source",
|
"source",
|
||||||
"push",
|
"push",
|
||||||
"delete",
|
"delete",
|
||||||
|
"tag",
|
||||||
|
"tag-toggle",
|
||||||
}
|
}
|
||||||
|
|
||||||
gOptWords = []string{
|
gOptWords = []string{
|
||||||
@@ -73,12 +80,18 @@ var (
|
|||||||
"autoquit",
|
"autoquit",
|
||||||
"noautoquit",
|
"noautoquit",
|
||||||
"autoquit!",
|
"autoquit!",
|
||||||
|
"dircache",
|
||||||
|
"nodircache",
|
||||||
|
"dircache!",
|
||||||
"dircounts",
|
"dircounts",
|
||||||
"nodircounts",
|
"nodircounts",
|
||||||
"dircounts!",
|
"dircounts!",
|
||||||
"dirfirst",
|
"dirfirst",
|
||||||
"nodirfirst",
|
"nodirfirst",
|
||||||
"dirfirst!",
|
"dirfirst!",
|
||||||
|
"dironly",
|
||||||
|
"nodironly",
|
||||||
|
"dironly!",
|
||||||
"drawbox",
|
"drawbox",
|
||||||
"nodrawbox",
|
"nodrawbox",
|
||||||
"drawbox!",
|
"drawbox!",
|
||||||
@@ -100,6 +113,9 @@ var (
|
|||||||
"incsearch",
|
"incsearch",
|
||||||
"noincsearch",
|
"noincsearch",
|
||||||
"incsearch!",
|
"incsearch!",
|
||||||
|
"incfilter",
|
||||||
|
"noincfilter",
|
||||||
|
"incfilter!",
|
||||||
"mouse",
|
"mouse",
|
||||||
"nomouse",
|
"nomouse",
|
||||||
"mouse!",
|
"mouse!",
|
||||||
@@ -146,6 +162,9 @@ var (
|
|||||||
"shellopts",
|
"shellopts",
|
||||||
"sortby",
|
"sortby",
|
||||||
"timefmt",
|
"timefmt",
|
||||||
|
"tempmarks",
|
||||||
|
"infotimefmtnew",
|
||||||
|
"infotimefmtold",
|
||||||
"truncatechar",
|
"truncatechar",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ func copyFile(src, dst string, info os.FileInfo, nums chan int64) error {
|
|||||||
}
|
}
|
||||||
defer r.Close()
|
defer r.Close()
|
||||||
|
|
||||||
w, err := os.Create(dst)
|
w, err := os.OpenFile(dst, os.O_RDWR|os.O_CREATE|os.O_TRUNC, info.Mode())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -70,11 +70,6 @@ func copyFile(src, dst string, info os.FileInfo, nums chan int64) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := os.Chmod(dst, info.Mode()); err != nil {
|
|
||||||
os.Remove(dst)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,10 +4,11 @@
|
|||||||
/*
|
/*
|
||||||
lf is a terminal file manager.
|
lf is a terminal file manager.
|
||||||
|
|
||||||
Source code can be found in the repository at https://github.com/gokcehan/lf.
|
Source code can be found in the repository at https://github.com/gokcehan/lf
|
||||||
|
|
||||||
This documentation can either be read from terminal using 'lf -doc' or online at https://godoc.org/github.com/gokcehan/lf.
|
This documentation can either be read from terminal using 'lf -doc' or online at https://pkg.go.dev/github.com/gokcehan/lf
|
||||||
You can also use 'doc' command (default '<f-1>') inside lf to view the documentation in a pager.
|
You can also use 'doc' command (default '<f-1>') inside lf to view the documentation in a pager.
|
||||||
|
A man page with the same content is also available in the repository at https://github.com/gokcehan/lf/blob/master/lf.1
|
||||||
|
|
||||||
You can run 'lf -help' to see descriptions of command line options.
|
You can run 'lf -help' to see descriptions of command line options.
|
||||||
|
|
||||||
@@ -19,11 +20,15 @@ The following commands are provided by lf:
|
|||||||
up (default 'k' and '<up>')
|
up (default 'k' and '<up>')
|
||||||
half-up (default '<c-u>')
|
half-up (default '<c-u>')
|
||||||
page-up (default '<c-b>' and '<pgup>')
|
page-up (default '<c-b>' and '<pgup>')
|
||||||
|
scroll-up (default '<c-y>')
|
||||||
down (default 'j' and '<down>')
|
down (default 'j' and '<down>')
|
||||||
half-down (default '<c-d>')
|
half-down (default '<c-d>')
|
||||||
page-down (default '<c-f>' and '<pgdn>')
|
page-down (default '<c-f>' and '<pgdn>')
|
||||||
|
scroll-down (default '<c-e>')
|
||||||
updir (default 'h' and '<left>')
|
updir (default 'h' and '<left>')
|
||||||
open (default 'l' and '<right>')
|
open (default 'l' and '<right>')
|
||||||
|
jump-next (default ']')
|
||||||
|
jump-prev (default '[')
|
||||||
top (default 'gg' and '<home>')
|
top (default 'gg' and '<home>')
|
||||||
bottom (default 'G' and '<end>')
|
bottom (default 'G' and '<end>')
|
||||||
toggle
|
toggle
|
||||||
@@ -31,6 +36,7 @@ The following commands are provided by lf:
|
|||||||
unselect (default 'u')
|
unselect (default 'u')
|
||||||
glob-select
|
glob-select
|
||||||
glob-unselect
|
glob-unselect
|
||||||
|
calcdirsize
|
||||||
copy (default 'y')
|
copy (default 'y')
|
||||||
cut (default 'd')
|
cut (default 'd')
|
||||||
paste (default 'p')
|
paste (default 'p')
|
||||||
@@ -62,9 +68,13 @@ The following commands are provided by lf:
|
|||||||
search-back (modal) (default '?')
|
search-back (modal) (default '?')
|
||||||
search-next (default 'n')
|
search-next (default 'n')
|
||||||
search-prev (default 'N')
|
search-prev (default 'N')
|
||||||
|
filter (modal)
|
||||||
|
setfilter
|
||||||
mark-save (modal) (default 'm')
|
mark-save (modal) (default 'm')
|
||||||
mark-load (modal) (default "'")
|
mark-load (modal) (default "'")
|
||||||
mark-remove (modal) (default `"`)
|
mark-remove (modal) (default '"')
|
||||||
|
tag
|
||||||
|
tag-toggle (default 't')
|
||||||
|
|
||||||
The following command line commands are provided by lf:
|
The following command line commands are provided by lf:
|
||||||
|
|
||||||
@@ -99,8 +109,11 @@ The following options can be used to customize the behavior of lf:
|
|||||||
|
|
||||||
anchorfind bool (default on)
|
anchorfind bool (default on)
|
||||||
autoquit bool (default off)
|
autoquit bool (default off)
|
||||||
|
cleaner string (default '')
|
||||||
|
dircache bool (default on)
|
||||||
dircounts bool (default off)
|
dircounts bool (default off)
|
||||||
dirfirst bool (default on)
|
dirfirst bool (default on)
|
||||||
|
dironly bool (default off)
|
||||||
drawbox bool (default off)
|
drawbox bool (default off)
|
||||||
errorfmt string (default "\033[7;31;47m%s\033[0m")
|
errorfmt string (default "\033[7;31;47m%s\033[0m")
|
||||||
filesep string (default "\n")
|
filesep string (default "\n")
|
||||||
@@ -112,26 +125,30 @@ The following options can be used to customize the behavior of lf:
|
|||||||
ifs string (default '')
|
ifs string (default '')
|
||||||
ignorecase bool (default on)
|
ignorecase bool (default on)
|
||||||
ignoredia bool (default on)
|
ignoredia bool (default on)
|
||||||
|
incfilter bool (default off)
|
||||||
incsearch bool (default off)
|
incsearch bool (default off)
|
||||||
info []string (default '')
|
info []string (default '')
|
||||||
|
infotimefmtnew string (default 'Jan _2 15:04')
|
||||||
|
infotimefmtold string (default 'Jan _2 2006')
|
||||||
mouse bool (default off)
|
mouse bool (default off)
|
||||||
number bool (default off)
|
number bool (default off)
|
||||||
period int (default 0)
|
period int (default 0)
|
||||||
preview bool (default on)
|
preview bool (default on)
|
||||||
previewer string (default '')
|
previewer string (default '')
|
||||||
cleaner string (default '')
|
|
||||||
promptfmt string (default "\033[32;1m%u@%h\033[0m:\033[34;1m%d\033[0m\033[1m%f\033[0m")
|
promptfmt string (default "\033[32;1m%u@%h\033[0m:\033[34;1m%d\033[0m\033[1m%f\033[0m")
|
||||||
ratios []int (default '1:2:3')
|
ratios []int (default '1:2:3')
|
||||||
relativenumber bool (default off)
|
relativenumber bool (default off)
|
||||||
reverse bool (default off)
|
reverse bool (default off)
|
||||||
scrolloff int (default 0)
|
scrolloff int (default 0)
|
||||||
shell string (default 'sh' for unix and 'cmd' for windows)
|
shell string (default 'sh' for Unix and 'cmd' for Windows)
|
||||||
shellflag string (default '-c' for unix and '/c' for windows)
|
shellflag string (default '-c' for Unix and '/c' for Windows)
|
||||||
shellopts []string (default '')
|
shellopts []string (default '')
|
||||||
smartcase bool (default on)
|
smartcase bool (default on)
|
||||||
smartdia bool (default off)
|
smartdia bool (default off)
|
||||||
sortby string (default 'natural')
|
sortby string (default 'natural')
|
||||||
tabstop int (default 8)
|
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')
|
timefmt string (default 'Mon Jan _2 15:04:05 2006')
|
||||||
truncatechar string (default '~')
|
truncatechar string (default '~')
|
||||||
waitmsg string (default 'Press any key to continue')
|
waitmsg string (default 'Press any key to continue')
|
||||||
@@ -151,10 +168,21 @@ The following environment variables are exported for shell commands:
|
|||||||
EDITOR
|
EDITOR
|
||||||
PAGER
|
PAGER
|
||||||
SHELL
|
SHELL
|
||||||
|
lf_{option}
|
||||||
|
|
||||||
|
The following special shell commands are used to customize the behavior of lf when defined:
|
||||||
|
|
||||||
|
open
|
||||||
|
paste
|
||||||
|
rename
|
||||||
|
delete
|
||||||
|
pre-cd
|
||||||
|
on-cd
|
||||||
|
on-quit
|
||||||
|
|
||||||
The following commands/keybindings are provided by default:
|
The following commands/keybindings are provided by default:
|
||||||
|
|
||||||
unix windows
|
Unix Windows
|
||||||
cmd open &$OPENER "$f" cmd open &%OPENER% %f%
|
cmd open &$OPENER "$f" cmd open &%OPENER% %f%
|
||||||
map e $$EDITOR "$f" map e $%EDITOR% %f%
|
map e $$EDITOR "$f" map e $%EDITOR% %f%
|
||||||
map i $$PAGER "$f" map i !%PAGER% %f%
|
map i $$PAGER "$f" map i !%PAGER% %f%
|
||||||
@@ -181,27 +209,43 @@ Configuration
|
|||||||
|
|
||||||
Configuration files should be located at:
|
Configuration files should be located at:
|
||||||
|
|
||||||
os system-wide user-specific
|
OS system-wide user-specific
|
||||||
unix /etc/lf/lfrc ~/.config/lf/lfrc
|
Unix /etc/lf/lfrc ~/.config/lf/lfrc
|
||||||
windows C:\ProgramData\lf\lfrc C:\Users\<user>\AppData\Local\lf\lfrc
|
Windows C:\ProgramData\lf\lfrc C:\Users\<user>\AppData\Local\lf\lfrc
|
||||||
|
|
||||||
|
Colors file should be located at:
|
||||||
|
|
||||||
|
OS system-wide user-specific
|
||||||
|
Unix /etc/lf/colors ~/.config/lf/colors
|
||||||
|
Windows C:\ProgramData\lf\colors C:\Users\<user>\AppData\Local\lf\colors
|
||||||
|
|
||||||
|
Icons file should be located at:
|
||||||
|
|
||||||
|
OS system-wide user-specific
|
||||||
|
Unix /etc/lf/icons ~/.config/lf/icons
|
||||||
|
Windows C:\ProgramData\lf\icons C:\Users\<user>\AppData\Local\lf\icons
|
||||||
|
|
||||||
Selection file should be located at:
|
Selection file should be located at:
|
||||||
|
|
||||||
unix ~/.local/share/lf/files
|
Unix ~/.local/share/lf/files
|
||||||
windows C:\Users\<user>\AppData\Local\lf\files
|
Windows C:\Users\<user>\AppData\Local\lf\files
|
||||||
|
|
||||||
Marks file should be located at:
|
Marks file should be located at:
|
||||||
|
|
||||||
unix ~/.local/share/lf/marks
|
Unix ~/.local/share/lf/marks
|
||||||
windows C:\Users\<user>\AppData\Local\lf\marks
|
Windows C:\Users\<user>\AppData\Local\lf\marks
|
||||||
|
|
||||||
|
Tags file should be located at:
|
||||||
|
|
||||||
|
Unix ~/.local/share/lf/tags
|
||||||
|
Windows C:\Users\<user>\AppData\Local\lf\tags
|
||||||
|
|
||||||
History file should be located at:
|
History file should be located at:
|
||||||
|
|
||||||
unix ~/.local/share/lf/history
|
Unix ~/.local/share/lf/history
|
||||||
windows C:\Users\<user>\AppData\Local\lf\history
|
Windows C:\Users\<user>\AppData\Local\lf\history
|
||||||
|
|
||||||
You can configure the default values of following variables to change these
|
You can configure the default values of following variables to change these locations:
|
||||||
locations:
|
|
||||||
|
|
||||||
$XDG_CONFIG_HOME ~/.config
|
$XDG_CONFIG_HOME ~/.config
|
||||||
$XDG_DATA_HOME ~/.local/share
|
$XDG_DATA_HOME ~/.local/share
|
||||||
@@ -209,7 +253,7 @@ locations:
|
|||||||
%LOCALAPPDATA% C:\Users\<user>\AppData\Local
|
%LOCALAPPDATA% C:\Users\<user>\AppData\Local
|
||||||
|
|
||||||
A sample configuration file can be found at
|
A sample configuration file can be found at
|
||||||
https://github.com/gokcehan/lf/blob/master/etc/lfrc.example.
|
https://github.com/gokcehan/lf/blob/master/etc/lfrc.example
|
||||||
|
|
||||||
Commands
|
Commands
|
||||||
|
|
||||||
@@ -223,11 +267,13 @@ Quit lf and return to the shell.
|
|||||||
up (default 'k' and '<up>')
|
up (default 'k' and '<up>')
|
||||||
half-up (default '<c-u>')
|
half-up (default '<c-u>')
|
||||||
page-up (default '<c-b>' and '<pgup>')
|
page-up (default '<c-b>' and '<pgup>')
|
||||||
|
scroll-up (default '<c-y>')
|
||||||
down (default 'j' and '<down>')
|
down (default 'j' and '<down>')
|
||||||
half-down (default '<c-d>')
|
half-down (default '<c-d>')
|
||||||
page-down (default '<c-f>' and '<pgdn>')
|
page-down (default '<c-f>' and '<pgdn>')
|
||||||
|
scroll-down (default '<c-e>')
|
||||||
|
|
||||||
Move the current file selection upwards/downwards by one/half a page/full page.
|
Move/scroll the current file selection upwards/downwards by one/half a page/full page.
|
||||||
|
|
||||||
updir (default 'h' and '<left>')
|
updir (default 'h' and '<left>')
|
||||||
|
|
||||||
@@ -239,7 +285,10 @@ If the current file is a directory, then change the current directory to it, oth
|
|||||||
A default 'open' command is provided to call the default system opener asynchronously with the current file as the argument.
|
A default 'open' command is provided to call the default system opener asynchronously with the current file as the argument.
|
||||||
A custom 'open' command can be defined to override this default.
|
A custom 'open' command can be defined to override this default.
|
||||||
|
|
||||||
(See also 'OPENER' variable and 'Opening Files' section)
|
jump-next (default ']')
|
||||||
|
jump-prev (default '[')
|
||||||
|
|
||||||
|
Change the current working directory to the next/previous jumplist item.
|
||||||
|
|
||||||
top (default 'gg' and '<home>')
|
top (default 'gg' and '<home>')
|
||||||
bottom (default 'G' and '<end>')
|
bottom (default 'G' and '<end>')
|
||||||
@@ -254,19 +303,21 @@ Toggle the selection of the current file or files given as arguments.
|
|||||||
|
|
||||||
Reverse the selection of all files in the current directory (i.e. 'toggle' all files).
|
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.
|
Selections in other directories are not effected by this command.
|
||||||
You can define a new command to select all files in the directory by combining 'invert' with 'unselect' (i.e. `cmd select-all :unselect; invert`), though this will also remove selections in other directories.
|
You can define a new command to select all files in the directory by combining 'invert' with 'unselect' (i.e. 'cmd select-all :unselect; invert'), though this will also remove selections in other directories.
|
||||||
|
|
||||||
unselect (default 'u')
|
unselect (default 'u')
|
||||||
|
|
||||||
Remove the selection of all files in all directories.
|
Remove the selection of all files in all directories.
|
||||||
|
|
||||||
glob-select
|
glob-select
|
||||||
|
|
||||||
Select files that match the given glob.
|
|
||||||
|
|
||||||
glob-unselect
|
glob-unselect
|
||||||
|
|
||||||
Unselect files that match the given glob.
|
Select/unselect files that match the given glob.
|
||||||
|
|
||||||
|
calcdirsize
|
||||||
|
|
||||||
|
Calculate the total size for each of the selected directories.
|
||||||
|
Option 'info' should include 'size' and option 'dircounts' should be disabled to show this size.
|
||||||
|
|
||||||
copy (default 'y')
|
copy (default 'y')
|
||||||
|
|
||||||
@@ -279,6 +330,7 @@ If there are no selections, save the path of the current file to the cut buffer,
|
|||||||
paste (default 'p')
|
paste (default 'p')
|
||||||
|
|
||||||
Copy/Move files in copy/cut buffer to the current working directory.
|
Copy/Move files in copy/cut buffer to the current working directory.
|
||||||
|
A custom 'paste' command can be defined to override this default.
|
||||||
|
|
||||||
clear (default 'c')
|
clear (default 'c')
|
||||||
|
|
||||||
@@ -317,7 +369,7 @@ Print given arguments to the message line at the bottom and also to the log file
|
|||||||
|
|
||||||
echoerr
|
echoerr
|
||||||
|
|
||||||
Print given arguments to the message line at the bottom in red color and also to the log file.
|
Print given arguments to the message line at the bottom as 'errorfmt' and also to the log file.
|
||||||
|
|
||||||
cd
|
cd
|
||||||
|
|
||||||
@@ -330,6 +382,7 @@ Change the current file selection to the given argument.
|
|||||||
delete (modal)
|
delete (modal)
|
||||||
|
|
||||||
Remove the current file or selected file(s).
|
Remove the current file or selected file(s).
|
||||||
|
A custom 'delete' command can be defined to override this default.
|
||||||
|
|
||||||
rename (modal) (default 'r')
|
rename (modal) (default 'r')
|
||||||
|
|
||||||
@@ -352,23 +405,17 @@ Read a command to evaluate.
|
|||||||
|
|
||||||
Read a shell command to execute.
|
Read a shell command to execute.
|
||||||
|
|
||||||
(See also 'Prefixes' and 'Shell Commands' sections)
|
|
||||||
|
|
||||||
shell-pipe (modal) (default '%')
|
shell-pipe (modal) (default '%')
|
||||||
|
|
||||||
Read a shell command to execute piping its standard I/O to the bottom statline.
|
Read a shell command to execute piping its standard I/O to the bottom statline.
|
||||||
|
|
||||||
(See also 'Prefixes' and 'Piping Shell Commands' sections)
|
|
||||||
|
|
||||||
shell-wait (modal) (default '!')
|
shell-wait (modal) (default '!')
|
||||||
|
|
||||||
Read a shell command to execute and wait for a key press in the end.
|
Read a shell command to execute and wait for a key press in the end.
|
||||||
|
|
||||||
(See also 'Prefixes' and 'Waiting Shell Commands' sections)
|
|
||||||
|
|
||||||
shell-async (modal) (default '&')
|
shell-async (modal) (default '&')
|
||||||
|
|
||||||
Read a shell command to execute synchronously without standard I/O.
|
Read a shell command to execute asynchronously without standard I/O.
|
||||||
|
|
||||||
find (modal) (default 'f')
|
find (modal) (default 'f')
|
||||||
find-back (modal) (default 'F')
|
find-back (modal) (default 'F')
|
||||||
@@ -377,8 +424,6 @@ Read a shell command to execute synchronously without standard I/O.
|
|||||||
|
|
||||||
Read key(s) to find the appropriate file name match in the forward/backward direction and jump to the next/previous match.
|
Read key(s) to find the appropriate file name match in the forward/backward direction and jump to the next/previous match.
|
||||||
|
|
||||||
(See also 'anchorfind', 'findlen', 'wrapscan', 'ignorecase', 'smartcase', 'ignoredia', and 'smartdia' options and 'Searching Files' section)
|
|
||||||
|
|
||||||
search (default '/')
|
search (default '/')
|
||||||
search-back (default '?')
|
search-back (default '?')
|
||||||
search-next (default 'n')
|
search-next (default 'n')
|
||||||
@@ -386,7 +431,12 @@ Read key(s) to find the appropriate file name match in the forward/backward dire
|
|||||||
|
|
||||||
Read a pattern to search for a file name match in the forward/backward direction and jump to the next/previous match.
|
Read a pattern to search for a file name match in the forward/backward direction and jump to the next/previous match.
|
||||||
|
|
||||||
(See also 'globsearch', 'incsearch', 'wrapscan', 'ignorecase', 'smartcase', 'ignoredia', and 'smartdia' options and 'Searching Files' section)
|
filter (modal)
|
||||||
|
setfilter
|
||||||
|
|
||||||
|
Command 'filter' reads a pattern to filter out and only view files matching the pattern.
|
||||||
|
Command 'setfilter' does the same but uses an argument to set the filter immediately.
|
||||||
|
You can supply an argument to 'filter', in order to use that as the starting prompt.
|
||||||
|
|
||||||
mark-save (modal) (default 'm')
|
mark-save (modal) (default 'm')
|
||||||
|
|
||||||
@@ -397,10 +447,19 @@ Save the current directory as a bookmark assigned to the given key.
|
|||||||
Change the current directory to the bookmark assigned to the given key.
|
Change the current directory to the bookmark assigned to the given key.
|
||||||
A special bookmark "'" holds the previous directory after a 'mark-load', 'cd', or 'select' command.
|
A special bookmark "'" holds the previous directory after a 'mark-load', 'cd', or 'select' command.
|
||||||
|
|
||||||
mark-remove (modal) (default `"`)
|
mark-remove (modal) (default '"')
|
||||||
|
|
||||||
Remove a bookmark assigned to the given key.
|
Remove a bookmark assigned to the given key.
|
||||||
|
|
||||||
|
tag
|
||||||
|
|
||||||
|
Tag a file with '*' or a single width character given in the argument.
|
||||||
|
You can define a new tag clearing command by combining 'tag' with 'tag-toggle' (i.e. 'cmd tag-clear :tag; tag-toggle').
|
||||||
|
|
||||||
|
tag-toggle (default 't')
|
||||||
|
|
||||||
|
Tag a file with '*' or a single width character given in the argument if the file is untagged, otherwise remove the tag.
|
||||||
|
|
||||||
Command Line Commands
|
Command Line Commands
|
||||||
|
|
||||||
This section shows information about command line commands.
|
This section shows information about command line commands.
|
||||||
@@ -416,14 +475,11 @@ Quit command line mode and return to normal mode.
|
|||||||
Autocomplete the current word.
|
Autocomplete the current word.
|
||||||
|
|
||||||
cmd-menu-complete
|
cmd-menu-complete
|
||||||
|
|
||||||
Autocomplete the current word, then you can press the binded key/s
|
|
||||||
again to cycle completition options.
|
|
||||||
|
|
||||||
cmd-menu-complete-back
|
cmd-menu-complete-back
|
||||||
|
|
||||||
Autocomplete the current word, then you can press the binded key/s
|
Autocomplete the current word with menu selection.
|
||||||
again to cycle completition options backwards.
|
You need to assign keys to these commands (e.g. 'cmap <tab> cmd-menu-complete; cmap <backtab> cmd-menu-complete-back').
|
||||||
|
You can use the assigned keys assigned to display the menu and then cycle through completion options.
|
||||||
|
|
||||||
cmd-enter (default '<c-j>' and '<enter>')
|
cmd-enter (default '<c-j>' and '<enter>')
|
||||||
|
|
||||||
@@ -499,6 +555,18 @@ When this option is enabled, find command starts matching patterns from the begi
|
|||||||
|
|
||||||
Automatically quit server when there are no clients left connected.
|
Automatically quit server when there are no clients left connected.
|
||||||
|
|
||||||
|
cleaner string (default '') (not called if empty)
|
||||||
|
|
||||||
|
Set the path of a cleaner file.
|
||||||
|
The file should be executable.
|
||||||
|
This file is called if previewing is enabled, the previewer is set, and the previously selected file had its preview cache disabled.
|
||||||
|
One argument is passed to the file, path to the file whose preview should be cleaned.
|
||||||
|
Preview clearing is disabled when the value of this option is left empty.
|
||||||
|
|
||||||
|
dircache bool (default on)
|
||||||
|
|
||||||
|
Cache directory contents.
|
||||||
|
|
||||||
dircounts bool (default off)
|
dircounts bool (default off)
|
||||||
|
|
||||||
When this option is enabled, directory sizes show the number of items inside instead of the size of directory file.
|
When this option is enabled, directory sizes show the number of items inside instead of the size of directory file.
|
||||||
@@ -512,6 +580,10 @@ A thousand items are counted per directory at most, and bigger directories are s
|
|||||||
|
|
||||||
Show directories first above regular files.
|
Show directories first above regular files.
|
||||||
|
|
||||||
|
dironly bool (default off)
|
||||||
|
|
||||||
|
Show only directories.
|
||||||
|
|
||||||
drawbox bool (default off)
|
drawbox bool (default off)
|
||||||
|
|
||||||
Draw boxes around panes with box drawing characters.
|
Draw boxes around panes with box drawing characters.
|
||||||
@@ -538,8 +610,8 @@ Otherwise, these characters are interpreted as they are.
|
|||||||
hidden bool (default off)
|
hidden bool (default off)
|
||||||
|
|
||||||
Show hidden files.
|
Show hidden files.
|
||||||
On unix systems, hidden files are determined by the value of 'hiddenfiles'.
|
On Unix systems, hidden files are determined by the value of 'hiddenfiles'.
|
||||||
On windows, only files with hidden attributes are considered hidden files.
|
On Windows, only files with hidden attributes are considered hidden files.
|
||||||
|
|
||||||
hiddenfiles []string (default '.*')
|
hiddenfiles []string (default '.*')
|
||||||
|
|
||||||
@@ -551,19 +623,15 @@ In addition, if a pattern starts with '!', then its matches are excluded from hi
|
|||||||
icons bool (default off)
|
icons bool (default off)
|
||||||
|
|
||||||
Show icons before each item in the list.
|
Show icons before each item in the list.
|
||||||
By default, only two icons, 🗀 (U+1F5C0) and 🗎 (U+1F5CE), are used for directories and files respectively, as they are supported in the unicode standard.
|
|
||||||
Icons can be configured with an environment variable named 'LF_ICONS'.
|
|
||||||
The syntax of this variable is similar to 'LS_COLORS'.
|
|
||||||
See the wiki page for an example icon configuration.
|
|
||||||
|
|
||||||
ifs string (default '')
|
ifs string (default '')
|
||||||
|
|
||||||
Sets 'IFS' variable in shell commands.
|
Sets 'IFS' variable in shell commands.
|
||||||
It works by adding the assignment to the beginning of the command string as 'IFS='...'; ...'.
|
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.
|
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 method assumes a POSIX shell syntax and so it can fail for non-POSIX shells.
|
||||||
This option has no effect when the value is left empty.
|
This option has no effect when the value is left empty.
|
||||||
This option does not have any effect on windows.
|
This option does not have any effect on Windows.
|
||||||
|
|
||||||
ignorecase bool (default on)
|
ignorecase bool (default on)
|
||||||
|
|
||||||
@@ -577,12 +645,24 @@ Ignore diacritics in sorting and search patterns.
|
|||||||
|
|
||||||
Jump to the first match after each keystroke during searching.
|
Jump to the first match after each keystroke during searching.
|
||||||
|
|
||||||
|
incfilter bool (default off)
|
||||||
|
|
||||||
|
Apply filter pattern after each keystroke during filtering.
|
||||||
|
|
||||||
info []string (default '')
|
info []string (default '')
|
||||||
|
|
||||||
List of information shown for directory items at the right side of pane.
|
List of information shown for directory items at the right side of pane.
|
||||||
Currently supported information types are 'size', 'time', 'atime', and 'ctime'.
|
Currently supported information types are 'size', 'time', 'atime', and 'ctime'.
|
||||||
Information is only shown when the pane width is more than twice the width of information.
|
Information is only shown when the pane width is more than twice the width of information.
|
||||||
|
|
||||||
|
infotimefmtnew string (default 'Jan _2 15:04')
|
||||||
|
|
||||||
|
Format string of the file time shown in the info column when it matches this year.
|
||||||
|
|
||||||
|
infotimefmtold string (default 'Jan _2 2006')
|
||||||
|
|
||||||
|
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 off)
|
||||||
|
|
||||||
Send mouse events as input.
|
Send mouse events as input.
|
||||||
@@ -590,7 +670,7 @@ Send mouse events as input.
|
|||||||
number bool (default off)
|
number bool (default off)
|
||||||
|
|
||||||
Show the position number for directory items at the left side of pane.
|
Show the position number for directory items at the left side of pane.
|
||||||
When 'relativenumber' is enabled, only the current line shows the absolute position and relative positions are shown for the rest.
|
When 'relativenumber' option is enabled, only the current line shows the absolute position and relative positions are shown for the rest.
|
||||||
|
|
||||||
period int (default 0)
|
period int (default 0)
|
||||||
|
|
||||||
@@ -610,22 +690,16 @@ Files containing the null character (U+0000) in the read portion are considered
|
|||||||
|
|
||||||
Set the path of a previewer file to filter the content of regular files for previewing.
|
Set the path of a previewer file to filter the content of regular files for previewing.
|
||||||
The file should be executable.
|
The file should be executable.
|
||||||
Five arguments are passed to the file, first is the current file name; the second, third, fourth, and fifth are width, height, horizontal position, and vertical position of preview pane respectively.
|
Five arguments are passed to the file, (1) current file name, (2) width, (3) height, (4) horizontal position, and (5) vertical position of preview pane respectively.
|
||||||
SIGPIPE signal is sent when enough lines are read.
|
SIGPIPE signal is sent when enough lines are read.
|
||||||
If the previewer returns a non-zero exit code, then the preview cache for the given file is disabled. This means that if the file is selected in the future, the previewer is called once again.
|
If the previewer returns a non-zero exit code, then the preview cache for the given file is disabled.
|
||||||
|
This means that if the file is selected in the future, the previewer is called once again.
|
||||||
Preview filtering is disabled and files are displayed as they are when the value of this option is left empty.
|
Preview filtering is disabled and files are displayed as they are when the value of this option is left empty.
|
||||||
|
|
||||||
cleaner string (default '') (not called if empty)
|
|
||||||
|
|
||||||
Set the path of a cleaner file. This file will be called if previewing is enabled, the previewer is set, and the previously selected file had its preview cache disabled.
|
|
||||||
The file should be executable.
|
|
||||||
One argument is passed to the file; the path to the file whose preview should be cleaned.
|
|
||||||
Preview clearing is disabled when the value of this option is left empty.
|
|
||||||
|
|
||||||
promptfmt string (default "\033[32;1m%u@%h\033[0m:\033[34;1m%d\033[0m\033[1m%f\033[0m")
|
promptfmt string (default "\033[32;1m%u@%h\033[0m:\033[34;1m%d\033[0m\033[1m%f\033[0m")
|
||||||
|
|
||||||
Format string of the prompt shown in the top line.
|
Format string of the prompt shown in the top line.
|
||||||
Special expansions are provided, '%u' as the user name, '%h' as the host name, '%w' as the working directory, '%d' as the working directory with a trailing path separator, and '%f' as the file name.
|
Special expansions are provided, '%u' as the user name, '%h' as the host name, '%w' as the working directory, '%d' as the working directory with a trailing path separator, '%f' as the file name, and '%F' as the current filter.
|
||||||
Home folder is shown as '~' in the working directory expansion.
|
Home folder is shown as '~' in the working directory expansion.
|
||||||
Directory names are automatically shortened to a single character starting from the left most parent when the prompt does not fit to the screen.
|
Directory names are automatically shortened to a single character starting from the left most parent when the prompt does not fit to the screen.
|
||||||
|
|
||||||
@@ -650,12 +724,12 @@ Minimum number of offset lines shown at all times in the top and the bottom of t
|
|||||||
The current line is kept in the middle when this option is set to a large value that is bigger than the half of number of lines.
|
The current line is kept in the middle when this option is set to a large value that is bigger than the half of number of lines.
|
||||||
A smaller offset can be used when the current file is close to the beginning or end of the list to show the maximum number of items.
|
A smaller offset can be used when the current file is close to the beginning or end of the list to show the maximum number of items.
|
||||||
|
|
||||||
shell string (default 'sh' for unix and 'cmd' for windows)
|
shell string (default 'sh' for Unix and 'cmd' for Windows)
|
||||||
|
|
||||||
Shell executable to use for shell commands.
|
Shell executable to use for shell commands.
|
||||||
Shell commands are executed as 'shell shellopts shellflag command -- arguments'.
|
Shell commands are executed as 'shell shellopts shellflag command -- arguments'.
|
||||||
|
|
||||||
shellflag string (default '-c' for unix and '/c' for windows)
|
shellflag string (default '-c' for Unix and '/c' for Windows)
|
||||||
|
|
||||||
Command line flag used to pass shell commands.
|
Command line flag used to pass shell commands.
|
||||||
|
|
||||||
@@ -682,6 +756,16 @@ Currently supported sort types are 'natural', 'name', 'size', 'time', 'ctime', '
|
|||||||
|
|
||||||
Number of space characters to show for horizontal tabulation (U+0009) character.
|
Number of space characters to show for horizontal tabulation (U+0009) character.
|
||||||
|
|
||||||
|
tagfmt string (default "\033[31m%s\033[0m")
|
||||||
|
|
||||||
|
Format string of the tags.
|
||||||
|
|
||||||
|
tempmarks string (default '')
|
||||||
|
|
||||||
|
Marks to be considered temporary (e.g. 'abc' refers to marks 'a', 'b', and 'c').
|
||||||
|
These marks are not synced to other clients and they are not saved in the bookmarks file.
|
||||||
|
Note that the special bookmark "'" is always treated as temporary and it does not need to be specified.
|
||||||
|
|
||||||
timefmt string (default 'Mon Jan _2 15:04:05 2006')
|
timefmt string (default 'Mon Jan _2 15:04:05 2006')
|
||||||
|
|
||||||
Format string of the file modification time shown in the bottom line.
|
Format string of the file modification time shown in the bottom line.
|
||||||
@@ -743,15 +827,49 @@ If this variable is set in the environment, use the same value, otherwise set th
|
|||||||
|
|
||||||
EDITOR
|
EDITOR
|
||||||
|
|
||||||
If this variable is set in the environment, use the same value, otherwise set the value to 'vi' on unix, 'notepad' in Windows.
|
If this variable is set in the environment, use the same value, otherwise set the value to 'vi' on Unix, 'notepad' in Windows.
|
||||||
|
|
||||||
PAGER
|
PAGER
|
||||||
|
|
||||||
If this variable is set in the environment, use the same value, otherwise set the value to 'less' on unix, 'more' in Windows.
|
If this variable is set in the environment, use the same value, otherwise set the value to 'less' on Unix, 'more' in Windows.
|
||||||
|
|
||||||
SHELL
|
SHELL
|
||||||
|
|
||||||
If this variable is set in the environment, use the same value, otherwise set the value to 'sh' on unix, 'cmd' in Windows.
|
If this variable is set in the environment, use the same value, otherwise set the value to 'sh' on Unix, 'cmd' in Windows.
|
||||||
|
|
||||||
|
lf_{option}
|
||||||
|
|
||||||
|
Value of the {option}.
|
||||||
|
|
||||||
|
Special Commands
|
||||||
|
|
||||||
|
open
|
||||||
|
|
||||||
|
This shell command can be defined to override the default 'open' command when the current file is not a directory.
|
||||||
|
|
||||||
|
paste
|
||||||
|
|
||||||
|
This shell command can be defined to override the default 'paste' command.
|
||||||
|
|
||||||
|
rename
|
||||||
|
|
||||||
|
This shell command can be defined to override the default 'paste' command.
|
||||||
|
|
||||||
|
delete
|
||||||
|
|
||||||
|
This shell command can be defined to override the default 'delete' command.
|
||||||
|
|
||||||
|
pre-cd
|
||||||
|
|
||||||
|
This shell command can be defined to be executed before changing a directory.
|
||||||
|
|
||||||
|
on-cd
|
||||||
|
|
||||||
|
This shell command can be defined to be executed after changing a directory.
|
||||||
|
|
||||||
|
on-quit
|
||||||
|
|
||||||
|
This shell command can be defined to be executed before quit.
|
||||||
|
|
||||||
Prefixes
|
Prefixes
|
||||||
|
|
||||||
@@ -774,7 +892,7 @@ Characters from '#' to newline are comments and ignored:
|
|||||||
|
|
||||||
# comments start with '#'
|
# comments start with '#'
|
||||||
|
|
||||||
There are three special commands ('set', 'map', and 'cmd') and their variants for configuration.
|
There are three special commands ('set', 'map', 'cmap', and 'cmd') for configuration.
|
||||||
|
|
||||||
Command 'set' is used to set an option which can be boolean, integer, or string:
|
Command 'set' is used to set an option which can be boolean, integer, or string:
|
||||||
|
|
||||||
@@ -960,7 +1078,7 @@ Also, even when there is no output or error, the ui still needs to be paused whi
|
|||||||
This can cause flickering on the screen for short commands and similar distractions for longer commands.
|
This can cause flickering on the screen for short commands and similar distractions for longer commands.
|
||||||
|
|
||||||
Instead of pausing the ui, piping shell commands connects stdin, stdout, and stderr of the command to the statline in the bottom of the ui.
|
Instead of pausing the ui, piping shell commands connects stdin, stdout, and stderr of the command to the statline in the bottom of the ui.
|
||||||
This can be useful for programs following the unix philosophy to give no output in the success case, and brief error messages or prompts in other cases.
|
This can be useful for programs following the Unix philosophy to give no output in the success case, and brief error messages or prompts in other cases.
|
||||||
|
|
||||||
For example, following rename command prompts for overwrite in the statline if there is an existing file with the given name:
|
For example, following rename command prompts for overwrite in the statline if there is an existing file with the given name:
|
||||||
|
|
||||||
@@ -991,11 +1109,11 @@ All clients connect to a server on startup.
|
|||||||
It is possible to send commands to all or any of the connected clients over the common server.
|
It is possible to send commands to all or any of the connected clients over the common server.
|
||||||
This is used internally to notify file selection changes to other clients.
|
This is used internally to notify file selection changes to other clients.
|
||||||
|
|
||||||
To use this feature, you need to use a client which supports communicating with a UNIX-domain socket.
|
To use this feature, you need to use a client which supports communicating with a Unix domain socket.
|
||||||
OpenBSD implementation of netcat (nc) is one such example.
|
OpenBSD implementation of netcat (nc) is one such example.
|
||||||
You can use it to send a command to the socket file:
|
You can use it to send a command to the socket file:
|
||||||
|
|
||||||
echo 'send echo hello world' | nc -U /tmp/lf.${USER}.sock
|
echo 'send echo hello world' | nc -U ${XDG_RUNTIME_DIR:-/tmp}/lf.${USER}.sock
|
||||||
|
|
||||||
Since such a client may not be available everywhere, lf comes bundled with a command line flag to be used as such.
|
Since such a client may not be available everywhere, lf comes bundled with a command line flag to be used as such.
|
||||||
When using lf, you do not need to specify the address of the socket file.
|
When using lf, you do not need to specify the address of the socket file.
|
||||||
@@ -1067,9 +1185,9 @@ You can use the following example as a starting point:
|
|||||||
cp -R $list .
|
cp -R $list .
|
||||||
elif [ $mode = 'move' ]; then
|
elif [ $mode = 'move' ]; then
|
||||||
mv $list .
|
mv $list .
|
||||||
fi
|
|
||||||
rm ~/.local/share/lf/files
|
rm ~/.local/share/lf/files
|
||||||
lf -remote 'send clear'
|
lf -remote 'send clear'
|
||||||
|
fi
|
||||||
}}
|
}}
|
||||||
|
|
||||||
Some useful things to be considered are to use the backup ('--backup') and/or preserve attributes ('-a') options with 'cp' and 'mv' commands if they support it (i.e. GNU implementation), change the command type to asynchronous, or use 'rsync' command with progress bar option for copying and feed the progress to the client periodically with remote 'echo' calls.
|
Some useful things to be considered are to use the backup ('--backup') and/or preserve attributes ('-a') options with 'cp' and 'mv' commands if they support it (i.e. GNU implementation), change the command type to asynchronous, or use 'rsync' command with progress bar option for copying and feed the progress to the client periodically with remote 'echo' calls.
|
||||||
@@ -1147,18 +1265,18 @@ Previewing Files
|
|||||||
|
|
||||||
lf previews files on the preview pane by printing the file until the end or the preview pane is filled.
|
lf previews files on the preview pane by printing the file until the end or the preview pane is filled.
|
||||||
This output can be enhanced by providing a custom preview script for filtering.
|
This output can be enhanced by providing a custom preview script for filtering.
|
||||||
This can be used to highlight source codes, list contents of archive files or view pdf or image files as text to name few.
|
This can be used to highlight source codes, list contents of archive files or view pdf or image files to name few.
|
||||||
For coloring lf recognizes ansi escape codes.
|
For coloring lf recognizes ansi escape codes.
|
||||||
|
|
||||||
In order to use this feature you need to set the value of 'previewer' option to the path of an executable file.
|
In order to use this feature you need to set the value of 'previewer' option to the path of an executable file.
|
||||||
lf passes the current file name as the first argument and the height of the preview pane as the second argument when running this file.
|
Five arguments are passed to the file, (1) current file name, (2) width, (3) height, (4) horizontal position, and (5) vertical position of preview pane respectively.
|
||||||
Output of the execution is printed in the preview pane.
|
Output of the execution is printed in the preview pane.
|
||||||
You may want to use the same script in your pager mapping as well if any:
|
You may also want to use the same script in your pager mapping as well:
|
||||||
|
|
||||||
set previewer ~/.config/lf/pv.sh
|
set previewer ~/.config/lf/pv.sh
|
||||||
map i $~/.config/lf/pv.sh $f | less -R
|
map i $~/.config/lf/pv.sh $f | less -R
|
||||||
|
|
||||||
For 'less' pager, you may instead utilize 'LESSOPEN' mechanism so that useful information about the file such as the full path of the file can be displayed in the statusline below:
|
For 'less' pager, you may instead utilize 'LESSOPEN' mechanism so that useful information about the file such as the full path of the file can still be displayed in the statusline below:
|
||||||
|
|
||||||
set previewer ~/.config/lf/pv.sh
|
set previewer ~/.config/lf/pv.sh
|
||||||
map i $LESSOPEN='| ~/.config/lf/pv.sh %s' less -R $f
|
map i $LESSOPEN='| ~/.config/lf/pv.sh %s' less -R $f
|
||||||
@@ -1198,7 +1316,8 @@ Changing Directory
|
|||||||
|
|
||||||
lf changes the working directory of the process to the current directory so that shell commands always work in the displayed directory.
|
lf changes the working directory of the process to the current directory so that shell commands always work in the displayed directory.
|
||||||
After quitting, it returns to the original directory where it is first launched like all shell programs.
|
After quitting, it returns to the original directory where it is first launched like all shell programs.
|
||||||
If you want to stay in the current directory after quitting, you can use one of the example wrapper shell scripts provided in the repository.
|
If you want to stay in the current directory after quitting, you can use one of the example lfcd wrapper shell scripts provided in the repository at
|
||||||
|
https://github.com/gokcehan/lf/tree/master/etc
|
||||||
|
|
||||||
There is a special command 'on-cd' that runs a shell command when it is defined and the directory is changed.
|
There is a special command 'on-cd' that runs a shell command when it is defined and the directory is changed.
|
||||||
You can define it just as you would define any other command:
|
You can define it just as you would define any other command:
|
||||||
@@ -1225,10 +1344,12 @@ The following xterm specific escape sequence sets the terminal title to the work
|
|||||||
This command runs whenever you change directory but not on startup.
|
This command runs whenever you change directory but not on startup.
|
||||||
You can add an extra call to make it run on startup as well:
|
You can add an extra call to make it run on startup as well:
|
||||||
|
|
||||||
cmd on-cd &{{ # ... }}
|
cmd on-cd &{{ ... }}
|
||||||
on-cd
|
on-cd
|
||||||
|
|
||||||
Note that all shell commands are possible but `%` and `&` are usually more appropriate as `$` and `!` causes flickers and pauses respectively.
|
Note that all shell commands are possible but '%' and '&' are usually more appropriate as '$' and '!' causes flickers and pauses respectively.
|
||||||
|
|
||||||
|
There is also a 'pre-cd' command, that works like 'on-cd', but is run before the directory is actually changed.
|
||||||
|
|
||||||
Colors
|
Colors
|
||||||
|
|
||||||
@@ -1240,17 +1361,20 @@ Colors are set in the following order:
|
|||||||
2. LSCOLORS (Mac/BSD ls)
|
2. LSCOLORS (Mac/BSD ls)
|
||||||
3. LS_COLORS (GNU ls)
|
3. LS_COLORS (GNU ls)
|
||||||
4. LF_COLORS (lf specific)
|
4. LF_COLORS (lf specific)
|
||||||
|
5. colors file (lf specific)
|
||||||
|
|
||||||
Please refer to the corresponding man pages for more information about 'LSCOLORS' and 'LS_COLORS'.
|
Please refer to the corresponding man pages for more information about 'LSCOLORS' and 'LS_COLORS'.
|
||||||
'LF_COLORS' is provided with the same syntax as 'LS_COLORS' in case you want to configure colors only for lf but not ls.
|
'LF_COLORS' is provided with the same syntax as 'LS_COLORS' in case you want to configure colors only for lf but not ls.
|
||||||
This can be useful since there are some differences between ls and lf, though one should expect the same behavior for common cases.
|
This can be useful since there are some differences between ls and lf, though one should expect the same behavior for common cases.
|
||||||
|
Colors file is provided for easier configuration without environment variables.
|
||||||
|
This file should consist of whitespace separated pairs with '#' character to start comments until the end of line.
|
||||||
|
|
||||||
You can configure lf colors in two different ways.
|
You can configure lf colors in two different ways.
|
||||||
First, you can only configure 8 basic colors used by your terminal and lf should pick up those colors automatically.
|
First, you can only configure 8 basic colors used by your terminal and lf should pick up those colors automatically.
|
||||||
Depending on your terminal, you should be able to select your colors from a 24-bit palette.
|
Depending on your terminal, you should be able to select your colors from a 24-bit palette.
|
||||||
This is the recommended approach as colors used by other programs will also match each other.
|
This is the recommended approach as colors used by other programs will also match each other.
|
||||||
|
|
||||||
Second, you can set the values of environmental variables mentioned above for fine grained customization.
|
Second, you can set the values of environment variables or colors file mentioned above for fine grained customization.
|
||||||
Note that 'LS_COLORS/LF_COLORS' are more powerful than 'LSCOLORS' and they can be used even when GNU programs are not installed on the system.
|
Note that 'LS_COLORS/LF_COLORS' are more powerful than 'LSCOLORS' and they can be used even when GNU programs are not installed on the system.
|
||||||
You can combine this second method with the first method for best results.
|
You can combine this second method with the first method for best results.
|
||||||
|
|
||||||
@@ -1258,8 +1382,9 @@ Lastly, you may also want to configure the colors of the prompt line to match th
|
|||||||
Colors of the prompt line can be configured using the 'promptfmt' option which can include hardcoded colors as ansi escapes.
|
Colors of the prompt line can be configured using the 'promptfmt' option which can include hardcoded colors as ansi escapes.
|
||||||
See the default value of this option to have an idea about how to color this line.
|
See the default value of this option to have an idea about how to color this line.
|
||||||
|
|
||||||
It is worth noting that lf uses as many colors are advertised by your terminal's entry in your systems terminfo or infocmp database, if this is not present lf will default to an internal database.
|
It is worth noting that lf uses as many colors advertised by your terminal's entry in terminfo or infocmp databases on your system.
|
||||||
For terminals supporting 24-bit (or "true") color that do not have a database entry (or one that does not advertise all capabilities), support can be enabled by either setting the '$COLORTERM' variable to "truecolor" or ensuring '$TERM' is set to a value that ends with "-truecolor".
|
If an entry is not present, it falls back to an internal database.
|
||||||
|
If your terminal supports 24-bit colors but either does not have a database entry or does not advertise all capabilities, you can enable support by setting the '$COLORTERM' variable to 'truecolor' or ensuring '$TERM' is set to a value that ends with '-truecolor'.
|
||||||
|
|
||||||
Default lf colors are mostly taken from GNU dircolors defaults.
|
Default lf colors are mostly taken from GNU dircolors defaults.
|
||||||
These defaults use 8 basic colors and bold attribute.
|
These defaults use 8 basic colors and bold attribute.
|
||||||
@@ -1282,16 +1407,17 @@ Default values are as follows given with their matching order in lf:
|
|||||||
ex 01;32
|
ex 01;32
|
||||||
fi 00
|
fi 00
|
||||||
|
|
||||||
Note that, lf first tries matching file names and then falls back to file types.
|
Note that lf first tries matching file names and then falls back to file types.
|
||||||
The full order of matchings from most specific to least are as follows:
|
The full order of matchings from most specific to least are as follows:
|
||||||
|
|
||||||
1. Full Path (e.g. '~/.config/lf/lfrc')
|
1. Full Path (e.g. '~/.config/lf/lfrc')
|
||||||
2. Dir Name (e.g. '.git/') (only matches dirs with a trailing slash at the end)
|
2. Dir Name (e.g. '.git/') (only matches dirs with a trailing slash at the end)
|
||||||
3. File Type (e.g. 'ln') (except 'fi')
|
3. File Type (e.g. 'ln') (except 'fi')
|
||||||
4. File Name (e.g. '.git*') (only matches files with a trailing star at the end)
|
4. File Name (e.g. 'README*')
|
||||||
5. Base Name (e.g. 'README.*')
|
5. File Name (e.g. '*README')
|
||||||
6. Extension (e.g. '*.txt')
|
6. Base Name (e.g. 'README.*')
|
||||||
7. Default (i.e. 'fi')
|
7. Extension (e.g. '*.txt')
|
||||||
|
8. Default (i.e. 'fi')
|
||||||
|
|
||||||
For example, given a regular text file '/path/to/README.txt', the following entries are checked in the configuration and the first one to match is used:
|
For example, given a regular text file '/path/to/README.txt', the following entries are checked in the configuration and the first one to match is used:
|
||||||
|
|
||||||
@@ -1299,9 +1425,10 @@ For example, given a regular text file '/path/to/README.txt', the following entr
|
|||||||
2. (skipped since the file is not a directory)
|
2. (skipped since the file is not a directory)
|
||||||
3. (skipped since the file is of type 'fi')
|
3. (skipped since the file is of type 'fi')
|
||||||
4. 'README.txt*'
|
4. 'README.txt*'
|
||||||
5. 'README.*'
|
5. '*README.txt'
|
||||||
6. '*.txt'
|
6. 'README.*'
|
||||||
7. 'fi'
|
7. '*.txt'
|
||||||
|
8. 'fi'
|
||||||
|
|
||||||
Given a regular directory '/path/to/example.d', the following entries are checked in the configuration and the first one to match is used:
|
Given a regular directory '/path/to/example.d', the following entries are checked in the configuration and the first one to match is used:
|
||||||
|
|
||||||
@@ -1309,15 +1436,16 @@ Given a regular directory '/path/to/example.d', the following entries are checke
|
|||||||
2. 'example.d/'
|
2. 'example.d/'
|
||||||
3. 'di'
|
3. 'di'
|
||||||
4. 'example.d*'
|
4. 'example.d*'
|
||||||
5. 'example.*'
|
5. '*example.d'
|
||||||
6. '*.d'
|
6. 'example.*'
|
||||||
7. 'fi'
|
7. '*.d'
|
||||||
|
8. 'fi'
|
||||||
|
|
||||||
Note that glob-like patterns do not actually perform glob matching due to performance reasons.
|
Note that glob-like patterns do not actually perform glob matching due to performance reasons.
|
||||||
|
|
||||||
For example, you can set a variable as follows:
|
For example, you can set a variable as follows:
|
||||||
|
|
||||||
export LF_COLORS="~/Documents=01;31:~/Downloads=01;31:~/.local/share=01;31:~/.config/lf/lfrc=31:.git/=01;32:.git=32:.gitignore=32:Makefile=32:README.*=33:*.txt=34:*.md=34:ln=01;36:di=01;34:ex=01;32:"
|
export LF_COLORS="~/Documents=01;31:~/Downloads=01;31:~/.local/share=01;31:~/.config/lf/lfrc=31:.git/=01;32:.git*=32:*.gitignore=32:*Makefile=32:README.*=33:*.txt=34:*.md=34:ln=01;36:di=01;34:ex=01;32:"
|
||||||
|
|
||||||
Having all entries on a single line can make it hard to read.
|
Having all entries on a single line can make it hard to read.
|
||||||
You may instead divide it to multiple lines in between double quotes by escaping newlines with backslashes as follows:
|
You may instead divide it to multiple lines in between double quotes by escaping newlines with backslashes as follows:
|
||||||
@@ -1328,9 +1456,9 @@ You may instead divide it to multiple lines in between double quotes by escaping
|
|||||||
~/.local/share=01;31:\
|
~/.local/share=01;31:\
|
||||||
~/.config/lf/lfrc=31:\
|
~/.config/lf/lfrc=31:\
|
||||||
.git/=01;32:\
|
.git/=01;32:\
|
||||||
.git=32:\
|
.git*=32:\
|
||||||
.gitignore=32:\
|
*.gitignore=32:\
|
||||||
Makefile=32:\
|
*Makefile=32:\
|
||||||
README.*=33:\
|
README.*=33:\
|
||||||
*.txt=34:\
|
*.txt=34:\
|
||||||
*.md=34:\
|
*.md=34:\
|
||||||
@@ -1340,37 +1468,37 @@ You may instead divide it to multiple lines in between double quotes by escaping
|
|||||||
"
|
"
|
||||||
|
|
||||||
Having such a long variable definition in a shell configuration file might be undesirable.
|
Having such a long variable definition in a shell configuration file might be undesirable.
|
||||||
You may instead put this definition in a separate file and source it in your shell configuration file as follows:
|
You may instead use the colors file for configuration.
|
||||||
|
A sample colors file can be found at
|
||||||
[ -f "/path/to/colors" ] && source "/path/to/colors"
|
https://github.com/gokcehan/lf/blob/master/etc/colors.example
|
||||||
|
You may also see the wiki page for ansi escape codes
|
||||||
See the wiki page for ansi escape codes
|
https://en.wikipedia.org/wiki/ANSI_escape_code
|
||||||
https://en.wikipedia.org/wiki/ANSI_escape_code.
|
|
||||||
|
|
||||||
Icons
|
Icons
|
||||||
|
|
||||||
Icons are configured using 'LF_ICONS' environment variable.
|
Icons are configured using 'LF_ICONS' environment variable or an icons file.
|
||||||
This variable uses the same syntax as 'LS_COLORS/LF_COLORS'.
|
The variable uses the same syntax as 'LS_COLORS/LF_COLORS'.
|
||||||
Instead of colors, you should put a single characters as values of entries.
|
Instead of colors, you should put a single characters as values of entries.
|
||||||
|
Icons file should consist of whitespace separated pairs with '#' character to start comments until the end of line.
|
||||||
Do not forget to enable 'icons' option to see the icons.
|
Do not forget to enable 'icons' option to see the icons.
|
||||||
Default values are as follows given with their matching order in lf:
|
Default values are as follows given with their matching order in lf:
|
||||||
|
|
||||||
ln 🗎
|
ln l
|
||||||
or 🗎
|
or l
|
||||||
tw 🗀
|
tw t
|
||||||
ow 🗀
|
ow d
|
||||||
st 🗀
|
st t
|
||||||
di 🗀
|
di d
|
||||||
pi 🗎
|
pi p
|
||||||
so 🗎
|
so s
|
||||||
bd 🗎
|
bd b
|
||||||
cd 🗎
|
cd c
|
||||||
su 🗎
|
su u
|
||||||
sg 🗎
|
sg g
|
||||||
ex 🗎
|
ex x
|
||||||
fi 🗎
|
fi -
|
||||||
|
|
||||||
See the wiki page for an example icons configuration
|
A sample icons file can be found at
|
||||||
https://github.com/gokcehan/lf/wiki/Icons.
|
https://github.com/gokcehan/lf/blob/master/etc/icons.example
|
||||||
*/
|
*/
|
||||||
package main
|
package main
|
||||||
+291
-155
@@ -5,12 +5,13 @@ package main
|
|||||||
var genDocString = `
|
var genDocString = `
|
||||||
lf is a terminal file manager.
|
lf is a terminal file manager.
|
||||||
|
|
||||||
Source code can be found in the repository at
|
Source code can be found in the repository at https://github.com/gokcehan/lf
|
||||||
https://github.com/gokcehan/lf.
|
|
||||||
|
|
||||||
This documentation can either be read from terminal using 'lf -doc' or
|
This documentation can either be read from terminal using 'lf -doc' or
|
||||||
online at https://godoc.org/github.com/gokcehan/lf. You can also use 'doc'
|
online at https://pkg.go.dev/github.com/gokcehan/lf You can also use 'doc'
|
||||||
command (default '<f-1>') inside lf to view the documentation in a pager.
|
command (default '<f-1>') inside lf to view the documentation in a pager. A
|
||||||
|
man page with the same content is also available in the repository at
|
||||||
|
https://github.com/gokcehan/lf/blob/master/lf.1
|
||||||
|
|
||||||
You can run 'lf -help' to see descriptions of command line options.
|
You can run 'lf -help' to see descriptions of command line options.
|
||||||
|
|
||||||
@@ -23,11 +24,15 @@ The following commands are provided by lf:
|
|||||||
up (default 'k' and '<up>')
|
up (default 'k' and '<up>')
|
||||||
half-up (default '<c-u>')
|
half-up (default '<c-u>')
|
||||||
page-up (default '<c-b>' and '<pgup>')
|
page-up (default '<c-b>' and '<pgup>')
|
||||||
|
scroll-up (default '<c-y>')
|
||||||
down (default 'j' and '<down>')
|
down (default 'j' and '<down>')
|
||||||
half-down (default '<c-d>')
|
half-down (default '<c-d>')
|
||||||
page-down (default '<c-f>' and '<pgdn>')
|
page-down (default '<c-f>' and '<pgdn>')
|
||||||
|
scroll-down (default '<c-e>')
|
||||||
updir (default 'h' and '<left>')
|
updir (default 'h' and '<left>')
|
||||||
open (default 'l' and '<right>')
|
open (default 'l' and '<right>')
|
||||||
|
jump-next (default ']')
|
||||||
|
jump-prev (default '[')
|
||||||
top (default 'gg' and '<home>')
|
top (default 'gg' and '<home>')
|
||||||
bottom (default 'G' and '<end>')
|
bottom (default 'G' and '<end>')
|
||||||
toggle
|
toggle
|
||||||
@@ -35,6 +40,7 @@ The following commands are provided by lf:
|
|||||||
unselect (default 'u')
|
unselect (default 'u')
|
||||||
glob-select
|
glob-select
|
||||||
glob-unselect
|
glob-unselect
|
||||||
|
calcdirsize
|
||||||
copy (default 'y')
|
copy (default 'y')
|
||||||
cut (default 'd')
|
cut (default 'd')
|
||||||
paste (default 'p')
|
paste (default 'p')
|
||||||
@@ -66,9 +72,13 @@ The following commands are provided by lf:
|
|||||||
search-back (modal) (default '?')
|
search-back (modal) (default '?')
|
||||||
search-next (default 'n')
|
search-next (default 'n')
|
||||||
search-prev (default 'N')
|
search-prev (default 'N')
|
||||||
|
filter (modal)
|
||||||
|
setfilter
|
||||||
mark-save (modal) (default 'm')
|
mark-save (modal) (default 'm')
|
||||||
mark-load (modal) (default "'")
|
mark-load (modal) (default "'")
|
||||||
mark-remove (modal) (default '"')
|
mark-remove (modal) (default '"')
|
||||||
|
tag
|
||||||
|
tag-toggle (default 't')
|
||||||
|
|
||||||
The following command line commands are provided by lf:
|
The following command line commands are provided by lf:
|
||||||
|
|
||||||
@@ -103,8 +113,11 @@ The following options can be used to customize the behavior of lf:
|
|||||||
|
|
||||||
anchorfind bool (default on)
|
anchorfind bool (default on)
|
||||||
autoquit bool (default off)
|
autoquit bool (default off)
|
||||||
|
cleaner string (default '')
|
||||||
|
dircache bool (default on)
|
||||||
dircounts bool (default off)
|
dircounts bool (default off)
|
||||||
dirfirst bool (default on)
|
dirfirst bool (default on)
|
||||||
|
dironly bool (default off)
|
||||||
drawbox bool (default off)
|
drawbox bool (default off)
|
||||||
errorfmt string (default "\033[7;31;47m%s\033[0m")
|
errorfmt string (default "\033[7;31;47m%s\033[0m")
|
||||||
filesep string (default "\n")
|
filesep string (default "\n")
|
||||||
@@ -116,26 +129,30 @@ The following options can be used to customize the behavior of lf:
|
|||||||
ifs string (default '')
|
ifs string (default '')
|
||||||
ignorecase bool (default on)
|
ignorecase bool (default on)
|
||||||
ignoredia bool (default on)
|
ignoredia bool (default on)
|
||||||
|
incfilter bool (default off)
|
||||||
incsearch bool (default off)
|
incsearch bool (default off)
|
||||||
info []string (default '')
|
info []string (default '')
|
||||||
|
infotimefmtnew string (default 'Jan _2 15:04')
|
||||||
|
infotimefmtold string (default 'Jan _2 2006')
|
||||||
mouse bool (default off)
|
mouse bool (default off)
|
||||||
number bool (default off)
|
number bool (default off)
|
||||||
period int (default 0)
|
period int (default 0)
|
||||||
preview bool (default on)
|
preview bool (default on)
|
||||||
previewer string (default '')
|
previewer string (default '')
|
||||||
cleaner string (default '')
|
|
||||||
promptfmt string (default "\033[32;1m%u@%h\033[0m:\033[34;1m%d\033[0m\033[1m%f\033[0m")
|
promptfmt string (default "\033[32;1m%u@%h\033[0m:\033[34;1m%d\033[0m\033[1m%f\033[0m")
|
||||||
ratios []int (default '1:2:3')
|
ratios []int (default '1:2:3')
|
||||||
relativenumber bool (default off)
|
relativenumber bool (default off)
|
||||||
reverse bool (default off)
|
reverse bool (default off)
|
||||||
scrolloff int (default 0)
|
scrolloff int (default 0)
|
||||||
shell string (default 'sh' for unix and 'cmd' for windows)
|
shell string (default 'sh' for Unix and 'cmd' for Windows)
|
||||||
shellflag string (default '-c' for unix and '/c' for windows)
|
shellflag string (default '-c' for Unix and '/c' for Windows)
|
||||||
shellopts []string (default '')
|
shellopts []string (default '')
|
||||||
smartcase bool (default on)
|
smartcase bool (default on)
|
||||||
smartdia bool (default off)
|
smartdia bool (default off)
|
||||||
sortby string (default 'natural')
|
sortby string (default 'natural')
|
||||||
tabstop int (default 8)
|
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')
|
timefmt string (default 'Mon Jan _2 15:04:05 2006')
|
||||||
truncatechar string (default '~')
|
truncatechar string (default '~')
|
||||||
waitmsg string (default 'Press any key to continue')
|
waitmsg string (default 'Press any key to continue')
|
||||||
@@ -155,10 +172,22 @@ The following environment variables are exported for shell commands:
|
|||||||
EDITOR
|
EDITOR
|
||||||
PAGER
|
PAGER
|
||||||
SHELL
|
SHELL
|
||||||
|
lf_{option}
|
||||||
|
|
||||||
|
The following special shell commands are used to customize the behavior of
|
||||||
|
lf when defined:
|
||||||
|
|
||||||
|
open
|
||||||
|
paste
|
||||||
|
rename
|
||||||
|
delete
|
||||||
|
pre-cd
|
||||||
|
on-cd
|
||||||
|
on-quit
|
||||||
|
|
||||||
The following commands/keybindings are provided by default:
|
The following commands/keybindings are provided by default:
|
||||||
|
|
||||||
unix windows
|
Unix Windows
|
||||||
cmd open &$OPENER "$f" cmd open &%OPENER% %f%
|
cmd open &$OPENER "$f" cmd open &%OPENER% %f%
|
||||||
map e $$EDITOR "$f" map e $%EDITOR% %f%
|
map e $$EDITOR "$f" map e $%EDITOR% %f%
|
||||||
map i $$PAGER "$f" map i !%PAGER% %f%
|
map i $$PAGER "$f" map i !%PAGER% %f%
|
||||||
@@ -186,24 +215,41 @@ Configuration
|
|||||||
|
|
||||||
Configuration files should be located at:
|
Configuration files should be located at:
|
||||||
|
|
||||||
os system-wide user-specific
|
OS system-wide user-specific
|
||||||
unix /etc/lf/lfrc ~/.config/lf/lfrc
|
Unix /etc/lf/lfrc ~/.config/lf/lfrc
|
||||||
windows C:\ProgramData\lf\lfrc C:\Users\<user>\AppData\Local\lf\lfrc
|
Windows C:\ProgramData\lf\lfrc C:\Users\<user>\AppData\Local\lf\lfrc
|
||||||
|
|
||||||
|
Colors file should be located at:
|
||||||
|
|
||||||
|
OS system-wide user-specific
|
||||||
|
Unix /etc/lf/colors ~/.config/lf/colors
|
||||||
|
Windows C:\ProgramData\lf\colors C:\Users\<user>\AppData\Local\lf\colors
|
||||||
|
|
||||||
|
Icons file should be located at:
|
||||||
|
|
||||||
|
OS system-wide user-specific
|
||||||
|
Unix /etc/lf/icons ~/.config/lf/icons
|
||||||
|
Windows C:\ProgramData\lf\icons C:\Users\<user>\AppData\Local\lf\icons
|
||||||
|
|
||||||
Selection file should be located at:
|
Selection file should be located at:
|
||||||
|
|
||||||
unix ~/.local/share/lf/files
|
Unix ~/.local/share/lf/files
|
||||||
windows C:\Users\<user>\AppData\Local\lf\files
|
Windows C:\Users\<user>\AppData\Local\lf\files
|
||||||
|
|
||||||
Marks file should be located at:
|
Marks file should be located at:
|
||||||
|
|
||||||
unix ~/.local/share/lf/marks
|
Unix ~/.local/share/lf/marks
|
||||||
windows C:\Users\<user>\AppData\Local\lf\marks
|
Windows C:\Users\<user>\AppData\Local\lf\marks
|
||||||
|
|
||||||
|
Tags file should be located at:
|
||||||
|
|
||||||
|
Unix ~/.local/share/lf/tags
|
||||||
|
Windows C:\Users\<user>\AppData\Local\lf\tags
|
||||||
|
|
||||||
History file should be located at:
|
History file should be located at:
|
||||||
|
|
||||||
unix ~/.local/share/lf/history
|
Unix ~/.local/share/lf/history
|
||||||
windows C:\Users\<user>\AppData\Local\lf\history
|
Windows C:\Users\<user>\AppData\Local\lf\history
|
||||||
|
|
||||||
You can configure the default values of following variables to change these
|
You can configure the default values of following variables to change these
|
||||||
locations:
|
locations:
|
||||||
@@ -214,7 +260,7 @@ locations:
|
|||||||
%LOCALAPPDATA% C:\Users\<user>\AppData\Local
|
%LOCALAPPDATA% C:\Users\<user>\AppData\Local
|
||||||
|
|
||||||
A sample configuration file can be found at
|
A sample configuration file can be found at
|
||||||
https://github.com/gokcehan/lf/blob/master/etc/lfrc.example.
|
https://github.com/gokcehan/lf/blob/master/etc/lfrc.example
|
||||||
|
|
||||||
|
|
||||||
Commands
|
Commands
|
||||||
@@ -230,12 +276,14 @@ Quit lf and return to the shell.
|
|||||||
up (default 'k' and '<up>')
|
up (default 'k' and '<up>')
|
||||||
half-up (default '<c-u>')
|
half-up (default '<c-u>')
|
||||||
page-up (default '<c-b>' and '<pgup>')
|
page-up (default '<c-b>' and '<pgup>')
|
||||||
|
scroll-up (default '<c-y>')
|
||||||
down (default 'j' and '<down>')
|
down (default 'j' and '<down>')
|
||||||
half-down (default '<c-d>')
|
half-down (default '<c-d>')
|
||||||
page-down (default '<c-f>' and '<pgdn>')
|
page-down (default '<c-f>' and '<pgdn>')
|
||||||
|
scroll-down (default '<c-e>')
|
||||||
|
|
||||||
Move the current file selection upwards/downwards by one/half a page/full
|
Move/scroll the current file selection upwards/downwards by one/half a
|
||||||
page.
|
page/full page.
|
||||||
|
|
||||||
updir (default 'h' and '<left>')
|
updir (default 'h' and '<left>')
|
||||||
|
|
||||||
@@ -249,7 +297,10 @@ to call the default system opener asynchronously with the current file as
|
|||||||
the argument. A custom 'open' command can be defined to override this
|
the argument. A custom 'open' command can be defined to override this
|
||||||
default.
|
default.
|
||||||
|
|
||||||
(See also 'OPENER' variable and 'Opening Files' section)
|
jump-next (default ']')
|
||||||
|
jump-prev (default '[')
|
||||||
|
|
||||||
|
Change the current working directory to the next/previous jumplist item.
|
||||||
|
|
||||||
top (default 'gg' and '<home>')
|
top (default 'gg' and '<home>')
|
||||||
bottom (default 'G' and '<end>')
|
bottom (default 'G' and '<end>')
|
||||||
@@ -273,12 +324,15 @@ invert'), though this will also remove selections in other directories.
|
|||||||
Remove the selection of all files in all directories.
|
Remove the selection of all files in all directories.
|
||||||
|
|
||||||
glob-select
|
glob-select
|
||||||
|
|
||||||
Select files that match the given glob.
|
|
||||||
|
|
||||||
glob-unselect
|
glob-unselect
|
||||||
|
|
||||||
Unselect files that match the given glob.
|
Select/unselect files that match the given glob.
|
||||||
|
|
||||||
|
calcdirsize
|
||||||
|
|
||||||
|
Calculate the total size for each of the selected directories. Option 'info'
|
||||||
|
should include 'size' and option 'dircounts' should be disabled to show this
|
||||||
|
size.
|
||||||
|
|
||||||
copy (default 'y')
|
copy (default 'y')
|
||||||
|
|
||||||
@@ -292,7 +346,8 @@ buffer, otherwise, copy the paths of selected files.
|
|||||||
|
|
||||||
paste (default 'p')
|
paste (default 'p')
|
||||||
|
|
||||||
Copy/Move files in copy/cut buffer to the current working directory.
|
Copy/Move files in copy/cut buffer to the current working directory. A
|
||||||
|
custom 'paste' command can be defined to override this default.
|
||||||
|
|
||||||
clear (default 'c')
|
clear (default 'c')
|
||||||
|
|
||||||
@@ -331,7 +386,7 @@ file.
|
|||||||
|
|
||||||
echoerr
|
echoerr
|
||||||
|
|
||||||
Print given arguments to the message line at the bottom in red color and
|
Print given arguments to the message line at the bottom as 'errorfmt' and
|
||||||
also to the log file.
|
also to the log file.
|
||||||
|
|
||||||
cd
|
cd
|
||||||
@@ -344,7 +399,8 @@ Change the current file selection to the given argument.
|
|||||||
|
|
||||||
delete (modal)
|
delete (modal)
|
||||||
|
|
||||||
Remove the current file or selected file(s).
|
Remove the current file or selected file(s). A custom 'delete' command can
|
||||||
|
be defined to override this default.
|
||||||
|
|
||||||
rename (modal) (default 'r')
|
rename (modal) (default 'r')
|
||||||
|
|
||||||
@@ -367,24 +423,18 @@ Read a command to evaluate.
|
|||||||
|
|
||||||
Read a shell command to execute.
|
Read a shell command to execute.
|
||||||
|
|
||||||
(See also 'Prefixes' and 'Shell Commands' sections)
|
|
||||||
|
|
||||||
shell-pipe (modal) (default '%')
|
shell-pipe (modal) (default '%')
|
||||||
|
|
||||||
Read a shell command to execute piping its standard I/O to the bottom
|
Read a shell command to execute piping its standard I/O to the bottom
|
||||||
statline.
|
statline.
|
||||||
|
|
||||||
(See also 'Prefixes' and 'Piping Shell Commands' sections)
|
|
||||||
|
|
||||||
shell-wait (modal) (default '!')
|
shell-wait (modal) (default '!')
|
||||||
|
|
||||||
Read a shell command to execute and wait for a key press in the end.
|
Read a shell command to execute and wait for a key press in the end.
|
||||||
|
|
||||||
(See also 'Prefixes' and 'Waiting Shell Commands' sections)
|
|
||||||
|
|
||||||
shell-async (modal) (default '&')
|
shell-async (modal) (default '&')
|
||||||
|
|
||||||
Read a shell command to execute synchronously without standard I/O.
|
Read a shell command to execute asynchronously without standard I/O.
|
||||||
|
|
||||||
find (modal) (default 'f')
|
find (modal) (default 'f')
|
||||||
find-back (modal) (default 'F')
|
find-back (modal) (default 'F')
|
||||||
@@ -394,9 +444,6 @@ Read a shell command to execute synchronously without standard I/O.
|
|||||||
Read key(s) to find the appropriate file name match in the forward/backward
|
Read key(s) to find the appropriate file name match in the forward/backward
|
||||||
direction and jump to the next/previous match.
|
direction and jump to the next/previous match.
|
||||||
|
|
||||||
(See also 'anchorfind', 'findlen', 'wrapscan', 'ignorecase', 'smartcase',
|
|
||||||
'ignoredia', and 'smartdia' options and 'Searching Files' section)
|
|
||||||
|
|
||||||
search (default '/')
|
search (default '/')
|
||||||
search-back (default '?')
|
search-back (default '?')
|
||||||
search-next (default 'n')
|
search-next (default 'n')
|
||||||
@@ -405,8 +452,13 @@ direction and jump to the next/previous match.
|
|||||||
Read a pattern to search for a file name match in the forward/backward
|
Read a pattern to search for a file name match in the forward/backward
|
||||||
direction and jump to the next/previous match.
|
direction and jump to the next/previous match.
|
||||||
|
|
||||||
(See also 'globsearch', 'incsearch', 'wrapscan', 'ignorecase', 'smartcase',
|
filter (modal)
|
||||||
'ignoredia', and 'smartdia' options and 'Searching Files' section)
|
setfilter
|
||||||
|
|
||||||
|
Command 'filter' reads a pattern to filter out and only view files matching
|
||||||
|
the pattern. Command 'setfilter' does the same but uses an argument to set
|
||||||
|
the filter immediately. You can supply an argument to 'filter', in order to
|
||||||
|
use that as the starting prompt.
|
||||||
|
|
||||||
mark-save (modal) (default 'm')
|
mark-save (modal) (default 'm')
|
||||||
|
|
||||||
@@ -422,6 +474,17 @@ or 'select' command.
|
|||||||
|
|
||||||
Remove a bookmark assigned to the given key.
|
Remove a bookmark assigned to the given key.
|
||||||
|
|
||||||
|
tag
|
||||||
|
|
||||||
|
Tag a file with '*' or a single width character given in the argument. You
|
||||||
|
can define a new tag clearing command by combining 'tag' with 'tag-toggle'
|
||||||
|
(i.e. 'cmd tag-clear :tag; tag-toggle').
|
||||||
|
|
||||||
|
tag-toggle (default 't')
|
||||||
|
|
||||||
|
Tag a file with '*' or a single width character given in the argument if the
|
||||||
|
file is untagged, otherwise remove the tag.
|
||||||
|
|
||||||
|
|
||||||
Command Line Commands
|
Command Line Commands
|
||||||
|
|
||||||
@@ -439,14 +502,12 @@ Quit command line mode and return to normal mode.
|
|||||||
Autocomplete the current word.
|
Autocomplete the current word.
|
||||||
|
|
||||||
cmd-menu-complete
|
cmd-menu-complete
|
||||||
|
|
||||||
Autocomplete the current word, then you can press the binded key/s again to
|
|
||||||
cycle completition options.
|
|
||||||
|
|
||||||
cmd-menu-complete-back
|
cmd-menu-complete-back
|
||||||
|
|
||||||
Autocomplete the current word, then you can press the binded key/s again to
|
Autocomplete the current word with menu selection. You need to assign keys
|
||||||
cycle completition options backwards.
|
to these commands (e.g. 'cmap <tab> cmd-menu-complete; cmap <backtab>
|
||||||
|
cmd-menu-complete-back'). You can use the assigned keys assigned to display
|
||||||
|
the menu and then cycle through completion options.
|
||||||
|
|
||||||
cmd-enter (default '<c-j>' and '<enter>')
|
cmd-enter (default '<c-j>' and '<enter>')
|
||||||
|
|
||||||
@@ -525,6 +586,18 @@ beginning of file names, otherwise, it can match at an arbitrary position.
|
|||||||
|
|
||||||
Automatically quit server when there are no clients left connected.
|
Automatically quit server when there are no clients left connected.
|
||||||
|
|
||||||
|
cleaner string (default '') (not called if empty)
|
||||||
|
|
||||||
|
Set the path of a cleaner file. The file should be executable. This file is
|
||||||
|
called if previewing is enabled, the previewer is set, and the previously
|
||||||
|
selected file had its preview cache disabled. One argument is passed to the
|
||||||
|
file, path to the file whose preview should be cleaned. Preview clearing is
|
||||||
|
disabled when the value of this option is left empty.
|
||||||
|
|
||||||
|
dircache bool (default on)
|
||||||
|
|
||||||
|
Cache directory contents.
|
||||||
|
|
||||||
dircounts bool (default off)
|
dircounts bool (default off)
|
||||||
|
|
||||||
When this option is enabled, directory sizes show the number of items inside
|
When this option is enabled, directory sizes show the number of items inside
|
||||||
@@ -541,6 +614,10 @@ directories are shown as '999+'.
|
|||||||
|
|
||||||
Show directories first above regular files.
|
Show directories first above regular files.
|
||||||
|
|
||||||
|
dironly bool (default off)
|
||||||
|
|
||||||
|
Show only directories.
|
||||||
|
|
||||||
drawbox bool (default off)
|
drawbox bool (default off)
|
||||||
|
|
||||||
Draw boxes around panes with box drawing characters.
|
Draw boxes around panes with box drawing characters.
|
||||||
@@ -567,8 +644,8 @@ ranges. Otherwise, these characters are interpreted as they are.
|
|||||||
|
|
||||||
hidden bool (default off)
|
hidden bool (default off)
|
||||||
|
|
||||||
Show hidden files. On unix systems, hidden files are determined by the value
|
Show hidden files. On Unix systems, hidden files are determined by the value
|
||||||
of 'hiddenfiles'. On windows, only files with hidden attributes are
|
of 'hiddenfiles'. On Windows, only files with hidden attributes are
|
||||||
considered hidden files.
|
considered hidden files.
|
||||||
|
|
||||||
hiddenfiles []string (default '.*')
|
hiddenfiles []string (default '.*')
|
||||||
@@ -581,20 +658,16 @@ its matches are excluded from hidden files.
|
|||||||
|
|
||||||
icons bool (default off)
|
icons bool (default off)
|
||||||
|
|
||||||
Show icons before each item in the list. By default, only two icons, 🗀
|
Show icons before each item in the list.
|
||||||
(U+1F5C0) and 🗎 (U+1F5CE), are used for directories and files respectively,
|
|
||||||
as they are supported in the unicode standard. Icons can be configured with
|
|
||||||
an environment variable named 'LF_ICONS'. The syntax of this variable is
|
|
||||||
similar to 'LS_COLORS'. See the wiki page for an example icon configuration.
|
|
||||||
|
|
||||||
ifs string (default '')
|
ifs string (default '')
|
||||||
|
|
||||||
Sets 'IFS' variable in shell commands. It works by adding the assignment to
|
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
|
the beginning of the command string as "IFS='...'; ...". The reason is that
|
||||||
'IFS' variable is not inherited by the shell for security reasons. This
|
'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.
|
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
|
This option has no effect when the value is left empty. This option does not
|
||||||
have any effect on windows.
|
have any effect on Windows.
|
||||||
|
|
||||||
ignorecase bool (default on)
|
ignorecase bool (default on)
|
||||||
|
|
||||||
@@ -608,6 +681,10 @@ Ignore diacritics in sorting and search patterns.
|
|||||||
|
|
||||||
Jump to the first match after each keystroke during searching.
|
Jump to the first match after each keystroke during searching.
|
||||||
|
|
||||||
|
incfilter bool (default off)
|
||||||
|
|
||||||
|
Apply filter pattern after each keystroke during filtering.
|
||||||
|
|
||||||
info []string (default '')
|
info []string (default '')
|
||||||
|
|
||||||
List of information shown for directory items at the right side of pane.
|
List of information shown for directory items at the right side of pane.
|
||||||
@@ -615,6 +692,16 @@ Currently supported information types are 'size', 'time', 'atime', and
|
|||||||
'ctime'. Information is only shown when the pane width is more than twice
|
'ctime'. Information is only shown when the pane width is more than twice
|
||||||
the width of information.
|
the width of information.
|
||||||
|
|
||||||
|
infotimefmtnew string (default 'Jan _2 15:04')
|
||||||
|
|
||||||
|
Format string of the file time shown in the info column when it matches this
|
||||||
|
year.
|
||||||
|
|
||||||
|
infotimefmtold string (default 'Jan _2 2006')
|
||||||
|
|
||||||
|
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 off)
|
||||||
|
|
||||||
Send mouse events as input.
|
Send mouse events as input.
|
||||||
@@ -622,7 +709,7 @@ Send mouse events as input.
|
|||||||
number bool (default off)
|
number bool (default off)
|
||||||
|
|
||||||
Show the position number for directory items at the left side of pane. When
|
Show the position number for directory items at the left side of pane. When
|
||||||
'relativenumber' is enabled, only the current line shows the absolute
|
'relativenumber' option is enabled, only the current line shows the absolute
|
||||||
position and relative positions are shown for the rest.
|
position and relative positions are shown for the rest.
|
||||||
|
|
||||||
period int (default 0)
|
period int (default 0)
|
||||||
@@ -645,31 +732,23 @@ binary files and displayed as 'binary'.
|
|||||||
|
|
||||||
Set the path of a previewer file to filter the content of regular files for
|
Set the path of a previewer file to filter the content of regular files for
|
||||||
previewing. The file should be executable. Five arguments are passed to the
|
previewing. The file should be executable. Five arguments are passed to the
|
||||||
file, first is the current file name; the second, third, fourth, and fifth
|
file, (1) current file name, (2) width, (3) height, (4) horizontal position,
|
||||||
are width, height, horizontal position, and vertical position of preview
|
and (5) vertical position of preview pane respectively. SIGPIPE signal is
|
||||||
pane respectively. SIGPIPE signal is sent when enough lines are read. If the
|
sent when enough lines are read. If the previewer returns a non-zero exit
|
||||||
previewer returns a non-zero exit code, then the preview cache for the given
|
code, then the preview cache for the given file is disabled. This means that
|
||||||
file is disabled. This means that if the file is selected in the future, the
|
if the file is selected in the future, the previewer is called once again.
|
||||||
previewer is called once again. Preview filtering is disabled and files are
|
Preview filtering is disabled and files are displayed as they are when the
|
||||||
displayed as they are when the value of this option is left empty.
|
value of this option is left empty.
|
||||||
|
|
||||||
cleaner string (default '') (not called if empty)
|
|
||||||
|
|
||||||
Set the path of a cleaner file. This file will be called if previewing is
|
|
||||||
enabled, the previewer is set, and the previously selected file had its
|
|
||||||
preview cache disabled. The file should be executable. One argument is
|
|
||||||
passed to the file; the path to the file whose preview should be cleaned.
|
|
||||||
Preview clearing is disabled when the value of this option is left empty.
|
|
||||||
|
|
||||||
promptfmt string (default "\033[32;1m%u@%h\033[0m:\033[34;1m%d\033[0m\033[1m%f\033[0m")
|
promptfmt string (default "\033[32;1m%u@%h\033[0m:\033[34;1m%d\033[0m\033[1m%f\033[0m")
|
||||||
|
|
||||||
Format string of the prompt shown in the top line. Special expansions are
|
Format string of the prompt shown in the top line. Special expansions are
|
||||||
provided, '%u' as the user name, '%h' as the host name, '%w' as the working
|
provided, '%u' as the user name, '%h' as the host name, '%w' as the working
|
||||||
directory, '%d' as the working directory with a trailing path separator, and
|
directory, '%d' as the working directory with a trailing path separator,
|
||||||
'%f' as the file name. Home folder is shown as '~' in the working directory
|
'%f' as the file name, and '%F' as the current filter. Home folder is shown
|
||||||
expansion. Directory names are automatically shortened to a single character
|
as '~' in the working directory expansion. Directory names are automatically
|
||||||
starting from the left most parent when the prompt does not fit to the
|
shortened to a single character starting from the left most parent when the
|
||||||
screen.
|
prompt does not fit to the screen.
|
||||||
|
|
||||||
ratios []int (default '1:2:3')
|
ratios []int (default '1:2:3')
|
||||||
|
|
||||||
@@ -695,12 +774,12 @@ this option is set to a large value that is bigger than the half of number
|
|||||||
of lines. A smaller offset can be used when the current file is close to the
|
of lines. A smaller offset can be used when the current file is close to the
|
||||||
beginning or end of the list to show the maximum number of items.
|
beginning or end of the list to show the maximum number of items.
|
||||||
|
|
||||||
shell string (default 'sh' for unix and 'cmd' for windows)
|
shell string (default 'sh' for Unix and 'cmd' for Windows)
|
||||||
|
|
||||||
Shell executable to use for shell commands. Shell commands are executed as
|
Shell executable to use for shell commands. Shell commands are executed as
|
||||||
'shell shellopts shellflag command -- arguments'.
|
'shell shellopts shellflag command -- arguments'.
|
||||||
|
|
||||||
shellflag string (default '-c' for unix and '/c' for windows)
|
shellflag string (default '-c' for Unix and '/c' for Windows)
|
||||||
|
|
||||||
Command line flag used to pass shell commands.
|
Command line flag used to pass shell commands.
|
||||||
|
|
||||||
@@ -728,6 +807,17 @@ Sort type for directories. Currently supported sort types are 'natural',
|
|||||||
Number of space characters to show for horizontal tabulation (U+0009)
|
Number of space characters to show for horizontal tabulation (U+0009)
|
||||||
character.
|
character.
|
||||||
|
|
||||||
|
tagfmt string (default "\033[31m%s\033[0m")
|
||||||
|
|
||||||
|
Format string of the tags.
|
||||||
|
|
||||||
|
tempmarks string (default '')
|
||||||
|
|
||||||
|
Marks to be considered temporary (e.g. 'abc' refers to marks 'a', 'b', and
|
||||||
|
'c'). These marks are not synced to other clients and they are not saved in
|
||||||
|
the bookmarks file. Note that the special bookmark "'" is always treated as
|
||||||
|
temporary and it does not need to be specified.
|
||||||
|
|
||||||
timefmt string (default 'Mon Jan _2 15:04:05 2006')
|
timefmt string (default 'Mon Jan _2 15:04:05 2006')
|
||||||
|
|
||||||
Format string of the file modification time shown in the bottom line.
|
Format string of the file modification time shown in the bottom line.
|
||||||
@@ -800,17 +890,53 @@ set the value to 'start' in Windows, 'open' in MacOS, 'xdg-open' in others.
|
|||||||
EDITOR
|
EDITOR
|
||||||
|
|
||||||
If this variable is set in the environment, use the same value, otherwise
|
If this variable is set in the environment, use the same value, otherwise
|
||||||
set the value to 'vi' on unix, 'notepad' in Windows.
|
set the value to 'vi' on Unix, 'notepad' in Windows.
|
||||||
|
|
||||||
PAGER
|
PAGER
|
||||||
|
|
||||||
If this variable is set in the environment, use the same value, otherwise
|
If this variable is set in the environment, use the same value, otherwise
|
||||||
set the value to 'less' on unix, 'more' in Windows.
|
set the value to 'less' on Unix, 'more' in Windows.
|
||||||
|
|
||||||
SHELL
|
SHELL
|
||||||
|
|
||||||
If this variable is set in the environment, use the same value, otherwise
|
If this variable is set in the environment, use the same value, otherwise
|
||||||
set the value to 'sh' on unix, 'cmd' in Windows.
|
set the value to 'sh' on Unix, 'cmd' in Windows.
|
||||||
|
|
||||||
|
lf_{option}
|
||||||
|
|
||||||
|
Value of the {option}.
|
||||||
|
|
||||||
|
Special Commands
|
||||||
|
|
||||||
|
open
|
||||||
|
|
||||||
|
This shell command can be defined to override the default 'open' command
|
||||||
|
when the current file is not a directory.
|
||||||
|
|
||||||
|
paste
|
||||||
|
|
||||||
|
This shell command can be defined to override the default 'paste' command.
|
||||||
|
|
||||||
|
rename
|
||||||
|
|
||||||
|
This shell command can be defined to override the default 'paste' command.
|
||||||
|
|
||||||
|
delete
|
||||||
|
|
||||||
|
This shell command can be defined to override the default 'delete' command.
|
||||||
|
|
||||||
|
pre-cd
|
||||||
|
|
||||||
|
This shell command can be defined to be executed before changing a
|
||||||
|
directory.
|
||||||
|
|
||||||
|
on-cd
|
||||||
|
|
||||||
|
This shell command can be defined to be executed after changing a directory.
|
||||||
|
|
||||||
|
on-quit
|
||||||
|
|
||||||
|
This shell command can be defined to be executed before quit.
|
||||||
|
|
||||||
|
|
||||||
Prefixes
|
Prefixes
|
||||||
@@ -836,8 +962,8 @@ Characters from '#' to newline are comments and ignored:
|
|||||||
|
|
||||||
# comments start with '#'
|
# comments start with '#'
|
||||||
|
|
||||||
There are three special commands ('set', 'map', and 'cmd') and their
|
There are three special commands ('set', 'map', 'cmap', and 'cmd') for
|
||||||
variants for configuration.
|
configuration.
|
||||||
|
|
||||||
Command 'set' is used to set an option which can be boolean, integer, or
|
Command 'set' is used to set an option which can be boolean, integer, or
|
||||||
string:
|
string:
|
||||||
@@ -1047,7 +1173,7 @@ commands.
|
|||||||
|
|
||||||
Instead of pausing the ui, piping shell commands connects stdin, stdout, and
|
Instead of pausing the ui, piping shell commands connects stdin, stdout, and
|
||||||
stderr of the command to the statline in the bottom of the ui. This can be
|
stderr of the command to the statline in the bottom of the ui. This can be
|
||||||
useful for programs following the unix philosophy to give no output in the
|
useful for programs following the Unix philosophy to give no output in the
|
||||||
success case, and brief error messages or prompts in other cases.
|
success case, and brief error messages or prompts in other cases.
|
||||||
|
|
||||||
For example, following rename command prompts for overwrite in the statline
|
For example, following rename command prompts for overwrite in the statline
|
||||||
@@ -1088,10 +1214,10 @@ any of the connected clients over the common server. This is used internally
|
|||||||
to notify file selection changes to other clients.
|
to notify file selection changes to other clients.
|
||||||
|
|
||||||
To use this feature, you need to use a client which supports communicating
|
To use this feature, you need to use a client which supports communicating
|
||||||
with a UNIX-domain socket. OpenBSD implementation of netcat (nc) is one such
|
with a Unix domain socket. OpenBSD implementation of netcat (nc) is one such
|
||||||
example. You can use it to send a command to the socket file:
|
example. You can use it to send a command to the socket file:
|
||||||
|
|
||||||
echo 'send echo hello world' | nc -U /tmp/lf.${USER}.sock
|
echo 'send echo hello world' | nc -U ${XDG_RUNTIME_DIR:-/tmp}/lf.${USER}.sock
|
||||||
|
|
||||||
Since such a client may not be available everywhere, lf comes bundled with a
|
Since such a client may not be available everywhere, lf comes bundled with a
|
||||||
command line flag to be used as such. When using lf, you do not need to
|
command line flag to be used as such. When using lf, you do not need to
|
||||||
@@ -1178,9 +1304,9 @@ point:
|
|||||||
cp -R $list .
|
cp -R $list .
|
||||||
elif [ $mode = 'move' ]; then
|
elif [ $mode = 'move' ]; then
|
||||||
mv $list .
|
mv $list .
|
||||||
fi
|
|
||||||
rm ~/.local/share/lf/files
|
rm ~/.local/share/lf/files
|
||||||
lf -remote 'send clear'
|
lf -remote 'send clear'
|
||||||
|
fi
|
||||||
}}
|
}}
|
||||||
|
|
||||||
Some useful things to be considered are to use the backup ('--backup')
|
Some useful things to be considered are to use the backup ('--backup')
|
||||||
@@ -1279,22 +1405,22 @@ Previewing Files
|
|||||||
lf previews files on the preview pane by printing the file until the end or
|
lf previews files on the preview pane by printing the file until the end or
|
||||||
the preview pane is filled. This output can be enhanced by providing a
|
the preview pane is filled. This output can be enhanced by providing a
|
||||||
custom preview script for filtering. This can be used to highlight source
|
custom preview script for filtering. This can be used to highlight source
|
||||||
codes, list contents of archive files or view pdf or image files as text to
|
codes, list contents of archive files or view pdf or image files to name
|
||||||
name few. For coloring lf recognizes ansi escape codes.
|
few. For coloring lf recognizes ansi escape codes.
|
||||||
|
|
||||||
In order to use this feature you need to set the value of 'previewer' option
|
In order to use this feature you need to set the value of 'previewer' option
|
||||||
to the path of an executable file. lf passes the current file name as the
|
to the path of an executable file. Five arguments are passed to the file,
|
||||||
first argument and the height of the preview pane as the second argument
|
(1) current file name, (2) width, (3) height, (4) horizontal position, and
|
||||||
when running this file. Output of the execution is printed in the preview
|
(5) vertical position of preview pane respectively. Output of the execution
|
||||||
pane. You may want to use the same script in your pager mapping as well if
|
is printed in the preview pane. You may also want to use the same script in
|
||||||
any:
|
your pager mapping as well:
|
||||||
|
|
||||||
set previewer ~/.config/lf/pv.sh
|
set previewer ~/.config/lf/pv.sh
|
||||||
map i $~/.config/lf/pv.sh $f | less -R
|
map i $~/.config/lf/pv.sh $f | less -R
|
||||||
|
|
||||||
For 'less' pager, you may instead utilize 'LESSOPEN' mechanism so that
|
For 'less' pager, you may instead utilize 'LESSOPEN' mechanism so that
|
||||||
useful information about the file such as the full path of the file can be
|
useful information about the file such as the full path of the file can
|
||||||
displayed in the statusline below:
|
still be displayed in the statusline below:
|
||||||
|
|
||||||
set previewer ~/.config/lf/pv.sh
|
set previewer ~/.config/lf/pv.sh
|
||||||
map i $LESSOPEN='| ~/.config/lf/pv.sh %s' less -R $f
|
map i $LESSOPEN='| ~/.config/lf/pv.sh %s' less -R $f
|
||||||
@@ -1343,8 +1469,8 @@ lf changes the working directory of the process to the current directory so
|
|||||||
that shell commands always work in the displayed directory. After quitting,
|
that shell commands always work in the displayed directory. After quitting,
|
||||||
it returns to the original directory where it is first launched like all
|
it returns to the original directory where it is first launched like all
|
||||||
shell programs. If you want to stay in the current directory after quitting,
|
shell programs. If you want to stay in the current directory after quitting,
|
||||||
you can use one of the example wrapper shell scripts provided in the
|
you can use one of the example lfcd wrapper shell scripts provided in the
|
||||||
repository.
|
repository at https://github.com/gokcehan/lf/tree/master/etc
|
||||||
|
|
||||||
There is a special command 'on-cd' that runs a shell command when it is
|
There is a special command 'on-cd' that runs a shell command when it is
|
||||||
defined and the directory is changed. You can define it just as you would
|
defined and the directory is changed. You can define it just as you would
|
||||||
@@ -1373,12 +1499,15 @@ title to the working directory:
|
|||||||
This command runs whenever you change directory but not on startup. You can
|
This command runs whenever you change directory but not on startup. You can
|
||||||
add an extra call to make it run on startup as well:
|
add an extra call to make it run on startup as well:
|
||||||
|
|
||||||
cmd on-cd &{{ # ... }}
|
cmd on-cd &{{ ... }}
|
||||||
on-cd
|
on-cd
|
||||||
|
|
||||||
Note that all shell commands are possible but '%' and '&' are usually more
|
Note that all shell commands are possible but '%' and '&' are usually more
|
||||||
appropriate as '$' and '!' causes flickers and pauses respectively.
|
appropriate as '$' and '!' causes flickers and pauses respectively.
|
||||||
|
|
||||||
|
There is also a 'pre-cd' command, that works like 'on-cd', but is run before
|
||||||
|
the directory is actually changed.
|
||||||
|
|
||||||
|
|
||||||
Colors
|
Colors
|
||||||
|
|
||||||
@@ -1391,12 +1520,16 @@ are set in the following order:
|
|||||||
2. LSCOLORS (Mac/BSD ls)
|
2. LSCOLORS (Mac/BSD ls)
|
||||||
3. LS_COLORS (GNU ls)
|
3. LS_COLORS (GNU ls)
|
||||||
4. LF_COLORS (lf specific)
|
4. LF_COLORS (lf specific)
|
||||||
|
5. colors file (lf specific)
|
||||||
|
|
||||||
Please refer to the corresponding man pages for more information about
|
Please refer to the corresponding man pages for more information about
|
||||||
'LSCOLORS' and 'LS_COLORS'. 'LF_COLORS' is provided with the same syntax as
|
'LSCOLORS' and 'LS_COLORS'. 'LF_COLORS' is provided with the same syntax as
|
||||||
'LS_COLORS' in case you want to configure colors only for lf but not ls.
|
'LS_COLORS' in case you want to configure colors only for lf but not ls.
|
||||||
This can be useful since there are some differences between ls and lf,
|
This can be useful since there are some differences between ls and lf,
|
||||||
though one should expect the same behavior for common cases.
|
though one should expect the same behavior for common cases. Colors file is
|
||||||
|
provided for easier configuration without environment variables. This file
|
||||||
|
should consist of whitespace separated pairs with '#' character to start
|
||||||
|
comments until the end of line.
|
||||||
|
|
||||||
You can configure lf colors in two different ways. First, you can only
|
You can configure lf colors in two different ways. First, you can only
|
||||||
configure 8 basic colors used by your terminal and lf should pick up those
|
configure 8 basic colors used by your terminal and lf should pick up those
|
||||||
@@ -1404,11 +1537,11 @@ colors automatically. Depending on your terminal, you should be able to
|
|||||||
select your colors from a 24-bit palette. This is the recommended approach
|
select your colors from a 24-bit palette. This is the recommended approach
|
||||||
as colors used by other programs will also match each other.
|
as colors used by other programs will also match each other.
|
||||||
|
|
||||||
Second, you can set the values of environmental variables mentioned above
|
Second, you can set the values of environment variables or colors file
|
||||||
for fine grained customization. Note that 'LS_COLORS/LF_COLORS' are more
|
mentioned above for fine grained customization. Note that
|
||||||
powerful than 'LSCOLORS' and they can be used even when GNU programs are not
|
'LS_COLORS/LF_COLORS' are more powerful than 'LSCOLORS' and they can be used
|
||||||
installed on the system. You can combine this second method with the first
|
even when GNU programs are not installed on the system. You can combine this
|
||||||
method for best results.
|
second method with the first method for best results.
|
||||||
|
|
||||||
Lastly, you may also want to configure the colors of the prompt line to
|
Lastly, you may also want to configure the colors of the prompt line to
|
||||||
match the rest of the colors. Colors of the prompt line can be configured
|
match the rest of the colors. Colors of the prompt line can be configured
|
||||||
@@ -1416,13 +1549,13 @@ using the 'promptfmt' option which can include hardcoded colors as ansi
|
|||||||
escapes. See the default value of this option to have an idea about how to
|
escapes. See the default value of this option to have an idea about how to
|
||||||
color this line.
|
color this line.
|
||||||
|
|
||||||
It is worth noting that lf uses as many colors are advertised by your
|
It is worth noting that lf uses as many colors advertised by your terminal's
|
||||||
terminal's entry in your systems terminfo or infocmp database, if this is
|
entry in terminfo or infocmp databases on your system. If an entry is not
|
||||||
not present lf will default to an internal database. For terminals
|
present, it falls back to an internal database. If your terminal supports
|
||||||
supporting 24-bit (or "true") color that do not have a database entry (or
|
24-bit colors but either does not have a database entry or does not
|
||||||
one that does not advertise all capabilities), support can be enabled by
|
advertise all capabilities, you can enable support by setting the
|
||||||
either setting the '$COLORTERM' variable to "truecolor" or ensuring '$TERM'
|
'$COLORTERM' variable to 'truecolor' or ensuring '$TERM' is set to a value
|
||||||
is set to a value that ends with "-truecolor".
|
that ends with '-truecolor'.
|
||||||
|
|
||||||
Default lf colors are mostly taken from GNU dircolors defaults. These
|
Default lf colors are mostly taken from GNU dircolors defaults. These
|
||||||
defaults use 8 basic colors and bold attribute. Default dircolors entries
|
defaults use 8 basic colors and bold attribute. Default dircolors entries
|
||||||
@@ -1446,17 +1579,18 @@ with their matching order in lf:
|
|||||||
ex 01;32
|
ex 01;32
|
||||||
fi 00
|
fi 00
|
||||||
|
|
||||||
Note that, lf first tries matching file names and then falls back to file
|
Note that lf first tries matching file names and then falls back to file
|
||||||
types. The full order of matchings from most specific to least are as
|
types. The full order of matchings from most specific to least are as
|
||||||
follows:
|
follows:
|
||||||
|
|
||||||
1. Full Path (e.g. '~/.config/lf/lfrc')
|
1. Full Path (e.g. '~/.config/lf/lfrc')
|
||||||
2. Dir Name (e.g. '.git/') (only matches dirs with a trailing slash at the end)
|
2. Dir Name (e.g. '.git/') (only matches dirs with a trailing slash at the end)
|
||||||
3. File Type (e.g. 'ln') (except 'fi')
|
3. File Type (e.g. 'ln') (except 'fi')
|
||||||
4. File Name (e.g. '.git*') (only matches files with a trailing star at the end)
|
4. File Name (e.g. 'README*')
|
||||||
5. Base Name (e.g. 'README.*')
|
5. File Name (e.g. '*README')
|
||||||
6. Extension (e.g. '*.txt')
|
6. Base Name (e.g. 'README.*')
|
||||||
7. Default (i.e. 'fi')
|
7. Extension (e.g. '*.txt')
|
||||||
|
8. Default (i.e. 'fi')
|
||||||
|
|
||||||
For example, given a regular text file '/path/to/README.txt', the following
|
For example, given a regular text file '/path/to/README.txt', the following
|
||||||
entries are checked in the configuration and the first one to match is used:
|
entries are checked in the configuration and the first one to match is used:
|
||||||
@@ -1465,9 +1599,10 @@ entries are checked in the configuration and the first one to match is used:
|
|||||||
2. (skipped since the file is not a directory)
|
2. (skipped since the file is not a directory)
|
||||||
3. (skipped since the file is of type 'fi')
|
3. (skipped since the file is of type 'fi')
|
||||||
4. 'README.txt*'
|
4. 'README.txt*'
|
||||||
5. 'README.*'
|
5. '*README.txt'
|
||||||
6. '*.txt'
|
6. 'README.*'
|
||||||
7. 'fi'
|
7. '*.txt'
|
||||||
|
8. 'fi'
|
||||||
|
|
||||||
Given a regular directory '/path/to/example.d', the following entries are
|
Given a regular directory '/path/to/example.d', the following entries are
|
||||||
checked in the configuration and the first one to match is used:
|
checked in the configuration and the first one to match is used:
|
||||||
@@ -1476,16 +1611,17 @@ checked in the configuration and the first one to match is used:
|
|||||||
2. 'example.d/'
|
2. 'example.d/'
|
||||||
3. 'di'
|
3. 'di'
|
||||||
4. 'example.d*'
|
4. 'example.d*'
|
||||||
5. 'example.*'
|
5. '*example.d'
|
||||||
6. '*.d'
|
6. 'example.*'
|
||||||
7. 'fi'
|
7. '*.d'
|
||||||
|
8. 'fi'
|
||||||
|
|
||||||
Note that glob-like patterns do not actually perform glob matching due to
|
Note that glob-like patterns do not actually perform glob matching due to
|
||||||
performance reasons.
|
performance reasons.
|
||||||
|
|
||||||
For example, you can set a variable as follows:
|
For example, you can set a variable as follows:
|
||||||
|
|
||||||
export LF_COLORS="~/Documents=01;31:~/Downloads=01;31:~/.local/share=01;31:~/.config/lf/lfrc=31:.git/=01;32:.git=32:.gitignore=32:Makefile=32:README.*=33:*.txt=34:*.md=34:ln=01;36:di=01;34:ex=01;32:"
|
export LF_COLORS="~/Documents=01;31:~/Downloads=01;31:~/.local/share=01;31:~/.config/lf/lfrc=31:.git/=01;32:.git*=32:*.gitignore=32:*Makefile=32:README.*=33:*.txt=34:*.md=34:ln=01;36:di=01;34:ex=01;32:"
|
||||||
|
|
||||||
Having all entries on a single line can make it hard to read. You may
|
Having all entries on a single line can make it hard to read. You may
|
||||||
instead divide it to multiple lines in between double quotes by escaping
|
instead divide it to multiple lines in between double quotes by escaping
|
||||||
@@ -1497,9 +1633,9 @@ newlines with backslashes as follows:
|
|||||||
~/.local/share=01;31:\
|
~/.local/share=01;31:\
|
||||||
~/.config/lf/lfrc=31:\
|
~/.config/lf/lfrc=31:\
|
||||||
.git/=01;32:\
|
.git/=01;32:\
|
||||||
.git=32:\
|
.git*=32:\
|
||||||
.gitignore=32:\
|
*.gitignore=32:\
|
||||||
Makefile=32:\
|
*Makefile=32:\
|
||||||
README.*=33:\
|
README.*=33:\
|
||||||
*.txt=34:\
|
*.txt=34:\
|
||||||
*.md=34:\
|
*.md=34:\
|
||||||
@@ -1509,38 +1645,38 @@ newlines with backslashes as follows:
|
|||||||
"
|
"
|
||||||
|
|
||||||
Having such a long variable definition in a shell configuration file might
|
Having such a long variable definition in a shell configuration file might
|
||||||
be undesirable. You may instead put this definition in a separate file and
|
be undesirable. You may instead use the colors file for configuration. A
|
||||||
source it in your shell configuration file as follows:
|
sample colors file can be found at
|
||||||
|
https://github.com/gokcehan/lf/blob/master/etc/colors.example You may also
|
||||||
[ -f "/path/to/colors" ] && source "/path/to/colors"
|
see the wiki page for ansi escape codes
|
||||||
|
https://en.wikipedia.org/wiki/ANSI_escape_code
|
||||||
See the wiki page for ansi escape codes
|
|
||||||
https://en.wikipedia.org/wiki/ANSI_escape_code.
|
|
||||||
|
|
||||||
|
|
||||||
Icons
|
Icons
|
||||||
|
|
||||||
Icons are configured using 'LF_ICONS' environment variable. This variable
|
Icons are configured using 'LF_ICONS' environment variable or an icons file.
|
||||||
uses the same syntax as 'LS_COLORS/LF_COLORS'. Instead of colors, you should
|
The variable uses the same syntax as 'LS_COLORS/LF_COLORS'. Instead of
|
||||||
put a single characters as values of entries. Do not forget to enable
|
colors, you should put a single characters as values of entries. Icons file
|
||||||
'icons' option to see the icons. Default values are as follows given with
|
should consist of whitespace separated pairs with '#' character to start
|
||||||
their matching order in lf:
|
comments until the end of line. Do not forget to enable 'icons' option to
|
||||||
|
see the icons. Default values are as follows given with their matching order
|
||||||
|
in lf:
|
||||||
|
|
||||||
ln 🗎
|
ln l
|
||||||
or 🗎
|
or l
|
||||||
tw 🗀
|
tw t
|
||||||
ow 🗀
|
ow d
|
||||||
st 🗀
|
st t
|
||||||
di 🗀
|
di d
|
||||||
pi 🗎
|
pi p
|
||||||
so 🗎
|
so s
|
||||||
bd 🗎
|
bd b
|
||||||
cd 🗎
|
cd c
|
||||||
su 🗎
|
su u
|
||||||
sg 🗎
|
sg g
|
||||||
ex 🗎
|
ex x
|
||||||
fi 🗎
|
fi -
|
||||||
|
|
||||||
See the wiki page for an example icons configuration
|
A sample icons file can be found at
|
||||||
https://github.com/gokcehan/lf/wiki/Icons.
|
https://github.com/gokcehan/lf/blob/master/etc/icons.example
|
||||||
`
|
`
|
||||||
@@ -0,0 +1,174 @@
|
|||||||
|
# vim:ft=dircolors
|
||||||
|
# (This is not a dircolors file but it helps to highlight colors and comments)
|
||||||
|
|
||||||
|
# default values from dircolors
|
||||||
|
# (entries with a leading # are not implemented in lf)
|
||||||
|
# #no 00 # NORMAL
|
||||||
|
# fi 00 # FILE
|
||||||
|
# #rs 0 # RESET
|
||||||
|
# di 01;34 # DIR
|
||||||
|
# ln 01;36 # LINK
|
||||||
|
# #mh 00 # MULTIHARDLINK
|
||||||
|
# pi 40;33 # FIFO
|
||||||
|
# so 01;35 # SOCK
|
||||||
|
# #do 01;35 # DOOR
|
||||||
|
# bd 40;33;01 # BLK
|
||||||
|
# cd 40;33;01 # CHR
|
||||||
|
# or 40;31;01 # ORPHAN
|
||||||
|
# #mi 00 # MISSING
|
||||||
|
# su 37;41 # SETUID
|
||||||
|
# sg 30;43 # SETGID
|
||||||
|
# #ca 30;41 # CAPABILITY
|
||||||
|
# tw 30;42 # STICKY_OTHER_WRITABLE
|
||||||
|
# ow 34;42 # OTHER_WRITABLE
|
||||||
|
# st 37;44 # STICKY
|
||||||
|
# ex 01;32 # EXEC
|
||||||
|
|
||||||
|
# default values from lf (with matching order)
|
||||||
|
# ln 01;36 # LINK
|
||||||
|
# or 31;01 # ORPHAN
|
||||||
|
# tw 01;34 # STICKY_OTHER_WRITABLE
|
||||||
|
# ow 01;34 # OTHER_WRITABLE
|
||||||
|
# st 01;34 # STICKY
|
||||||
|
# di 01;34 # DIR
|
||||||
|
# pi 33 # FIFO
|
||||||
|
# so 01;35 # SOCK
|
||||||
|
# bd 33;01 # BLK
|
||||||
|
# cd 33;01 # CHR
|
||||||
|
# su 01;32 # SETUID
|
||||||
|
# sg 01;32 # SETGID
|
||||||
|
# ex 01;32 # EXEC
|
||||||
|
# fi 00 # FILE
|
||||||
|
|
||||||
|
# file types (with matching order)
|
||||||
|
ln 01;36 # LINK
|
||||||
|
or 31;01 # ORPHAN
|
||||||
|
tw 34 # STICKY_OTHER_WRITABLE
|
||||||
|
ow 34 # OTHER_WRITABLE
|
||||||
|
st 01;34 # STICKY
|
||||||
|
di 01;34 # DIR
|
||||||
|
pi 33 # FIFO
|
||||||
|
so 01;35 # SOCK
|
||||||
|
bd 33;01 # BLK
|
||||||
|
cd 33;01 # CHR
|
||||||
|
su 01;32 # SETUID
|
||||||
|
sg 01;32 # SETGID
|
||||||
|
ex 01;32 # EXEC
|
||||||
|
fi 00 # FILE
|
||||||
|
|
||||||
|
# archives or compressed (dircolors defaults)
|
||||||
|
*.tar 01;31
|
||||||
|
*.tgz 01;31
|
||||||
|
*.arc 01;31
|
||||||
|
*.arj 01;31
|
||||||
|
*.taz 01;31
|
||||||
|
*.lha 01;31
|
||||||
|
*.lz4 01;31
|
||||||
|
*.lzh 01;31
|
||||||
|
*.lzma 01;31
|
||||||
|
*.tlz 01;31
|
||||||
|
*.txz 01;31
|
||||||
|
*.tzo 01;31
|
||||||
|
*.t7z 01;31
|
||||||
|
*.zip 01;31
|
||||||
|
*.z 01;31
|
||||||
|
*.dz 01;31
|
||||||
|
*.gz 01;31
|
||||||
|
*.lrz 01;31
|
||||||
|
*.lz 01;31
|
||||||
|
*.lzo 01;31
|
||||||
|
*.xz 01;31
|
||||||
|
*.zst 01;31
|
||||||
|
*.tzst 01;31
|
||||||
|
*.bz2 01;31
|
||||||
|
*.bz 01;31
|
||||||
|
*.tbz 01;31
|
||||||
|
*.tbz2 01;31
|
||||||
|
*.tz 01;31
|
||||||
|
*.deb 01;31
|
||||||
|
*.rpm 01;31
|
||||||
|
*.jar 01;31
|
||||||
|
*.war 01;31
|
||||||
|
*.ear 01;31
|
||||||
|
*.sar 01;31
|
||||||
|
*.rar 01;31
|
||||||
|
*.alz 01;31
|
||||||
|
*.ace 01;31
|
||||||
|
*.zoo 01;31
|
||||||
|
*.cpio 01;31
|
||||||
|
*.7z 01;31
|
||||||
|
*.rz 01;31
|
||||||
|
*.cab 01;31
|
||||||
|
*.wim 01;31
|
||||||
|
*.swm 01;31
|
||||||
|
*.dwm 01;31
|
||||||
|
*.esd 01;31
|
||||||
|
|
||||||
|
# image formats (dircolors defaults)
|
||||||
|
*.jpg 01;35
|
||||||
|
*.jpeg 01;35
|
||||||
|
*.mjpg 01;35
|
||||||
|
*.mjpeg 01;35
|
||||||
|
*.gif 01;35
|
||||||
|
*.bmp 01;35
|
||||||
|
*.pbm 01;35
|
||||||
|
*.pgm 01;35
|
||||||
|
*.ppm 01;35
|
||||||
|
*.tga 01;35
|
||||||
|
*.xbm 01;35
|
||||||
|
*.xpm 01;35
|
||||||
|
*.tif 01;35
|
||||||
|
*.tiff 01;35
|
||||||
|
*.png 01;35
|
||||||
|
*.svg 01;35
|
||||||
|
*.svgz 01;35
|
||||||
|
*.mng 01;35
|
||||||
|
*.pcx 01;35
|
||||||
|
*.mov 01;35
|
||||||
|
*.mpg 01;35
|
||||||
|
*.mpeg 01;35
|
||||||
|
*.m2v 01;35
|
||||||
|
*.mkv 01;35
|
||||||
|
*.webm 01;35
|
||||||
|
*.ogm 01;35
|
||||||
|
*.mp4 01;35
|
||||||
|
*.m4v 01;35
|
||||||
|
*.mp4v 01;35
|
||||||
|
*.vob 01;35
|
||||||
|
*.qt 01;35
|
||||||
|
*.nuv 01;35
|
||||||
|
*.wmv 01;35
|
||||||
|
*.asf 01;35
|
||||||
|
*.rm 01;35
|
||||||
|
*.rmvb 01;35
|
||||||
|
*.flc 01;35
|
||||||
|
*.avi 01;35
|
||||||
|
*.fli 01;35
|
||||||
|
*.flv 01;35
|
||||||
|
*.gl 01;35
|
||||||
|
*.dl 01;35
|
||||||
|
*.xcf 01;35
|
||||||
|
*.xwd 01;35
|
||||||
|
*.yuv 01;35
|
||||||
|
*.cgm 01;35
|
||||||
|
*.emf 01;35
|
||||||
|
*.ogv 01;35
|
||||||
|
*.ogx 01;35
|
||||||
|
|
||||||
|
# audio formats (dircolors defaults)
|
||||||
|
*.aac 00;36
|
||||||
|
*.au 00;36
|
||||||
|
*.flac 00;36
|
||||||
|
*.m4a 00;36
|
||||||
|
*.mid 00;36
|
||||||
|
*.midi 00;36
|
||||||
|
*.mka 00;36
|
||||||
|
*.mp3 00;36
|
||||||
|
*.mpc 00;36
|
||||||
|
*.ogg 00;36
|
||||||
|
*.ra 00;36
|
||||||
|
*.wav 00;36
|
||||||
|
*.oga 00;36
|
||||||
|
*.opus 00;36
|
||||||
|
*.spx 00;36
|
||||||
|
*.xspf 00;36
|
||||||
@@ -0,0 +1,357 @@
|
|||||||
|
# vim:ft=conf
|
||||||
|
|
||||||
|
# These examples require Nerd Fonts or a compatible font to be used.
|
||||||
|
# See https://www.nerdfonts.com for more information.
|
||||||
|
|
||||||
|
# default values from lf (with matching order)
|
||||||
|
# ln l # LINK
|
||||||
|
# or l # ORPHAN
|
||||||
|
# tw t # STICKY_OTHER_WRITABLE
|
||||||
|
# ow d # OTHER_WRITABLE
|
||||||
|
# st t # STICKY
|
||||||
|
# di d # DIR
|
||||||
|
# pi p # FIFO
|
||||||
|
# so s # SOCK
|
||||||
|
# bd b # BLK
|
||||||
|
# cd c # CHR
|
||||||
|
# su u # SETUID
|
||||||
|
# sg g # SETGID
|
||||||
|
# ex x # EXEC
|
||||||
|
# fi - # FILE
|
||||||
|
|
||||||
|
# file types (with matching order)
|
||||||
|
ln # LINK
|
||||||
|
or # ORPHAN
|
||||||
|
tw t # STICKY_OTHER_WRITABLE
|
||||||
|
ow # OTHER_WRITABLE
|
||||||
|
st t # STICKY
|
||||||
|
di # DIR
|
||||||
|
pi p # FIFO
|
||||||
|
so s # SOCK
|
||||||
|
bd b # BLK
|
||||||
|
cd c # CHR
|
||||||
|
su u # SETUID
|
||||||
|
sg g # SETGID
|
||||||
|
ex # EXEC
|
||||||
|
fi # FILE
|
||||||
|
|
||||||
|
# file extensions (vim-devicons)
|
||||||
|
*.styl
|
||||||
|
*.sass
|
||||||
|
*.scss
|
||||||
|
*.htm
|
||||||
|
*.html
|
||||||
|
*.slim
|
||||||
|
*.haml
|
||||||
|
*.ejs
|
||||||
|
*.css
|
||||||
|
*.less
|
||||||
|
*.md
|
||||||
|
*.mdx
|
||||||
|
*.markdown
|
||||||
|
*.rmd
|
||||||
|
*.json
|
||||||
|
*.webmanifest
|
||||||
|
*.js
|
||||||
|
*.mjs
|
||||||
|
*.jsx
|
||||||
|
*.rb
|
||||||
|
*.gemspec
|
||||||
|
*.rake
|
||||||
|
*.php
|
||||||
|
*.py
|
||||||
|
*.pyc
|
||||||
|
*.pyo
|
||||||
|
*.pyd
|
||||||
|
*.coffee
|
||||||
|
*.mustache
|
||||||
|
*.hbs
|
||||||
|
*.conf
|
||||||
|
*.ini
|
||||||
|
*.yml
|
||||||
|
*.yaml
|
||||||
|
*.toml
|
||||||
|
*.bat
|
||||||
|
*.mk
|
||||||
|
*.jpg
|
||||||
|
*.jpeg
|
||||||
|
*.bmp
|
||||||
|
*.png
|
||||||
|
*.webp
|
||||||
|
*.gif
|
||||||
|
*.ico
|
||||||
|
*.twig
|
||||||
|
*.cpp
|
||||||
|
*.c++
|
||||||
|
*.cxx
|
||||||
|
*.cc
|
||||||
|
*.cp
|
||||||
|
*.c
|
||||||
|
*.cs
|
||||||
|
*.h
|
||||||
|
*.hh
|
||||||
|
*.hpp
|
||||||
|
*.hxx
|
||||||
|
*.hs
|
||||||
|
*.lhs
|
||||||
|
*.nix
|
||||||
|
*.lua
|
||||||
|
*.java
|
||||||
|
*.sh
|
||||||
|
*.fish
|
||||||
|
*.bash
|
||||||
|
*.zsh
|
||||||
|
*.ksh
|
||||||
|
*.csh
|
||||||
|
*.awk
|
||||||
|
*.ps1
|
||||||
|
*.ml λ
|
||||||
|
*.mli λ
|
||||||
|
*.diff
|
||||||
|
*.db
|
||||||
|
*.sql
|
||||||
|
*.dump
|
||||||
|
*.clj
|
||||||
|
*.cljc
|
||||||
|
*.cljs
|
||||||
|
*.edn
|
||||||
|
*.scala
|
||||||
|
*.go
|
||||||
|
*.dart
|
||||||
|
*.xul
|
||||||
|
*.sln
|
||||||
|
*.suo
|
||||||
|
*.pl
|
||||||
|
*.pm
|
||||||
|
*.t
|
||||||
|
*.rss
|
||||||
|
'*.f#'
|
||||||
|
*.fsscript
|
||||||
|
*.fsx
|
||||||
|
*.fs
|
||||||
|
*.fsi
|
||||||
|
*.rs
|
||||||
|
*.rlib
|
||||||
|
*.d
|
||||||
|
*.erl
|
||||||
|
*.hrl
|
||||||
|
*.ex
|
||||||
|
*.exs
|
||||||
|
*.eex
|
||||||
|
*.leex
|
||||||
|
*.heex
|
||||||
|
*.vim
|
||||||
|
*.ai
|
||||||
|
*.psd
|
||||||
|
*.psb
|
||||||
|
*.ts
|
||||||
|
*.tsx
|
||||||
|
*.jl
|
||||||
|
*.pp
|
||||||
|
*.vue ﵂
|
||||||
|
*.elm
|
||||||
|
*.swift
|
||||||
|
*.xcplayground
|
||||||
|
*.tex ﭨ
|
||||||
|
*.r ﳒ
|
||||||
|
*.rproj 鉶
|
||||||
|
*.sol ﲹ
|
||||||
|
*.pem
|
||||||
|
|
||||||
|
# file names (vim-devicons) (case-insensitive not supported in lf)
|
||||||
|
*gruntfile.coffee
|
||||||
|
*gruntfile.js
|
||||||
|
*gruntfile.ls
|
||||||
|
*gulpfile.coffee
|
||||||
|
*gulpfile.js
|
||||||
|
*gulpfile.ls
|
||||||
|
*mix.lock
|
||||||
|
*dropbox
|
||||||
|
*.ds_store
|
||||||
|
*.gitconfig
|
||||||
|
*.gitignore
|
||||||
|
*.gitattributes
|
||||||
|
*.gitlab-ci.yml
|
||||||
|
*.bashrc
|
||||||
|
*.zshrc
|
||||||
|
*.zshenv
|
||||||
|
*.zprofile
|
||||||
|
*.vimrc
|
||||||
|
*.gvimrc
|
||||||
|
*_vimrc
|
||||||
|
*_gvimrc
|
||||||
|
*.bashprofile
|
||||||
|
*favicon.ico
|
||||||
|
*license
|
||||||
|
*node_modules
|
||||||
|
*react.jsx
|
||||||
|
*procfile
|
||||||
|
*dockerfile
|
||||||
|
*docker-compose.yml
|
||||||
|
*rakefile
|
||||||
|
*config.ru
|
||||||
|
*gemfile
|
||||||
|
*makefile
|
||||||
|
*cmakelists.txt
|
||||||
|
*robots.txt ﮧ
|
||||||
|
|
||||||
|
# file names (case-sensitive adaptations)
|
||||||
|
*Gruntfile.coffee
|
||||||
|
*Gruntfile.js
|
||||||
|
*Gruntfile.ls
|
||||||
|
*Gulpfile.coffee
|
||||||
|
*Gulpfile.js
|
||||||
|
*Gulpfile.ls
|
||||||
|
*Dropbox
|
||||||
|
*.DS_Store
|
||||||
|
*LICENSE
|
||||||
|
*React.jsx
|
||||||
|
*Procfile
|
||||||
|
*Dockerfile
|
||||||
|
*Docker-compose.yml
|
||||||
|
*Rakefile
|
||||||
|
*Gemfile
|
||||||
|
*Makefile
|
||||||
|
*CMakeLists.txt
|
||||||
|
|
||||||
|
# file patterns (vim-devicons) (patterns not supported in lf)
|
||||||
|
# .*jquery.*\.js$
|
||||||
|
# .*angular.*\.js$
|
||||||
|
# .*backbone.*\.js$
|
||||||
|
# .*require.*\.js$
|
||||||
|
# .*materialize.*\.js$
|
||||||
|
# .*materialize.*\.css$
|
||||||
|
# .*mootools.*\.js$
|
||||||
|
# .*vimrc.*
|
||||||
|
# Vagrantfile$
|
||||||
|
|
||||||
|
# file patterns (file name adaptations)
|
||||||
|
*jquery.min.js
|
||||||
|
*angular.min.js
|
||||||
|
*backbone.min.js
|
||||||
|
*require.min.js
|
||||||
|
*materialize.min.js
|
||||||
|
*materialize.min.css
|
||||||
|
*mootools.min.js
|
||||||
|
*vimrc
|
||||||
|
Vagrantfile
|
||||||
|
|
||||||
|
# archives or compressed (extensions from dircolors defaults)
|
||||||
|
*.tar
|
||||||
|
*.tgz
|
||||||
|
*.arc
|
||||||
|
*.arj
|
||||||
|
*.taz
|
||||||
|
*.lha
|
||||||
|
*.lz4
|
||||||
|
*.lzh
|
||||||
|
*.lzma
|
||||||
|
*.tlz
|
||||||
|
*.txz
|
||||||
|
*.tzo
|
||||||
|
*.t7z
|
||||||
|
*.zip
|
||||||
|
*.z
|
||||||
|
*.dz
|
||||||
|
*.gz
|
||||||
|
*.lrz
|
||||||
|
*.lz
|
||||||
|
*.lzo
|
||||||
|
*.xz
|
||||||
|
*.zst
|
||||||
|
*.tzst
|
||||||
|
*.bz2
|
||||||
|
*.bz
|
||||||
|
*.tbz
|
||||||
|
*.tbz2
|
||||||
|
*.tz
|
||||||
|
*.deb
|
||||||
|
*.rpm
|
||||||
|
*.jar
|
||||||
|
*.war
|
||||||
|
*.ear
|
||||||
|
*.sar
|
||||||
|
*.rar
|
||||||
|
*.alz
|
||||||
|
*.ace
|
||||||
|
*.zoo
|
||||||
|
*.cpio
|
||||||
|
*.7z
|
||||||
|
*.rz
|
||||||
|
*.cab
|
||||||
|
*.wim
|
||||||
|
*.swm
|
||||||
|
*.dwm
|
||||||
|
*.esd
|
||||||
|
|
||||||
|
# image formats (extensions from dircolors defaults)
|
||||||
|
*.jpg
|
||||||
|
*.jpeg
|
||||||
|
*.mjpg
|
||||||
|
*.mjpeg
|
||||||
|
*.gif
|
||||||
|
*.bmp
|
||||||
|
*.pbm
|
||||||
|
*.pgm
|
||||||
|
*.ppm
|
||||||
|
*.tga
|
||||||
|
*.xbm
|
||||||
|
*.xpm
|
||||||
|
*.tif
|
||||||
|
*.tiff
|
||||||
|
*.png
|
||||||
|
*.svg
|
||||||
|
*.svgz
|
||||||
|
*.mng
|
||||||
|
*.pcx
|
||||||
|
*.mov
|
||||||
|
*.mpg
|
||||||
|
*.mpeg
|
||||||
|
*.m2v
|
||||||
|
*.mkv
|
||||||
|
*.webm
|
||||||
|
*.ogm
|
||||||
|
*.mp4
|
||||||
|
*.m4v
|
||||||
|
*.mp4v
|
||||||
|
*.vob
|
||||||
|
*.qt
|
||||||
|
*.nuv
|
||||||
|
*.wmv
|
||||||
|
*.asf
|
||||||
|
*.rm
|
||||||
|
*.rmvb
|
||||||
|
*.flc
|
||||||
|
*.avi
|
||||||
|
*.fli
|
||||||
|
*.flv
|
||||||
|
*.gl
|
||||||
|
*.dl
|
||||||
|
*.xcf
|
||||||
|
*.xwd
|
||||||
|
*.yuv
|
||||||
|
*.cgm
|
||||||
|
*.emf
|
||||||
|
*.ogv
|
||||||
|
*.ogx
|
||||||
|
|
||||||
|
# audio formats (extensions from dircolors defaults)
|
||||||
|
*.aac
|
||||||
|
*.au
|
||||||
|
*.flac
|
||||||
|
*.m4a
|
||||||
|
*.mid
|
||||||
|
*.midi
|
||||||
|
*.mka
|
||||||
|
*.mp3
|
||||||
|
*.mpc
|
||||||
|
*.ogg
|
||||||
|
*.ra
|
||||||
|
*.wav
|
||||||
|
*.oga
|
||||||
|
*.opus
|
||||||
|
*.spx
|
||||||
|
*.xspf
|
||||||
|
|
||||||
|
# other formats
|
||||||
|
*.pdf
|
||||||
@@ -13,6 +13,7 @@ _lf () {
|
|||||||
-cpuprofile
|
-cpuprofile
|
||||||
-doc
|
-doc
|
||||||
-last-dir-path
|
-last-dir-path
|
||||||
|
-log
|
||||||
-memprofile
|
-memprofile
|
||||||
-remote
|
-remote
|
||||||
-selection-path
|
-selection-path
|
||||||
|
|||||||
+1
-1
@@ -9,7 +9,7 @@
|
|||||||
# endif
|
# endif
|
||||||
#
|
#
|
||||||
|
|
||||||
set LF_ARGS = "-command -config -cpuprofile -doc -last-dir-path -memprofile -remote -selection-path -server -single -version -help "
|
set LF_ARGS = "-command -config -cpuprofile -doc -last-dir-path -log -memprofile -remote -selection-path -server -single -version -help "
|
||||||
|
|
||||||
complete lf "C/-*/(${LF_ARGS})/"
|
complete lf "C/-*/(${LF_ARGS})/"
|
||||||
complete lfcd "C/-*/(${LF_ARGS})/"
|
complete lfcd "C/-*/(${LF_ARGS})/"
|
||||||
@@ -11,6 +11,7 @@ complete -c lf -o config -r -d 'path to the config file (instead of the usual pa
|
|||||||
complete -c lf -o cpuprofile -r -d 'path to the file to write the CPU profile'
|
complete -c lf -o cpuprofile -r -d 'path to the file to write the CPU profile'
|
||||||
complete -c lf -o doc -d 'show documentation'
|
complete -c lf -o doc -d 'show documentation'
|
||||||
complete -c lf -o last-dir-path -r -d 'path to the file to write the last dir on exit (to use for cd)'
|
complete -c lf -o last-dir-path -r -d 'path to the file to write the last dir on exit (to use for cd)'
|
||||||
|
complete -c lf -o log -r -d 'path to the log file to write messages'
|
||||||
complete -c lf -o memprofile -r -d 'path to the file to write the memory profile'
|
complete -c lf -o memprofile -r -d 'path to the file to write the memory profile'
|
||||||
complete -c lf -o remote -x -d 'send remote command to server'
|
complete -c lf -o remote -x -d 'send remote command to server'
|
||||||
complete -c lf -o selection-path -r -d 'path to the file to write selected files on open (to use as open file dialog)'
|
complete -c lf -o selection-path -r -d 'path to the file to write selected files on open (to use as open file dialog)'
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ Register-ArgumentCompleter -Native -CommandName 'lf' -ScriptBlock {
|
|||||||
[CompletionResult]::new('-cpuprofile ', '-cpuprofile', [CompletionResultType]::ParameterName, 'path to the file to write the CPU profile')
|
[CompletionResult]::new('-cpuprofile ', '-cpuprofile', [CompletionResultType]::ParameterName, 'path to the file to write the CPU profile')
|
||||||
[CompletionResult]::new('-doc', '-doc', [CompletionResultType]::ParameterName, 'show documentation')
|
[CompletionResult]::new('-doc', '-doc', [CompletionResultType]::ParameterName, 'show documentation')
|
||||||
[CompletionResult]::new('-last-dir-path ', '-last-dir-path', [CompletionResultType]::ParameterName, 'path to the file to write the last dir on exit (to use for cd)')
|
[CompletionResult]::new('-last-dir-path ', '-last-dir-path', [CompletionResultType]::ParameterName, 'path to the file to write the last dir on exit (to use for cd)')
|
||||||
|
[CompletionResult]::new('-log ', '-log', [CompletionResultType]::ParameterName, 'path to the log file to write messages')
|
||||||
[CompletionResult]::new('-memprofile ', '-memprofile', [CompletionResultType]::ParameterName, 'path to the file to write the memory profile')
|
[CompletionResult]::new('-memprofile ', '-memprofile', [CompletionResultType]::ParameterName, 'path to the file to write the memory profile')
|
||||||
[CompletionResult]::new('-remote ', '-remote', [CompletionResultType]::ParameterName, 'send remote command to server')
|
[CompletionResult]::new('-remote ', '-remote', [CompletionResultType]::ParameterName, 'send remote command to server')
|
||||||
[CompletionResult]::new('-selection-path ', '-selection-path', [CompletionResultType]::ParameterName, 'path to the file to write selected files on open (to use as open file dialog)')
|
[CompletionResult]::new('-selection-path ', '-selection-path', [CompletionResultType]::ParameterName, 'path to the file to write selected files on open (to use as open file dialog)')
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ arguments=(
|
|||||||
'-cpuprofile[path to the file to write the CPU profile]'
|
'-cpuprofile[path to the file to write the CPU profile]'
|
||||||
'-doc[show documentation]'
|
'-doc[show documentation]'
|
||||||
'-last-dir-path[path to the file to write the last dir on exit (to use for cd)]'
|
'-last-dir-path[path to the file to write the last dir on exit (to use for cd)]'
|
||||||
|
'-log[path to the log file to write messages]'
|
||||||
'-memprofile[path to the file to write the memory profile]'
|
'-memprofile[path to the file to write the memory profile]'
|
||||||
'-remote[send remote command to server]'
|
'-remote[send remote command to server]'
|
||||||
'-selection-path[path to the file to write selected files on open (to use as open file dialog)]'
|
'-selection-path[path to the file to write selected files on open (to use as open file dialog)]'
|
||||||
|
|||||||
+4
-4
@@ -15,10 +15,10 @@
|
|||||||
|
|
||||||
$tmp = [System.IO.Path]::GetTempFileName()
|
$tmp = [System.IO.Path]::GetTempFileName()
|
||||||
lf -last-dir-path="$tmp" $args
|
lf -last-dir-path="$tmp" $args
|
||||||
if (test-path -pathtype leaf "$tmp") {
|
if (Test-Path -PathType Leaf "$tmp") {
|
||||||
$dir = type "$tmp"
|
$dir = Get-Content "$tmp"
|
||||||
remove-item -force "$tmp"
|
Remove-Item -Force "$tmp"
|
||||||
if (test-path -pathtype container "$dir") {
|
if (Test-Path -PathType Container "$dir") {
|
||||||
if ("$dir" -ne "$pwd") {
|
if ("$dir" -ne "$pwd") {
|
||||||
cd "$dir"
|
cd "$dir"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,9 @@ set shell powershell
|
|||||||
# which does not work with powershell. Therefore, you need to override these
|
# which does not work with powershell. Therefore, you need to override these
|
||||||
# keybindings with explicit choices accordingly.
|
# keybindings with explicit choices accordingly.
|
||||||
|
|
||||||
|
# change the default open command to work in powerShell
|
||||||
|
cmd open &start $Env:f
|
||||||
|
|
||||||
# change the editor used in default editor keybinding
|
# change the editor used in default editor keybinding
|
||||||
# There is no builtin terminal editor installed in Windows. The default editor
|
# There is no builtin terminal editor installed in Windows. The default editor
|
||||||
# mapping uses 'notepad' which launches in a separate GUI window. You may
|
# mapping uses 'notepad' which launches in a separate GUI window. You may
|
||||||
|
|||||||
@@ -26,12 +26,36 @@ func (e *setExpr) eval(app *app, args []string) {
|
|||||||
gOpts.autoquit = false
|
gOpts.autoquit = false
|
||||||
case "autoquit!":
|
case "autoquit!":
|
||||||
gOpts.autoquit = !gOpts.autoquit
|
gOpts.autoquit = !gOpts.autoquit
|
||||||
|
case "dircache":
|
||||||
|
gOpts.dircache = true
|
||||||
|
case "nodircache":
|
||||||
|
gOpts.dircache = false
|
||||||
|
case "dircache!":
|
||||||
|
gOpts.dircache = !gOpts.dircache
|
||||||
case "dircounts":
|
case "dircounts":
|
||||||
gOpts.dircounts = true
|
gOpts.dircounts = true
|
||||||
case "nodircounts":
|
case "nodircounts":
|
||||||
gOpts.dircounts = false
|
gOpts.dircounts = false
|
||||||
case "dircounts!":
|
case "dircounts!":
|
||||||
gOpts.dircounts = !gOpts.dircounts
|
gOpts.dircounts = !gOpts.dircounts
|
||||||
|
case "dironly":
|
||||||
|
gOpts.dironly = true
|
||||||
|
app.nav.sort()
|
||||||
|
app.nav.position()
|
||||||
|
app.ui.sort()
|
||||||
|
app.ui.loadFile(app.nav, true)
|
||||||
|
case "nodironly":
|
||||||
|
gOpts.dironly = false
|
||||||
|
app.nav.sort()
|
||||||
|
app.nav.position()
|
||||||
|
app.ui.sort()
|
||||||
|
app.ui.loadFile(app.nav, true)
|
||||||
|
case "dironly!":
|
||||||
|
gOpts.dironly = !gOpts.dironly
|
||||||
|
app.nav.sort()
|
||||||
|
app.nav.position()
|
||||||
|
app.ui.sort()
|
||||||
|
app.ui.loadFile(app.nav, true)
|
||||||
case "dirfirst":
|
case "dirfirst":
|
||||||
gOpts.sortType.option |= dirfirstSort
|
gOpts.sortType.option |= dirfirstSort
|
||||||
app.nav.sort()
|
app.nav.sort()
|
||||||
@@ -70,10 +94,19 @@ func (e *setExpr) eval(app *app, args []string) {
|
|||||||
app.ui.loadFile(app.nav, true)
|
app.ui.loadFile(app.nav, true)
|
||||||
case "globsearch":
|
case "globsearch":
|
||||||
gOpts.globsearch = true
|
gOpts.globsearch = true
|
||||||
|
app.nav.sort()
|
||||||
|
app.ui.sort()
|
||||||
|
app.ui.loadFile(app.nav, true)
|
||||||
case "noglobsearch":
|
case "noglobsearch":
|
||||||
gOpts.globsearch = false
|
gOpts.globsearch = false
|
||||||
|
app.nav.sort()
|
||||||
|
app.ui.sort()
|
||||||
|
app.ui.loadFile(app.nav, true)
|
||||||
case "globsearch!":
|
case "globsearch!":
|
||||||
gOpts.globsearch = !gOpts.globsearch
|
gOpts.globsearch = !gOpts.globsearch
|
||||||
|
app.nav.sort()
|
||||||
|
app.ui.sort()
|
||||||
|
app.ui.loadFile(app.nav, true)
|
||||||
case "hidden":
|
case "hidden":
|
||||||
gOpts.sortType.option |= hiddenSort
|
gOpts.sortType.option |= hiddenSort
|
||||||
app.nav.sort()
|
app.nav.sort()
|
||||||
@@ -102,14 +135,17 @@ func (e *setExpr) eval(app *app, args []string) {
|
|||||||
gOpts.ignorecase = true
|
gOpts.ignorecase = true
|
||||||
app.nav.sort()
|
app.nav.sort()
|
||||||
app.ui.sort()
|
app.ui.sort()
|
||||||
|
app.ui.loadFile(app.nav, true)
|
||||||
case "noignorecase":
|
case "noignorecase":
|
||||||
gOpts.ignorecase = false
|
gOpts.ignorecase = false
|
||||||
app.nav.sort()
|
app.nav.sort()
|
||||||
app.ui.sort()
|
app.ui.sort()
|
||||||
|
app.ui.loadFile(app.nav, true)
|
||||||
case "ignorecase!":
|
case "ignorecase!":
|
||||||
gOpts.ignorecase = !gOpts.ignorecase
|
gOpts.ignorecase = !gOpts.ignorecase
|
||||||
app.nav.sort()
|
app.nav.sort()
|
||||||
app.ui.sort()
|
app.ui.sort()
|
||||||
|
app.ui.loadFile(app.nav, true)
|
||||||
case "ignoredia":
|
case "ignoredia":
|
||||||
gOpts.ignoredia = true
|
gOpts.ignoredia = true
|
||||||
app.nav.sort()
|
app.nav.sort()
|
||||||
@@ -122,6 +158,12 @@ func (e *setExpr) eval(app *app, args []string) {
|
|||||||
gOpts.ignoredia = !gOpts.ignoredia
|
gOpts.ignoredia = !gOpts.ignoredia
|
||||||
app.nav.sort()
|
app.nav.sort()
|
||||||
app.ui.sort()
|
app.ui.sort()
|
||||||
|
case "incfilter":
|
||||||
|
gOpts.incfilter = true
|
||||||
|
case "noincfilter":
|
||||||
|
gOpts.incfilter = false
|
||||||
|
case "incfilter!":
|
||||||
|
gOpts.incfilter = !gOpts.incfilter
|
||||||
case "incsearch":
|
case "incsearch":
|
||||||
gOpts.incsearch = true
|
gOpts.incsearch = true
|
||||||
case "noincsearch":
|
case "noincsearch":
|
||||||
@@ -186,10 +228,19 @@ func (e *setExpr) eval(app *app, args []string) {
|
|||||||
app.ui.sort()
|
app.ui.sort()
|
||||||
case "smartcase":
|
case "smartcase":
|
||||||
gOpts.smartcase = true
|
gOpts.smartcase = true
|
||||||
|
app.nav.sort()
|
||||||
|
app.ui.sort()
|
||||||
|
app.ui.loadFile(app.nav, true)
|
||||||
case "nosmartcase":
|
case "nosmartcase":
|
||||||
gOpts.smartcase = false
|
gOpts.smartcase = false
|
||||||
|
app.nav.sort()
|
||||||
|
app.ui.sort()
|
||||||
|
app.ui.loadFile(app.nav, true)
|
||||||
case "smartcase!":
|
case "smartcase!":
|
||||||
gOpts.smartcase = !gOpts.smartcase
|
gOpts.smartcase = !gOpts.smartcase
|
||||||
|
app.nav.sort()
|
||||||
|
app.ui.sort()
|
||||||
|
app.ui.loadFile(app.nav, true)
|
||||||
case "smartdia":
|
case "smartdia":
|
||||||
gOpts.smartdia = true
|
gOpts.smartdia = true
|
||||||
case "nosmartdia":
|
case "nosmartdia":
|
||||||
@@ -359,8 +410,18 @@ func (e *setExpr) eval(app *app, args []string) {
|
|||||||
}
|
}
|
||||||
app.nav.sort()
|
app.nav.sort()
|
||||||
app.ui.sort()
|
app.ui.sort()
|
||||||
|
case "tempmarks":
|
||||||
|
if e.val != "" {
|
||||||
|
gOpts.tempmarks = "'" + e.val
|
||||||
|
} else {
|
||||||
|
gOpts.tempmarks = "'"
|
||||||
|
}
|
||||||
case "timefmt":
|
case "timefmt":
|
||||||
gOpts.timefmt = e.val
|
gOpts.timefmt = e.val
|
||||||
|
case "infotimefmtnew":
|
||||||
|
gOpts.infotimefmtnew = e.val
|
||||||
|
case "infotimefmtold":
|
||||||
|
gOpts.infotimefmtold = e.val
|
||||||
case "truncatechar":
|
case "truncatechar":
|
||||||
if runeSliceWidth([]rune(e.val)) != 1 {
|
if runeSliceWidth([]rune(e.val)) != 1 {
|
||||||
app.ui.echoerr("truncatechar: value should be a single character")
|
app.ui.echoerr("truncatechar: value should be a single character")
|
||||||
@@ -385,10 +446,10 @@ func (e *mapExpr) eval(app *app, args []string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (e *cmapExpr) eval(app *app, args []string) {
|
func (e *cmapExpr) eval(app *app, args []string) {
|
||||||
if e.cmd == "" {
|
if e.expr == nil {
|
||||||
delete(gOpts.cmdkeys, e.key)
|
delete(gOpts.cmdkeys, e.key)
|
||||||
} else {
|
} else {
|
||||||
gOpts.cmdkeys[e.key] = &callExpr{e.cmd, nil, 1}
|
gOpts.cmdkeys[e.key] = e.expr
|
||||||
}
|
}
|
||||||
app.ui.loadFileInfo(app.nav)
|
app.ui.loadFileInfo(app.nav)
|
||||||
}
|
}
|
||||||
@@ -402,7 +463,14 @@ func (e *cmdExpr) eval(app *app, args []string) {
|
|||||||
app.ui.loadFileInfo(app.nav)
|
app.ui.loadFileInfo(app.nav)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func preChdir(app *app) {
|
||||||
|
if cmd, ok := gOpts.cmds["pre-cd"]; ok {
|
||||||
|
cmd.eval(app, nil)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func onChdir(app *app) {
|
func onChdir(app *app) {
|
||||||
|
app.nav.addJumpList()
|
||||||
if cmd, ok := gOpts.cmds["on-cd"]; ok {
|
if cmd, ok := gOpts.cmds["on-cd"]; ok {
|
||||||
cmd.eval(app, nil)
|
cmd.eval(app, nil)
|
||||||
}
|
}
|
||||||
@@ -461,10 +529,56 @@ func update(app *app) {
|
|||||||
app.ui.loadFile(app.nav, true)
|
app.ui.loadFile(app.nav, true)
|
||||||
app.ui.loadFileInfo(app.nav)
|
app.ui.loadFileInfo(app.nav)
|
||||||
}
|
}
|
||||||
|
case gOpts.incfilter && app.ui.cmdPrefix == "filter: ":
|
||||||
|
filter := string(app.ui.cmdAccLeft) + string(app.ui.cmdAccRight)
|
||||||
|
dir := app.nav.currDir()
|
||||||
|
old := dir.ind
|
||||||
|
|
||||||
|
if err := app.nav.setFilter(strings.Split(filter, " ")); err != nil {
|
||||||
|
app.ui.echoerrf("filter: %s", err)
|
||||||
|
} else if old != dir.ind {
|
||||||
|
app.ui.loadFile(app.nav, true)
|
||||||
|
app.ui.loadFileInfo(app.nav)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func restartIncCmd(app *app) {
|
||||||
|
if gOpts.incsearch && (app.ui.cmdPrefix == "/" || app.ui.cmdPrefix == "?") {
|
||||||
|
dir := app.nav.currDir()
|
||||||
|
app.nav.searchInd = dir.ind
|
||||||
|
app.nav.searchPos = dir.pos
|
||||||
|
update(app)
|
||||||
|
} else if gOpts.incfilter && app.ui.cmdPrefix == "filter: " {
|
||||||
|
dir := app.nav.currDir()
|
||||||
|
app.nav.prevFilter = dir.filter
|
||||||
|
update(app)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func resetIncCmd(app *app) {
|
||||||
|
if gOpts.incsearch && (app.ui.cmdPrefix == "/" || app.ui.cmdPrefix == "?") {
|
||||||
|
dir := app.nav.currDir()
|
||||||
|
dir.pos = app.nav.searchPos
|
||||||
|
if dir.ind != app.nav.searchInd {
|
||||||
|
dir.ind = app.nav.searchInd
|
||||||
|
app.ui.loadFile(app.nav, true)
|
||||||
|
app.ui.loadFileInfo(app.nav)
|
||||||
|
}
|
||||||
|
} else if gOpts.incfilter && app.ui.cmdPrefix == "filter: " {
|
||||||
|
dir := app.nav.currDir()
|
||||||
|
old := dir.ind
|
||||||
|
app.nav.setFilter(app.nav.prevFilter)
|
||||||
|
if old != dir.ind {
|
||||||
|
app.ui.loadFile(app.nav, true)
|
||||||
|
app.ui.loadFileInfo(app.nav)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func normal(app *app) {
|
func normal(app *app) {
|
||||||
|
resetIncCmd(app)
|
||||||
|
|
||||||
app.ui.menuBuf = nil
|
app.ui.menuBuf = nil
|
||||||
app.ui.menuSelected = -2
|
app.ui.menuSelected = -2
|
||||||
|
|
||||||
@@ -479,6 +593,9 @@ func insert(app *app, arg string) {
|
|||||||
case gOpts.incsearch && (app.ui.cmdPrefix == "/" || app.ui.cmdPrefix == "?"):
|
case gOpts.incsearch && (app.ui.cmdPrefix == "/" || app.ui.cmdPrefix == "?"):
|
||||||
app.ui.cmdAccLeft = append(app.ui.cmdAccLeft, []rune(arg)...)
|
app.ui.cmdAccLeft = append(app.ui.cmdAccLeft, []rune(arg)...)
|
||||||
update(app)
|
update(app)
|
||||||
|
case gOpts.incfilter && app.ui.cmdPrefix == "filter: ":
|
||||||
|
app.ui.cmdAccLeft = append(app.ui.cmdAccLeft, []rune(arg)...)
|
||||||
|
update(app)
|
||||||
case app.ui.cmdPrefix == "find: ":
|
case app.ui.cmdPrefix == "find: ":
|
||||||
app.nav.find = string(app.ui.cmdAccLeft) + arg + string(app.ui.cmdAccRight)
|
app.nav.find = string(app.ui.cmdAccLeft) + arg + string(app.ui.cmdAccRight)
|
||||||
|
|
||||||
@@ -605,12 +722,7 @@ func insert(app *app, arg string) {
|
|||||||
case app.ui.cmdPrefix == "mark-save: ":
|
case app.ui.cmdPrefix == "mark-save: ":
|
||||||
normal(app)
|
normal(app)
|
||||||
|
|
||||||
wd, err := os.Getwd()
|
app.nav.marks[arg] = app.nav.currDir().path
|
||||||
if err != nil {
|
|
||||||
log.Printf("getting current directory: %s", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
app.nav.marks[arg] = wd
|
|
||||||
if err := app.nav.writeMarks(); err != nil {
|
if err := app.nav.writeMarks(); err != nil {
|
||||||
app.ui.echoerrf("mark-save: %s", err)
|
app.ui.echoerrf("mark-save: %s", err)
|
||||||
}
|
}
|
||||||
@@ -636,6 +748,12 @@ func insert(app *app, arg string) {
|
|||||||
app.ui.echoerr("mark-load: no such mark")
|
app.ui.echoerr("mark-load: no such mark")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if wd != path {
|
||||||
|
resetIncCmd(app)
|
||||||
|
preChdir(app)
|
||||||
|
}
|
||||||
|
|
||||||
if err := app.nav.cd(path); err != nil {
|
if err := app.nav.cd(path); err != nil {
|
||||||
app.ui.echoerrf("%s", err)
|
app.ui.echoerrf("%s", err)
|
||||||
return
|
return
|
||||||
@@ -645,6 +763,7 @@ func insert(app *app, arg string) {
|
|||||||
|
|
||||||
if wd != path {
|
if wd != path {
|
||||||
app.nav.marks["'"] = wd
|
app.nav.marks["'"] = wd
|
||||||
|
restartIncCmd(app)
|
||||||
onChdir(app)
|
onChdir(app)
|
||||||
}
|
}
|
||||||
case app.ui.cmdPrefix == "mark-remove: ":
|
case app.ui.cmdPrefix == "mark-remove: ":
|
||||||
@@ -674,57 +793,75 @@ func insert(app *app, arg string) {
|
|||||||
func (e *callExpr) eval(app *app, args []string) {
|
func (e *callExpr) eval(app *app, args []string) {
|
||||||
switch e.name {
|
switch e.name {
|
||||||
case "up":
|
case "up":
|
||||||
if app.ui.cmdPrefix != "" && app.ui.cmdPrefix != ">" {
|
if !app.nav.init {
|
||||||
normal(app)
|
return
|
||||||
}
|
}
|
||||||
if app.nav.up(e.count) {
|
if app.nav.up(e.count) {
|
||||||
app.ui.loadFile(app.nav, true)
|
app.ui.loadFile(app.nav, true)
|
||||||
app.ui.loadFileInfo(app.nav)
|
app.ui.loadFileInfo(app.nav)
|
||||||
}
|
}
|
||||||
case "half-up":
|
case "half-up":
|
||||||
if app.ui.cmdPrefix != "" && app.ui.cmdPrefix != ">" {
|
if !app.nav.init {
|
||||||
normal(app)
|
return
|
||||||
}
|
}
|
||||||
if app.nav.up(e.count * app.nav.height / 2) {
|
if app.nav.up(e.count * app.nav.height / 2) {
|
||||||
app.ui.loadFile(app.nav, true)
|
app.ui.loadFile(app.nav, true)
|
||||||
app.ui.loadFileInfo(app.nav)
|
app.ui.loadFileInfo(app.nav)
|
||||||
}
|
}
|
||||||
case "page-up":
|
case "page-up":
|
||||||
if app.ui.cmdPrefix != "" && app.ui.cmdPrefix != ">" {
|
if !app.nav.init {
|
||||||
normal(app)
|
return
|
||||||
}
|
}
|
||||||
if app.nav.up(e.count * app.nav.height) {
|
if app.nav.up(e.count * app.nav.height) {
|
||||||
app.ui.loadFile(app.nav, true)
|
app.ui.loadFile(app.nav, true)
|
||||||
app.ui.loadFileInfo(app.nav)
|
app.ui.loadFileInfo(app.nav)
|
||||||
}
|
}
|
||||||
|
case "scroll-up":
|
||||||
|
if !app.nav.init {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if app.nav.scrollUp(e.count) {
|
||||||
|
app.ui.loadFile(app.nav, true)
|
||||||
|
app.ui.loadFileInfo(app.nav)
|
||||||
|
}
|
||||||
case "down":
|
case "down":
|
||||||
if app.ui.cmdPrefix != "" && app.ui.cmdPrefix != ">" {
|
if !app.nav.init {
|
||||||
normal(app)
|
return
|
||||||
}
|
}
|
||||||
if app.nav.down(e.count) {
|
if app.nav.down(e.count) {
|
||||||
app.ui.loadFile(app.nav, true)
|
app.ui.loadFile(app.nav, true)
|
||||||
app.ui.loadFileInfo(app.nav)
|
app.ui.loadFileInfo(app.nav)
|
||||||
}
|
}
|
||||||
case "half-down":
|
case "half-down":
|
||||||
if app.ui.cmdPrefix != "" && app.ui.cmdPrefix != ">" {
|
if !app.nav.init {
|
||||||
normal(app)
|
return
|
||||||
}
|
}
|
||||||
if app.nav.down(e.count * app.nav.height / 2) {
|
if app.nav.down(e.count * app.nav.height / 2) {
|
||||||
app.ui.loadFile(app.nav, true)
|
app.ui.loadFile(app.nav, true)
|
||||||
app.ui.loadFileInfo(app.nav)
|
app.ui.loadFileInfo(app.nav)
|
||||||
}
|
}
|
||||||
case "page-down":
|
case "page-down":
|
||||||
if app.ui.cmdPrefix != "" && app.ui.cmdPrefix != ">" {
|
if !app.nav.init {
|
||||||
normal(app)
|
return
|
||||||
}
|
}
|
||||||
if app.nav.down(e.count * app.nav.height) {
|
if app.nav.down(e.count * app.nav.height) {
|
||||||
app.ui.loadFile(app.nav, true)
|
app.ui.loadFile(app.nav, true)
|
||||||
app.ui.loadFileInfo(app.nav)
|
app.ui.loadFileInfo(app.nav)
|
||||||
}
|
}
|
||||||
case "updir":
|
case "scroll-down":
|
||||||
if app.ui.cmdPrefix != "" && app.ui.cmdPrefix != ">" {
|
if !app.nav.init {
|
||||||
normal(app)
|
return
|
||||||
}
|
}
|
||||||
|
if app.nav.scrollDown(e.count) {
|
||||||
|
app.ui.loadFile(app.nav, true)
|
||||||
|
app.ui.loadFileInfo(app.nav)
|
||||||
|
}
|
||||||
|
case "updir":
|
||||||
|
if !app.nav.init {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resetIncCmd(app)
|
||||||
|
preChdir(app)
|
||||||
for i := 0; i < e.count; i++ {
|
for i := 0; i < e.count; i++ {
|
||||||
if err := app.nav.updir(); err != nil {
|
if err := app.nav.updir(); err != nil {
|
||||||
app.ui.echoerrf("%s", err)
|
app.ui.echoerrf("%s", err)
|
||||||
@@ -733,10 +870,11 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
}
|
}
|
||||||
app.ui.loadFile(app.nav, true)
|
app.ui.loadFile(app.nav, true)
|
||||||
app.ui.loadFileInfo(app.nav)
|
app.ui.loadFileInfo(app.nav)
|
||||||
|
restartIncCmd(app)
|
||||||
onChdir(app)
|
onChdir(app)
|
||||||
case "open":
|
case "open":
|
||||||
if app.ui.cmdPrefix != "" && app.ui.cmdPrefix != ">" {
|
if !app.nav.init {
|
||||||
normal(app)
|
return
|
||||||
}
|
}
|
||||||
curr, err := app.nav.currFile()
|
curr, err := app.nav.currFile()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -745,6 +883,8 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if curr.IsDir() {
|
if curr.IsDir() {
|
||||||
|
resetIncCmd(app)
|
||||||
|
preChdir(app)
|
||||||
err := app.nav.open()
|
err := app.nav.open()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.ui.echoerrf("opening directory: %s", err)
|
app.ui.echoerrf("opening directory: %s", err)
|
||||||
@@ -752,6 +892,7 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
}
|
}
|
||||||
app.ui.loadFile(app.nav, true)
|
app.ui.loadFile(app.nav, true)
|
||||||
app.ui.loadFileInfo(app.nav)
|
app.ui.loadFileInfo(app.nav)
|
||||||
|
restartIncCmd(app)
|
||||||
onChdir(app)
|
onChdir(app)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -784,30 +925,54 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
if cmd, ok := gOpts.cmds["open"]; ok {
|
if cmd, ok := gOpts.cmds["open"]; ok {
|
||||||
cmd.eval(app, e.args)
|
cmd.eval(app, e.args)
|
||||||
}
|
}
|
||||||
|
case "jump-prev":
|
||||||
|
resetIncCmd(app)
|
||||||
|
preChdir(app)
|
||||||
|
for i := 0; i < e.count; i++ {
|
||||||
|
app.nav.cdJumpListPrev()
|
||||||
|
}
|
||||||
|
app.ui.loadFile(app.nav, true)
|
||||||
|
app.ui.loadFileInfo(app.nav)
|
||||||
|
restartIncCmd(app)
|
||||||
|
onChdir(app)
|
||||||
|
case "jump-next":
|
||||||
|
resetIncCmd(app)
|
||||||
|
preChdir(app)
|
||||||
|
for i := 0; i < e.count; i++ {
|
||||||
|
app.nav.cdJumpListNext()
|
||||||
|
}
|
||||||
|
app.ui.loadFile(app.nav, true)
|
||||||
|
app.ui.loadFileInfo(app.nav)
|
||||||
|
restartIncCmd(app)
|
||||||
|
onChdir(app)
|
||||||
case "quit":
|
case "quit":
|
||||||
app.quitChan <- struct{}{}
|
app.quitChan <- struct{}{}
|
||||||
case "top":
|
case "top":
|
||||||
if app.ui.cmdPrefix != "" && app.ui.cmdPrefix != ">" {
|
if !app.nav.init {
|
||||||
normal(app)
|
return
|
||||||
}
|
}
|
||||||
if app.nav.top() {
|
if app.nav.top() {
|
||||||
app.ui.loadFile(app.nav, true)
|
app.ui.loadFile(app.nav, true)
|
||||||
app.ui.loadFileInfo(app.nav)
|
app.ui.loadFileInfo(app.nav)
|
||||||
}
|
}
|
||||||
case "bottom":
|
case "bottom":
|
||||||
if app.ui.cmdPrefix != "" && app.ui.cmdPrefix != ">" {
|
if !app.nav.init {
|
||||||
normal(app)
|
return
|
||||||
}
|
}
|
||||||
if app.nav.bottom() {
|
if app.nav.bottom() {
|
||||||
app.ui.loadFile(app.nav, true)
|
app.ui.loadFile(app.nav, true)
|
||||||
app.ui.loadFileInfo(app.nav)
|
app.ui.loadFileInfo(app.nav)
|
||||||
}
|
}
|
||||||
case "toggle":
|
case "toggle":
|
||||||
|
if !app.nav.init {
|
||||||
|
return
|
||||||
|
}
|
||||||
if len(e.args) == 0 {
|
if len(e.args) == 0 {
|
||||||
app.nav.toggle()
|
app.nav.toggle()
|
||||||
} else {
|
} else {
|
||||||
dir := app.nav.currDir()
|
dir := app.nav.currDir()
|
||||||
for _, path := range e.args {
|
for _, path := range e.args {
|
||||||
|
path = replaceTilde(path)
|
||||||
if !filepath.IsAbs(path) {
|
if !filepath.IsAbs(path) {
|
||||||
path = filepath.Join(dir.path, path)
|
path = filepath.Join(dir.path, path)
|
||||||
}
|
}
|
||||||
@@ -818,11 +983,80 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
case "tag-toggle":
|
||||||
|
if !app.nav.init {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
tag := "*"
|
||||||
|
if len(e.args) != 0 {
|
||||||
|
tag = e.args[0]
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := app.nav.tagToggle(tag); err != nil {
|
||||||
|
app.ui.echoerrf("tag-toggle: %s", err)
|
||||||
|
} else if err := app.nav.writeTags(); err != nil {
|
||||||
|
app.ui.echoerrf("tag-toggle: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if gSingleMode {
|
||||||
|
if err := app.nav.sync(); err != nil {
|
||||||
|
app.ui.echoerrf("tag-toggle: %s", err)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if err := remote("send sync"); err != nil {
|
||||||
|
app.ui.echoerrf("tag-toggle: %s", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case "tag":
|
||||||
|
if !app.nav.init {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
tag := "*"
|
||||||
|
if len(e.args) != 0 {
|
||||||
|
tag = e.args[0]
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := app.nav.tag(tag); err != nil {
|
||||||
|
app.ui.echoerrf("tag: %s", err)
|
||||||
|
} else if err := app.nav.writeTags(); err != nil {
|
||||||
|
app.ui.echoerrf("tag: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if gSingleMode {
|
||||||
|
if err := app.nav.sync(); err != nil {
|
||||||
|
app.ui.echoerrf("tag: %s", err)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if err := remote("send sync"); err != nil {
|
||||||
|
app.ui.echoerrf("tag: %s", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
case "invert":
|
case "invert":
|
||||||
|
if !app.nav.init {
|
||||||
|
return
|
||||||
|
}
|
||||||
app.nav.invert()
|
app.nav.invert()
|
||||||
case "unselect":
|
case "unselect":
|
||||||
app.nav.unselect()
|
app.nav.unselect()
|
||||||
|
case "calcdirsize":
|
||||||
|
if !app.nav.init {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err := app.nav.calcDirSize()
|
||||||
|
if err != nil {
|
||||||
|
app.ui.echoerrf("calcdirsize: %s", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
app.ui.loadFileInfo(app.nav)
|
||||||
|
app.nav.sort()
|
||||||
|
app.ui.sort()
|
||||||
case "copy":
|
case "copy":
|
||||||
|
if !app.nav.init {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if err := app.nav.save(true); err != nil {
|
if err := app.nav.save(true); err != nil {
|
||||||
app.ui.echoerrf("copy: %s", err)
|
app.ui.echoerrf("copy: %s", err)
|
||||||
return
|
return
|
||||||
@@ -841,6 +1075,10 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
}
|
}
|
||||||
app.ui.loadFileInfo(app.nav)
|
app.ui.loadFileInfo(app.nav)
|
||||||
case "cut":
|
case "cut":
|
||||||
|
if !app.nav.init {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if err := app.nav.save(false); err != nil {
|
if err := app.nav.save(false); err != nil {
|
||||||
app.ui.echoerrf("cut: %s", err)
|
app.ui.echoerrf("cut: %s", err)
|
||||||
return
|
return
|
||||||
@@ -859,6 +1097,10 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
}
|
}
|
||||||
app.ui.loadFileInfo(app.nav)
|
app.ui.loadFileInfo(app.nav)
|
||||||
case "paste":
|
case "paste":
|
||||||
|
if !app.nav.init {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if cmd, ok := gOpts.cmds["paste"]; ok {
|
if cmd, ok := gOpts.cmds["paste"]; ok {
|
||||||
cmd.eval(app, e.args)
|
cmd.eval(app, e.args)
|
||||||
} else if err := app.nav.paste(app.ui); err != nil {
|
} else if err := app.nav.paste(app.ui); err != nil {
|
||||||
@@ -868,6 +1110,10 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
app.ui.loadFile(app.nav, true)
|
app.ui.loadFile(app.nav, true)
|
||||||
app.ui.loadFileInfo(app.nav)
|
app.ui.loadFileInfo(app.nav)
|
||||||
case "delete":
|
case "delete":
|
||||||
|
if !app.nav.init {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if cmd, ok := gOpts.cmds["delete"]; ok {
|
if cmd, ok := gOpts.cmds["delete"]; ok {
|
||||||
cmd.eval(app, e.args)
|
cmd.eval(app, e.args)
|
||||||
app.nav.unselect()
|
app.nav.unselect()
|
||||||
@@ -887,6 +1133,10 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if app.ui.cmdPrefix == ">" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
normal(app)
|
||||||
if len(list) == 1 {
|
if len(list) == 1 {
|
||||||
app.ui.cmdPrefix = "delete '" + list[0] + "' ? [y/N] "
|
app.ui.cmdPrefix = "delete '" + list[0] + "' ? [y/N] "
|
||||||
} else {
|
} else {
|
||||||
@@ -896,6 +1146,9 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
app.ui.loadFile(app.nav, true)
|
app.ui.loadFile(app.nav, true)
|
||||||
app.ui.loadFileInfo(app.nav)
|
app.ui.loadFileInfo(app.nav)
|
||||||
case "clear":
|
case "clear":
|
||||||
|
if !app.nav.init {
|
||||||
|
return
|
||||||
|
}
|
||||||
if err := saveFiles(nil, false); err != nil {
|
if err := saveFiles(nil, false); err != nil {
|
||||||
app.ui.echoerrf("clear: %s", err)
|
app.ui.echoerrf("clear: %s", err)
|
||||||
return
|
return
|
||||||
@@ -914,6 +1167,9 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
app.ui.loadFileInfo(app.nav)
|
app.ui.loadFileInfo(app.nav)
|
||||||
case "draw":
|
case "draw":
|
||||||
case "redraw":
|
case "redraw":
|
||||||
|
if !app.nav.init {
|
||||||
|
return
|
||||||
|
}
|
||||||
app.ui.renew()
|
app.ui.renew()
|
||||||
app.ui.screen.Sync()
|
app.ui.screen.Sync()
|
||||||
if app.nav.height != app.ui.wins[0].h {
|
if app.nav.height != app.ui.wins[0].h {
|
||||||
@@ -922,38 +1178,75 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
}
|
}
|
||||||
app.ui.loadFile(app.nav, true)
|
app.ui.loadFile(app.nav, true)
|
||||||
case "load":
|
case "load":
|
||||||
|
if !app.nav.init {
|
||||||
|
return
|
||||||
|
}
|
||||||
app.nav.renew()
|
app.nav.renew()
|
||||||
app.ui.loadFile(app.nav, true)
|
app.ui.loadFile(app.nav, true)
|
||||||
case "reload":
|
case "reload":
|
||||||
|
if !app.nav.init {
|
||||||
|
return
|
||||||
|
}
|
||||||
if err := app.nav.reload(); err != nil {
|
if err := app.nav.reload(); err != nil {
|
||||||
app.ui.echoerrf("reload: %s", err)
|
app.ui.echoerrf("reload: %s", err)
|
||||||
}
|
}
|
||||||
app.ui.loadFile(app.nav, true)
|
app.ui.loadFile(app.nav, true)
|
||||||
app.ui.loadFileInfo(app.nav)
|
app.ui.loadFileInfo(app.nav)
|
||||||
case "read":
|
case "read":
|
||||||
|
if app.ui.cmdPrefix == ">" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
normal(app)
|
||||||
app.ui.cmdPrefix = ":"
|
app.ui.cmdPrefix = ":"
|
||||||
app.ui.loadFileInfo(app.nav)
|
app.ui.loadFileInfo(app.nav)
|
||||||
case "shell":
|
case "shell":
|
||||||
|
if app.ui.cmdPrefix == ">" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
normal(app)
|
||||||
app.ui.cmdPrefix = "$"
|
app.ui.cmdPrefix = "$"
|
||||||
app.ui.loadFileInfo(app.nav)
|
app.ui.loadFileInfo(app.nav)
|
||||||
case "shell-pipe":
|
case "shell-pipe":
|
||||||
|
if app.ui.cmdPrefix == ">" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
normal(app)
|
||||||
app.ui.cmdPrefix = "%"
|
app.ui.cmdPrefix = "%"
|
||||||
app.ui.loadFileInfo(app.nav)
|
app.ui.loadFileInfo(app.nav)
|
||||||
case "shell-wait":
|
case "shell-wait":
|
||||||
|
if app.ui.cmdPrefix == ">" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
normal(app)
|
||||||
app.ui.cmdPrefix = "!"
|
app.ui.cmdPrefix = "!"
|
||||||
app.ui.loadFileInfo(app.nav)
|
app.ui.loadFileInfo(app.nav)
|
||||||
case "shell-async":
|
case "shell-async":
|
||||||
|
if app.ui.cmdPrefix == ">" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
normal(app)
|
||||||
app.ui.cmdPrefix = "&"
|
app.ui.cmdPrefix = "&"
|
||||||
app.ui.loadFileInfo(app.nav)
|
app.ui.loadFileInfo(app.nav)
|
||||||
case "find":
|
case "find":
|
||||||
|
if app.ui.cmdPrefix == ">" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
normal(app)
|
||||||
app.ui.cmdPrefix = "find: "
|
app.ui.cmdPrefix = "find: "
|
||||||
app.nav.findBack = false
|
app.nav.findBack = false
|
||||||
app.ui.loadFileInfo(app.nav)
|
app.ui.loadFileInfo(app.nav)
|
||||||
case "find-back":
|
case "find-back":
|
||||||
|
if app.ui.cmdPrefix == ">" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
normal(app)
|
||||||
app.ui.cmdPrefix = "find-back: "
|
app.ui.cmdPrefix = "find-back: "
|
||||||
app.nav.findBack = true
|
app.nav.findBack = true
|
||||||
app.ui.loadFileInfo(app.nav)
|
app.ui.loadFileInfo(app.nav)
|
||||||
case "find-next":
|
case "find-next":
|
||||||
|
if !app.nav.init {
|
||||||
|
return
|
||||||
|
}
|
||||||
dir := app.nav.currDir()
|
dir := app.nav.currDir()
|
||||||
old := dir.ind
|
old := dir.ind
|
||||||
for i := 0; i < e.count; i++ {
|
for i := 0; i < e.count; i++ {
|
||||||
@@ -968,6 +1261,9 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
app.ui.loadFileInfo(app.nav)
|
app.ui.loadFileInfo(app.nav)
|
||||||
}
|
}
|
||||||
case "find-prev":
|
case "find-prev":
|
||||||
|
if !app.nav.init {
|
||||||
|
return
|
||||||
|
}
|
||||||
dir := app.nav.currDir()
|
dir := app.nav.currDir()
|
||||||
old := dir.ind
|
old := dir.ind
|
||||||
for i := 0; i < e.count; i++ {
|
for i := 0; i < e.count; i++ {
|
||||||
@@ -982,6 +1278,13 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
app.ui.loadFileInfo(app.nav)
|
app.ui.loadFileInfo(app.nav)
|
||||||
}
|
}
|
||||||
case "search":
|
case "search":
|
||||||
|
if !app.nav.init {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if app.ui.cmdPrefix == ">" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
normal(app)
|
||||||
app.ui.cmdPrefix = "/"
|
app.ui.cmdPrefix = "/"
|
||||||
dir := app.nav.currDir()
|
dir := app.nav.currDir()
|
||||||
app.nav.searchInd = dir.ind
|
app.nav.searchInd = dir.ind
|
||||||
@@ -989,6 +1292,13 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
app.nav.searchBack = false
|
app.nav.searchBack = false
|
||||||
app.ui.loadFileInfo(app.nav)
|
app.ui.loadFileInfo(app.nav)
|
||||||
case "search-back":
|
case "search-back":
|
||||||
|
if !app.nav.init {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if app.ui.cmdPrefix == ">" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
normal(app)
|
||||||
app.ui.cmdPrefix = "?"
|
app.ui.cmdPrefix = "?"
|
||||||
dir := app.nav.currDir()
|
dir := app.nav.currDir()
|
||||||
app.nav.searchInd = dir.ind
|
app.nav.searchInd = dir.ind
|
||||||
@@ -996,6 +1306,9 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
app.nav.searchBack = true
|
app.nav.searchBack = true
|
||||||
app.ui.loadFileInfo(app.nav)
|
app.ui.loadFileInfo(app.nav)
|
||||||
case "search-next":
|
case "search-next":
|
||||||
|
if !app.nav.init {
|
||||||
|
return
|
||||||
|
}
|
||||||
for i := 0; i < e.count; i++ {
|
for i := 0; i < e.count; i++ {
|
||||||
if app.nav.searchBack {
|
if app.nav.searchBack {
|
||||||
if moved, err := app.nav.searchPrev(); err != nil {
|
if moved, err := app.nav.searchPrev(); err != nil {
|
||||||
@@ -1014,6 +1327,9 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
case "search-prev":
|
case "search-prev":
|
||||||
|
if !app.nav.init {
|
||||||
|
return
|
||||||
|
}
|
||||||
for i := 0; i < e.count; i++ {
|
for i := 0; i < e.count; i++ {
|
||||||
if app.nav.searchBack {
|
if app.nav.searchBack {
|
||||||
if moved, err := app.nav.searchNext(); err != nil {
|
if moved, err := app.nav.searchNext(); err != nil {
|
||||||
@@ -1031,15 +1347,57 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
case "filter":
|
||||||
|
if !app.nav.init {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if app.ui.cmdPrefix == ">" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
normal(app)
|
||||||
|
app.ui.cmdPrefix = "filter: "
|
||||||
|
dir := app.nav.currDir()
|
||||||
|
app.nav.prevFilter = dir.filter
|
||||||
|
if len(e.args) == 0 {
|
||||||
|
app.ui.cmdAccLeft = []rune(strings.Join(dir.filter, " "))
|
||||||
|
} else {
|
||||||
|
app.ui.cmdAccLeft = []rune(strings.Join(e.args, " "))
|
||||||
|
}
|
||||||
|
app.ui.loadFileInfo(app.nav)
|
||||||
|
case "setfilter":
|
||||||
|
if !app.nav.init {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
log.Printf("filter: %s", e.args)
|
||||||
|
if err := app.nav.setFilter(e.args); err != nil {
|
||||||
|
app.ui.echoerrf("filter: %s", err)
|
||||||
|
}
|
||||||
|
app.ui.loadFile(app.nav, true)
|
||||||
|
app.ui.loadFileInfo(app.nav)
|
||||||
case "mark-save":
|
case "mark-save":
|
||||||
|
if app.ui.cmdPrefix == ">" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
normal(app)
|
||||||
app.ui.cmdPrefix = "mark-save: "
|
app.ui.cmdPrefix = "mark-save: "
|
||||||
case "mark-load":
|
case "mark-load":
|
||||||
|
if app.ui.cmdPrefix == ">" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
normal(app)
|
||||||
app.ui.menuBuf = listMarks(app.nav.marks)
|
app.ui.menuBuf = listMarks(app.nav.marks)
|
||||||
app.ui.cmdPrefix = "mark-load: "
|
app.ui.cmdPrefix = "mark-load: "
|
||||||
case "mark-remove":
|
case "mark-remove":
|
||||||
|
if app.ui.cmdPrefix == ">" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
normal(app)
|
||||||
app.ui.menuBuf = listMarks(app.nav.marks)
|
app.ui.menuBuf = listMarks(app.nav.marks)
|
||||||
app.ui.cmdPrefix = "mark-remove: "
|
app.ui.cmdPrefix = "mark-remove: "
|
||||||
case "rename":
|
case "rename":
|
||||||
|
if !app.nav.init {
|
||||||
|
return
|
||||||
|
}
|
||||||
if cmd, ok := gOpts.cmds["rename"]; ok {
|
if cmd, ok := gOpts.cmds["rename"]; ok {
|
||||||
cmd.eval(app, e.args)
|
cmd.eval(app, e.args)
|
||||||
if gSingleMode {
|
if gSingleMode {
|
||||||
@@ -1057,6 +1415,10 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
app.ui.echoerrf("rename: %s:", err)
|
app.ui.echoerrf("rename: %s:", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if app.ui.cmdPrefix == ">" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
normal(app)
|
||||||
app.ui.cmdPrefix = "rename: "
|
app.ui.cmdPrefix = "rename: "
|
||||||
app.ui.cmdAccLeft = append(app.ui.cmdAccLeft, []rune(curr.Name())...)
|
app.ui.cmdAccLeft = append(app.ui.cmdAccLeft, []rune(curr.Name())...)
|
||||||
}
|
}
|
||||||
@@ -1083,6 +1445,18 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
log.Printf("getting current directory: %s", err)
|
log.Printf("getting current directory: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
path = replaceTilde(path)
|
||||||
|
if !filepath.IsAbs(path) {
|
||||||
|
path = filepath.Join(wd, path)
|
||||||
|
} else {
|
||||||
|
path = filepath.Clean(path)
|
||||||
|
}
|
||||||
|
|
||||||
|
if wd != path {
|
||||||
|
resetIncCmd(app)
|
||||||
|
preChdir(app)
|
||||||
|
}
|
||||||
|
|
||||||
if err := app.nav.cd(path); err != nil {
|
if err := app.nav.cd(path); err != nil {
|
||||||
app.ui.echoerrf("%s", err)
|
app.ui.echoerrf("%s", err)
|
||||||
return
|
return
|
||||||
@@ -1091,17 +1465,16 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
app.ui.loadFile(app.nav, true)
|
app.ui.loadFile(app.nav, true)
|
||||||
app.ui.loadFileInfo(app.nav)
|
app.ui.loadFileInfo(app.nav)
|
||||||
|
|
||||||
if !filepath.IsAbs(path) {
|
|
||||||
path = filepath.Join(wd, path)
|
|
||||||
} else {
|
|
||||||
path = filepath.Clean(path)
|
|
||||||
}
|
|
||||||
|
|
||||||
if wd != path {
|
if wd != path {
|
||||||
app.nav.marks["'"] = wd
|
app.nav.marks["'"] = wd
|
||||||
|
restartIncCmd(app)
|
||||||
onChdir(app)
|
onChdir(app)
|
||||||
}
|
}
|
||||||
case "select":
|
case "select":
|
||||||
|
if !app.nav.init {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if len(e.args) != 1 {
|
if len(e.args) != 1 {
|
||||||
app.ui.echoerr("select: requires an argument")
|
app.ui.echoerr("select: requires an argument")
|
||||||
return
|
return
|
||||||
@@ -1112,6 +1485,18 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
log.Printf("getting current directory: %s", err)
|
log.Printf("getting current directory: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
path := filepath.Dir(replaceTilde(e.args[0]))
|
||||||
|
if !filepath.IsAbs(path) {
|
||||||
|
path = filepath.Join(wd, path)
|
||||||
|
} else {
|
||||||
|
path = filepath.Clean(path)
|
||||||
|
}
|
||||||
|
|
||||||
|
if wd != path {
|
||||||
|
resetIncCmd(app)
|
||||||
|
preChdir(app)
|
||||||
|
}
|
||||||
|
|
||||||
if err := app.nav.sel(e.args[0]); err != nil {
|
if err := app.nav.sel(e.args[0]); err != nil {
|
||||||
app.ui.echoerrf("%s", err)
|
app.ui.echoerrf("%s", err)
|
||||||
return
|
return
|
||||||
@@ -1120,18 +1505,15 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
app.ui.loadFile(app.nav, true)
|
app.ui.loadFile(app.nav, true)
|
||||||
app.ui.loadFileInfo(app.nav)
|
app.ui.loadFileInfo(app.nav)
|
||||||
|
|
||||||
path := filepath.Dir(e.args[0])
|
|
||||||
if !filepath.IsAbs(path) {
|
|
||||||
path = filepath.Join(wd, path)
|
|
||||||
} else {
|
|
||||||
path = filepath.Clean(path)
|
|
||||||
}
|
|
||||||
|
|
||||||
if wd != path {
|
if wd != path {
|
||||||
app.nav.marks["'"] = wd
|
app.nav.marks["'"] = wd
|
||||||
|
restartIncCmd(app)
|
||||||
onChdir(app)
|
onChdir(app)
|
||||||
}
|
}
|
||||||
case "glob-select":
|
case "glob-select":
|
||||||
|
if !app.nav.init {
|
||||||
|
return
|
||||||
|
}
|
||||||
if len(e.args) != 1 {
|
if len(e.args) != 1 {
|
||||||
app.ui.echoerr("glob-select: requires a pattern to match")
|
app.ui.echoerr("glob-select: requires a pattern to match")
|
||||||
return
|
return
|
||||||
@@ -1141,6 +1523,9 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
case "glob-unselect":
|
case "glob-unselect":
|
||||||
|
if !app.nav.init {
|
||||||
|
return
|
||||||
|
}
|
||||||
if len(e.args) != 1 {
|
if len(e.args) != 1 {
|
||||||
app.ui.echoerr("glob-unselect: requires a pattern to match")
|
app.ui.echoerr("glob-unselect: requires a pattern to match")
|
||||||
return
|
return
|
||||||
@@ -1182,15 +1567,6 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
if app.ui.cmdPrefix == ">" {
|
if app.ui.cmdPrefix == ">" {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if gOpts.incsearch && (app.ui.cmdPrefix == "/" || app.ui.cmdPrefix == "?") {
|
|
||||||
dir := app.nav.currDir()
|
|
||||||
dir.pos = app.nav.searchPos
|
|
||||||
if dir.ind != app.nav.searchInd {
|
|
||||||
dir.ind = app.nav.searchInd
|
|
||||||
app.ui.loadFile(app.nav, true)
|
|
||||||
app.ui.loadFileInfo(app.nav)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
normal(app)
|
normal(app)
|
||||||
case "cmd-complete":
|
case "cmd-complete":
|
||||||
var matches []string
|
var matches []string
|
||||||
@@ -1307,7 +1683,7 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
}
|
}
|
||||||
case "cmd-enter":
|
case "cmd-enter":
|
||||||
s := string(append(app.ui.cmdAccLeft, app.ui.cmdAccRight...))
|
s := string(append(app.ui.cmdAccLeft, app.ui.cmdAccRight...))
|
||||||
if len(s) == 0 {
|
if len(s) == 0 && app.ui.cmdPrefix != "filter: " {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1384,6 +1760,14 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
app.ui.loadFile(app.nav, true)
|
app.ui.loadFile(app.nav, true)
|
||||||
app.ui.loadFileInfo(app.nav)
|
app.ui.loadFileInfo(app.nav)
|
||||||
}
|
}
|
||||||
|
case "filter: ":
|
||||||
|
log.Printf("filter: %s", s)
|
||||||
|
app.ui.cmdPrefix = ""
|
||||||
|
if err := app.nav.setFilter(strings.Split(s, " ")); err != nil {
|
||||||
|
app.ui.echoerrf("filter: %s", err)
|
||||||
|
}
|
||||||
|
app.ui.loadFile(app.nav, true)
|
||||||
|
app.ui.loadFileInfo(app.nav)
|
||||||
case "find: ":
|
case "find: ":
|
||||||
app.ui.cmdPrefix = ""
|
app.ui.cmdPrefix = ""
|
||||||
if moved, found := app.nav.findNext(); !found {
|
if moved, found := app.nav.findNext(); !found {
|
||||||
@@ -1413,7 +1797,7 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
|
|
||||||
oldPath := filepath.Join(wd, curr.Name())
|
oldPath := filepath.Join(wd, curr.Name())
|
||||||
|
|
||||||
newPath := filepath.Clean(s)
|
newPath := filepath.Clean(replaceTilde(s))
|
||||||
if !filepath.IsAbs(newPath) {
|
if !filepath.IsAbs(newPath) {
|
||||||
newPath = filepath.Join(wd, newPath)
|
newPath = filepath.Join(wd, newPath)
|
||||||
}
|
}
|
||||||
@@ -1480,12 +1864,9 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
cmd := app.cmdHistory[len(app.cmdHistory)-app.cmdHistoryInd]
|
cmd := app.cmdHistory[len(app.cmdHistory)-app.cmdHistoryInd]
|
||||||
|
normal(app)
|
||||||
app.ui.cmdPrefix = cmd.prefix
|
app.ui.cmdPrefix = cmd.prefix
|
||||||
app.ui.cmdAccLeft = []rune(cmd.value)
|
app.ui.cmdAccLeft = []rune(cmd.value)
|
||||||
app.ui.cmdAccRight = nil
|
|
||||||
app.ui.cmdTmp = nil
|
|
||||||
app.ui.menuBuf = nil
|
|
||||||
app.ui.menuSelected = -2
|
|
||||||
case "cmd-history-prev":
|
case "cmd-history-prev":
|
||||||
if app.ui.cmdPrefix == ">" {
|
if app.ui.cmdPrefix == ">" {
|
||||||
return
|
return
|
||||||
@@ -1498,12 +1879,9 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
}
|
}
|
||||||
app.cmdHistoryInd++
|
app.cmdHistoryInd++
|
||||||
cmd := app.cmdHistory[len(app.cmdHistory)-app.cmdHistoryInd]
|
cmd := app.cmdHistory[len(app.cmdHistory)-app.cmdHistoryInd]
|
||||||
|
normal(app)
|
||||||
app.ui.cmdPrefix = cmd.prefix
|
app.ui.cmdPrefix = cmd.prefix
|
||||||
app.ui.cmdAccLeft = []rune(cmd.value)
|
app.ui.cmdAccLeft = []rune(cmd.value)
|
||||||
app.ui.cmdAccRight = nil
|
|
||||||
app.ui.cmdTmp = nil
|
|
||||||
app.ui.menuBuf = nil
|
|
||||||
app.ui.menuSelected = -2
|
|
||||||
case "cmd-delete":
|
case "cmd-delete":
|
||||||
if len(app.ui.cmdAccRight) == 0 {
|
if len(app.ui.cmdAccRight) == 0 {
|
||||||
return
|
return
|
||||||
@@ -1564,7 +1942,12 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
update(app)
|
update(app)
|
||||||
case "cmd-interrupt":
|
case "cmd-interrupt":
|
||||||
if app.cmd != nil {
|
if app.cmd != nil {
|
||||||
app.cmd.Process.Kill()
|
err := shellKill(app.cmd)
|
||||||
|
if err != nil {
|
||||||
|
app.ui.echoerrf("kill: %s", err)
|
||||||
|
} else {
|
||||||
|
app.ui.echoerr("process interrupt")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
normal(app)
|
normal(app)
|
||||||
case "cmd-word":
|
case "cmd-word":
|
||||||
|
|||||||
+1
-1
@@ -218,7 +218,7 @@ var gEvalTests = []struct {
|
|||||||
{
|
{
|
||||||
"cmap <c-g> cmd-escape",
|
"cmap <c-g> cmd-escape",
|
||||||
[]string{"cmap", "<c-g>", "cmd-escape", "\n"},
|
[]string{"cmap", "<c-g>", "cmd-escape", "\n"},
|
||||||
[]expr{&cmapExpr{"<c-g>", "cmd-escape"}},
|
[]expr{&cmapExpr{"<c-g>", &callExpr{"cmd-escape", nil, 1}}},
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|||||||
+2
-1
@@ -28,6 +28,7 @@ lf \- terminal file manager
|
|||||||
.OP \-cpuprofile path
|
.OP \-cpuprofile path
|
||||||
.OP \-doc
|
.OP \-doc
|
||||||
.OP \-last-dir-path path
|
.OP \-last-dir-path path
|
||||||
|
.OP \-log path
|
||||||
.OP \-memprofile path
|
.OP \-memprofile path
|
||||||
.OP \-remote command
|
.OP \-remote command
|
||||||
.OP \-selection-path path
|
.OP \-selection-path path
|
||||||
@@ -35,7 +36,7 @@ lf \- terminal file manager
|
|||||||
.OP \-single
|
.OP \-single
|
||||||
.OP \-version
|
.OP \-version
|
||||||
.OP \-help
|
.OP \-help
|
||||||
.RI [ directory ]
|
.RI [ cd-or-select-path ]
|
||||||
.YS
|
.YS
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
END
|
END
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ go 1.12
|
|||||||
require (
|
require (
|
||||||
github.com/gdamore/tcell/v2 v2.3.1
|
github.com/gdamore/tcell/v2 v2.3.1
|
||||||
github.com/mattn/go-runewidth v0.0.10
|
github.com/mattn/go-runewidth v0.0.10
|
||||||
|
golang.org/x/sys v0.0.0-20220209214540-3681064d5158
|
||||||
golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d
|
golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d
|
||||||
gopkg.in/djherbis/times.v1 v1.2.0
|
gopkg.in/djherbis/times.v1 v1.2.0
|
||||||
)
|
)
|
||||||
@@ -8,8 +8,9 @@ github.com/mattn/go-runewidth v0.0.10 h1:CoZ3S2P7pvtP45xOtBw+/mDL2z0RKI576gSkzRR
|
|||||||
github.com/mattn/go-runewidth v0.0.10/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=
|
github.com/mattn/go-runewidth v0.0.10/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=
|
||||||
github.com/rivo/uniseg v0.1.0 h1:+2KBaVoUmb9XzDsrx/Ct0W/EYOSFf/nWTauy++DprtY=
|
github.com/rivo/uniseg v0.1.0 h1:+2KBaVoUmb9XzDsrx/Ct0W/EYOSFf/nWTauy++DprtY=
|
||||||
github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
||||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68 h1:nxC68pudNYkKU6jWhgrqdreuFiOQWj1Fs7T3VrH4Pjw=
|
|
||||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20220209214540-3681064d5158 h1:rm+CHSpPEEW2IsXUib1ThaHIjuBVZjxNgSKmBLFfD4c=
|
||||||
|
golang.org/x/sys v0.0.0-20220209214540-3681064d5158/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||||
golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d h1:SZxvLBoTP5yHO3Frd4z4vrF+DBX9vMVanchswa69toE=
|
golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d h1:SZxvLBoTP5yHO3Frd4z4vrF+DBX9vMVanchswa69toE=
|
||||||
golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||||
|
|||||||
@@ -13,20 +13,20 @@ func parseIcons() iconMap {
|
|||||||
im := make(iconMap)
|
im := make(iconMap)
|
||||||
|
|
||||||
defaultIcons := []string{
|
defaultIcons := []string{
|
||||||
"fi=🗎",
|
"ln=l",
|
||||||
"di=🗀",
|
"or=l",
|
||||||
"ln=🗎",
|
"tw=t",
|
||||||
"pi=🗎",
|
"ow=d",
|
||||||
"so=🗎",
|
"st=t",
|
||||||
"bd=🗎",
|
"di=d",
|
||||||
"cd=🗎",
|
"pi=p",
|
||||||
"or=🗎",
|
"so=s",
|
||||||
"su=🗎",
|
"bd=b",
|
||||||
"sg=🗎",
|
"cd=c",
|
||||||
"tw=🗀",
|
"su=u",
|
||||||
"ow=🗀",
|
"sg=g",
|
||||||
"st=🗀",
|
"ex=x",
|
||||||
"ex=🗎",
|
"fi=-",
|
||||||
}
|
}
|
||||||
|
|
||||||
im.parseEnv(strings.Join(defaultIcons, ":"))
|
im.parseEnv(strings.Join(defaultIcons, ":"))
|
||||||
@@ -35,9 +35,44 @@ func parseIcons() iconMap {
|
|||||||
im.parseEnv(env)
|
im.parseEnv(env)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for _, path := range gIconsPaths {
|
||||||
|
if _, err := os.Stat(path); !os.IsNotExist(err) {
|
||||||
|
im.parseFile(path)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return im
|
return im
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (im iconMap) parseFile(path string) {
|
||||||
|
log.Printf("reading file: %s", path)
|
||||||
|
|
||||||
|
f, err := os.Open(path)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("opening icons file: %s", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer f.Close()
|
||||||
|
|
||||||
|
pairs, err := readPairs(f)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("reading icons file: %s", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, pair := range pairs {
|
||||||
|
key, val := pair[0], pair[1]
|
||||||
|
|
||||||
|
key = replaceTilde(key)
|
||||||
|
|
||||||
|
if filepath.IsAbs(key) {
|
||||||
|
key = filepath.Clean(key)
|
||||||
|
}
|
||||||
|
|
||||||
|
im[key] = val
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (im iconMap) parseEnv(env string) {
|
func (im iconMap) parseEnv(env string) {
|
||||||
for _, entry := range strings.Split(env, ":") {
|
for _, entry := range strings.Split(env, ":") {
|
||||||
if entry == "" {
|
if entry == "" {
|
||||||
@@ -113,6 +148,10 @@ func (im iconMap) get(f *file) string {
|
|||||||
return val
|
return val
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if val, ok := im["*"+f.Name()]; ok {
|
||||||
|
return val
|
||||||
|
}
|
||||||
|
|
||||||
if val, ok := im[filepath.Base(f.Name())+".*"]; ok {
|
if val, ok := im[filepath.Base(f.Name())+".*"]; ok {
|
||||||
return val
|
return val
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ lf \- terminal file manager
|
|||||||
.OP \-cpuprofile path
|
.OP \-cpuprofile path
|
||||||
.OP \-doc
|
.OP \-doc
|
||||||
.OP \-last-dir-path path
|
.OP \-last-dir-path path
|
||||||
|
.OP \-log path
|
||||||
.OP \-memprofile path
|
.OP \-memprofile path
|
||||||
.OP \-remote command
|
.OP \-remote command
|
||||||
.OP \-selection-path path
|
.OP \-selection-path path
|
||||||
@@ -16,14 +17,14 @@ lf \- terminal file manager
|
|||||||
.OP \-single
|
.OP \-single
|
||||||
.OP \-version
|
.OP \-version
|
||||||
.OP \-help
|
.OP \-help
|
||||||
.RI [ directory ]
|
.RI [ cd-or-select-path ]
|
||||||
.YS
|
.YS
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
lf is a terminal file manager.
|
lf is a terminal file manager.
|
||||||
.PP
|
.PP
|
||||||
Source code can be found in the repository at https://github.com/gokcehan/lf.
|
Source code can be found in the repository at https://github.com/gokcehan/lf
|
||||||
.PP
|
.PP
|
||||||
This documentation can either be read from terminal using 'lf -doc' or online at https://godoc.org/github.com/gokcehan/lf. You can also use 'doc' command (default '<f-1>') inside lf to view the documentation in a pager.
|
This documentation can either be read from terminal using 'lf -doc' or online at https://pkg.go.dev/github.com/gokcehan/lf You can also use 'doc' command (default '<f-1>') inside lf to view the documentation in a pager. A man page with the same content is also available in the repository at https://github.com/gokcehan/lf/blob/master/lf.1
|
||||||
.PP
|
.PP
|
||||||
You can run 'lf -help' to see descriptions of command line options.
|
You can run 'lf -help' to see descriptions of command line options.
|
||||||
.SH QUICK REFERENCE
|
.SH QUICK REFERENCE
|
||||||
@@ -34,11 +35,15 @@ The following commands are provided by lf:
|
|||||||
up (default 'k' and '<up>')
|
up (default 'k' and '<up>')
|
||||||
half-up (default '<c-u>')
|
half-up (default '<c-u>')
|
||||||
page-up (default '<c-b>' and '<pgup>')
|
page-up (default '<c-b>' and '<pgup>')
|
||||||
|
scroll-up (default '<c-y>')
|
||||||
down (default 'j' and '<down>')
|
down (default 'j' and '<down>')
|
||||||
half-down (default '<c-d>')
|
half-down (default '<c-d>')
|
||||||
page-down (default '<c-f>' and '<pgdn>')
|
page-down (default '<c-f>' and '<pgdn>')
|
||||||
|
scroll-down (default '<c-e>')
|
||||||
updir (default 'h' and '<left>')
|
updir (default 'h' and '<left>')
|
||||||
open (default 'l' and '<right>')
|
open (default 'l' and '<right>')
|
||||||
|
jump-next (default ']')
|
||||||
|
jump-prev (default '[')
|
||||||
top (default 'gg' and '<home>')
|
top (default 'gg' and '<home>')
|
||||||
bottom (default 'G' and '<end>')
|
bottom (default 'G' and '<end>')
|
||||||
toggle
|
toggle
|
||||||
@@ -46,6 +51,7 @@ The following commands are provided by lf:
|
|||||||
unselect (default 'u')
|
unselect (default 'u')
|
||||||
glob-select
|
glob-select
|
||||||
glob-unselect
|
glob-unselect
|
||||||
|
calcdirsize
|
||||||
copy (default 'y')
|
copy (default 'y')
|
||||||
cut (default 'd')
|
cut (default 'd')
|
||||||
paste (default 'p')
|
paste (default 'p')
|
||||||
@@ -77,9 +83,13 @@ The following commands are provided by lf:
|
|||||||
search-back (modal) (default '?')
|
search-back (modal) (default '?')
|
||||||
search-next (default 'n')
|
search-next (default 'n')
|
||||||
search-prev (default 'N')
|
search-prev (default 'N')
|
||||||
|
filter (modal)
|
||||||
|
setfilter
|
||||||
mark-save (modal) (default 'm')
|
mark-save (modal) (default 'm')
|
||||||
mark-load (modal) (default "'")
|
mark-load (modal) (default "'")
|
||||||
mark-remove (modal) (default `"`)
|
mark-remove (modal) (default '"')
|
||||||
|
tag
|
||||||
|
tag-toggle (default 't')
|
||||||
.EE
|
.EE
|
||||||
.PP
|
.PP
|
||||||
The following command line commands are provided by lf:
|
The following command line commands are provided by lf:
|
||||||
@@ -118,8 +128,11 @@ The following options can be used to customize the behavior of lf:
|
|||||||
.EX
|
.EX
|
||||||
anchorfind bool (default on)
|
anchorfind bool (default on)
|
||||||
autoquit bool (default off)
|
autoquit bool (default off)
|
||||||
|
cleaner string (default '')
|
||||||
|
dircache bool (default on)
|
||||||
dircounts bool (default off)
|
dircounts bool (default off)
|
||||||
dirfirst bool (default on)
|
dirfirst bool (default on)
|
||||||
|
dironly bool (default off)
|
||||||
drawbox bool (default off)
|
drawbox bool (default off)
|
||||||
errorfmt string (default "\e033[7;31;47m%s\e033[0m")
|
errorfmt string (default "\e033[7;31;47m%s\e033[0m")
|
||||||
filesep string (default "\en")
|
filesep string (default "\en")
|
||||||
@@ -131,26 +144,30 @@ The following options can be used to customize the behavior of lf:
|
|||||||
ifs string (default '')
|
ifs string (default '')
|
||||||
ignorecase bool (default on)
|
ignorecase bool (default on)
|
||||||
ignoredia bool (default on)
|
ignoredia bool (default on)
|
||||||
|
incfilter bool (default off)
|
||||||
incsearch bool (default off)
|
incsearch bool (default off)
|
||||||
info []string (default '')
|
info []string (default '')
|
||||||
|
infotimefmtnew string (default 'Jan _2 15:04')
|
||||||
|
infotimefmtold string (default 'Jan _2 2006')
|
||||||
mouse bool (default off)
|
mouse bool (default off)
|
||||||
number bool (default off)
|
number bool (default off)
|
||||||
period int (default 0)
|
period int (default 0)
|
||||||
preview bool (default on)
|
preview bool (default on)
|
||||||
previewer string (default '')
|
previewer string (default '')
|
||||||
cleaner string (default '')
|
|
||||||
promptfmt string (default "\e033[32;1m%u@%h\e033[0m:\e033[34;1m%d\e033[0m\e033[1m%f\e033[0m")
|
promptfmt string (default "\e033[32;1m%u@%h\e033[0m:\e033[34;1m%d\e033[0m\e033[1m%f\e033[0m")
|
||||||
ratios []int (default '1:2:3')
|
ratios []int (default '1:2:3')
|
||||||
relativenumber bool (default off)
|
relativenumber bool (default off)
|
||||||
reverse bool (default off)
|
reverse bool (default off)
|
||||||
scrolloff int (default 0)
|
scrolloff int (default 0)
|
||||||
shell string (default 'sh' for unix and 'cmd' for windows)
|
shell string (default 'sh' for Unix and 'cmd' for Windows)
|
||||||
shellflag string (default '-c' for unix and '/c' for windows)
|
shellflag string (default '-c' for Unix and '/c' for Windows)
|
||||||
shellopts []string (default '')
|
shellopts []string (default '')
|
||||||
smartcase bool (default on)
|
smartcase bool (default on)
|
||||||
smartdia bool (default off)
|
smartdia bool (default off)
|
||||||
sortby string (default 'natural')
|
sortby string (default 'natural')
|
||||||
tabstop int (default 8)
|
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')
|
timefmt string (default 'Mon Jan _2 15:04:05 2006')
|
||||||
truncatechar string (default '~')
|
truncatechar string (default '~')
|
||||||
waitmsg string (default 'Press any key to continue')
|
waitmsg string (default 'Press any key to continue')
|
||||||
@@ -172,12 +189,25 @@ The following environment variables are exported for shell commands:
|
|||||||
EDITOR
|
EDITOR
|
||||||
PAGER
|
PAGER
|
||||||
SHELL
|
SHELL
|
||||||
|
lf_{option}
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
The following special shell commands are used to customize the behavior of lf when defined:
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
open
|
||||||
|
paste
|
||||||
|
rename
|
||||||
|
delete
|
||||||
|
pre-cd
|
||||||
|
on-cd
|
||||||
|
on-quit
|
||||||
.EE
|
.EE
|
||||||
.PP
|
.PP
|
||||||
The following commands/keybindings are provided by default:
|
The following commands/keybindings are provided by default:
|
||||||
.PP
|
.PP
|
||||||
.EX
|
.EX
|
||||||
unix windows
|
Unix Windows
|
||||||
cmd open &$OPENER "$f" cmd open &%OPENER% %f%
|
cmd open &$OPENER "$f" cmd open &%OPENER% %f%
|
||||||
map e $$EDITOR "$f" map e $%EDITOR% %f%
|
map e $$EDITOR "$f" map e $%EDITOR% %f%
|
||||||
map i $$PAGER "$f" map i !%PAGER% %f%
|
map i $$PAGER "$f" map i !%PAGER% %f%
|
||||||
@@ -206,30 +236,53 @@ The following additional keybindings are provided by default:
|
|||||||
Configuration files should be located at:
|
Configuration files should be located at:
|
||||||
.PP
|
.PP
|
||||||
.EX
|
.EX
|
||||||
os system-wide user-specific
|
OS system-wide user-specific
|
||||||
unix /etc/lf/lfrc ~/.config/lf/lfrc
|
Unix /etc/lf/lfrc ~/.config/lf/lfrc
|
||||||
windows C:\eProgramData\elf\elfrc C:\eUsers\e<user>\eAppData\eLocal\elf\elfrc
|
Windows C:\eProgramData\elf\elfrc C:\eUsers\e<user>\eAppData\eLocal\elf\elfrc
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Colors file should be located at:
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
OS system-wide user-specific
|
||||||
|
Unix /etc/lf/colors ~/.config/lf/colors
|
||||||
|
Windows C:\eProgramData\elf\ecolors C:\eUsers\e<user>\eAppData\eLocal\elf\ecolors
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Icons file should be located at:
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
OS system-wide user-specific
|
||||||
|
Unix /etc/lf/icons ~/.config/lf/icons
|
||||||
|
Windows C:\eProgramData\elf\eicons C:\eUsers\e<user>\eAppData\eLocal\elf\eicons
|
||||||
.EE
|
.EE
|
||||||
.PP
|
.PP
|
||||||
Selection file should be located at:
|
Selection file should be located at:
|
||||||
.PP
|
.PP
|
||||||
.EX
|
.EX
|
||||||
unix ~/.local/share/lf/files
|
Unix ~/.local/share/lf/files
|
||||||
windows C:\eUsers\e<user>\eAppData\eLocal\elf\efiles
|
Windows C:\eUsers\e<user>\eAppData\eLocal\elf\efiles
|
||||||
.EE
|
.EE
|
||||||
.PP
|
.PP
|
||||||
Marks file should be located at:
|
Marks file should be located at:
|
||||||
.PP
|
.PP
|
||||||
.EX
|
.EX
|
||||||
unix ~/.local/share/lf/marks
|
Unix ~/.local/share/lf/marks
|
||||||
windows C:\eUsers\e<user>\eAppData\eLocal\elf\emarks
|
Windows C:\eUsers\e<user>\eAppData\eLocal\elf\emarks
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Tags file should be located at:
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
Unix ~/.local/share/lf/tags
|
||||||
|
Windows C:\eUsers\e<user>\eAppData\eLocal\elf\etags
|
||||||
.EE
|
.EE
|
||||||
.PP
|
.PP
|
||||||
History file should be located at:
|
History file should be located at:
|
||||||
.PP
|
.PP
|
||||||
.EX
|
.EX
|
||||||
unix ~/.local/share/lf/history
|
Unix ~/.local/share/lf/history
|
||||||
windows C:\eUsers\e<user>\eAppData\eLocal\elf\ehistory
|
Windows C:\eUsers\e<user>\eAppData\eLocal\elf\ehistory
|
||||||
.EE
|
.EE
|
||||||
.PP
|
.PP
|
||||||
You can configure the default values of following variables to change these locations:
|
You can configure the default values of following variables to change these locations:
|
||||||
@@ -241,7 +294,7 @@ You can configure the default values of following variables to change these loca
|
|||||||
%LOCALAPPDATA% C:\eUsers\e<user>\eAppData\eLocal
|
%LOCALAPPDATA% C:\eUsers\e<user>\eAppData\eLocal
|
||||||
.EE
|
.EE
|
||||||
.PP
|
.PP
|
||||||
A sample configuration file can be found at https://github.com/gokcehan/lf/blob/master/etc/lfrc.example.
|
A sample configuration file can be found at https://github.com/gokcehan/lf/blob/master/etc/lfrc.example
|
||||||
.SH COMMANDS
|
.SH COMMANDS
|
||||||
This section shows information about builtin commands. Modal commands do not take any arguments, but instead change the operation mode to read their input conveniently, and so they are meant to be assigned to keybindings.
|
This section shows information about builtin commands. Modal commands do not take any arguments, but instead change the operation mode to read their input conveniently, and so they are meant to be assigned to keybindings.
|
||||||
.PP
|
.PP
|
||||||
@@ -255,12 +308,14 @@ Quit lf and return to the shell.
|
|||||||
up (default 'k' and '<up>')
|
up (default 'k' and '<up>')
|
||||||
half-up (default '<c-u>')
|
half-up (default '<c-u>')
|
||||||
page-up (default '<c-b>' and '<pgup>')
|
page-up (default '<c-b>' and '<pgup>')
|
||||||
|
scroll-up (default '<c-y>')
|
||||||
down (default 'j' and '<down>')
|
down (default 'j' and '<down>')
|
||||||
half-down (default '<c-d>')
|
half-down (default '<c-d>')
|
||||||
page-down (default '<c-f>' and '<pgdn>')
|
page-down (default '<c-f>' and '<pgdn>')
|
||||||
|
scroll-down (default '<c-e>')
|
||||||
.EE
|
.EE
|
||||||
.PP
|
.PP
|
||||||
Move the current file selection upwards/downwards by one/half a page/full page.
|
Move/scroll the current file selection upwards/downwards by one/half a page/full page.
|
||||||
.PP
|
.PP
|
||||||
.EX
|
.EX
|
||||||
updir (default 'h' and '<left>')
|
updir (default 'h' and '<left>')
|
||||||
@@ -274,7 +329,12 @@ Change the current working directory to the parent directory.
|
|||||||
.PP
|
.PP
|
||||||
If the current file is a directory, then change the current directory to it, otherwise, execute the 'open' command. A default 'open' command is provided to call the default system opener asynchronously with the current file as the argument. A custom 'open' command can be defined to override this default.
|
If the current file is a directory, then change the current directory to it, otherwise, execute the 'open' command. A default 'open' command is provided to call the default system opener asynchronously with the current file as the argument. A custom 'open' command can be defined to override this default.
|
||||||
.PP
|
.PP
|
||||||
(See also 'OPENER' variable and 'Opening Files' section)
|
.EX
|
||||||
|
jump-next (default ']')
|
||||||
|
jump-prev (default '[')
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Change the current working directory to the next/previous jumplist item.
|
||||||
.PP
|
.PP
|
||||||
.EX
|
.EX
|
||||||
top (default 'gg' and '<home>')
|
top (default 'gg' and '<home>')
|
||||||
@@ -293,7 +353,7 @@ Toggle the selection of the current file or files given as arguments.
|
|||||||
invert (default 'v')
|
invert (default 'v')
|
||||||
.EE
|
.EE
|
||||||
.PP
|
.PP
|
||||||
Reverse the selection of all files in the current directory (i.e. 'toggle' all files). Selections in other directories are not effected by this command. You can define a new command to select all files in the directory by combining 'invert' with 'unselect' (i.e. `cmd select-all :unselect; invert`), though this will also remove selections in other directories.
|
Reverse the selection of all files in the current directory (i.e. 'toggle' all files). Selections in other directories are not effected by this command. You can define a new command to select all files in the directory by combining 'invert' with 'unselect' (i.e. 'cmd select-all :unselect; invert'), though this will also remove selections in other directories.
|
||||||
.PP
|
.PP
|
||||||
.EX
|
.EX
|
||||||
unselect (default 'u')
|
unselect (default 'u')
|
||||||
@@ -303,15 +363,16 @@ Remove the selection of all files in all directories.
|
|||||||
.PP
|
.PP
|
||||||
.EX
|
.EX
|
||||||
glob-select
|
glob-select
|
||||||
.EE
|
|
||||||
.PP
|
|
||||||
Select files that match the given glob.
|
|
||||||
.PP
|
|
||||||
.EX
|
|
||||||
glob-unselect
|
glob-unselect
|
||||||
.EE
|
.EE
|
||||||
.PP
|
.PP
|
||||||
Unselect files that match the given glob.
|
Select/unselect files that match the given glob.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
calcdirsize
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Calculate the total size for each of the selected directories. Option 'info' should include 'size' and option 'dircounts' should be disabled to show this size.
|
||||||
.PP
|
.PP
|
||||||
.EX
|
.EX
|
||||||
copy (default 'y')
|
copy (default 'y')
|
||||||
@@ -329,7 +390,7 @@ If there are no selections, save the path of the current file to the cut buffer,
|
|||||||
paste (default 'p')
|
paste (default 'p')
|
||||||
.EE
|
.EE
|
||||||
.PP
|
.PP
|
||||||
Copy/Move files in copy/cut buffer to the current working directory.
|
Copy/Move files in copy/cut buffer to the current working directory. A custom 'paste' command can be defined to override this default.
|
||||||
.PP
|
.PP
|
||||||
.EX
|
.EX
|
||||||
clear (default 'c')
|
clear (default 'c')
|
||||||
@@ -383,7 +444,7 @@ Print given arguments to the message line at the bottom and also to the log file
|
|||||||
echoerr
|
echoerr
|
||||||
.EE
|
.EE
|
||||||
.PP
|
.PP
|
||||||
Print given arguments to the message line at the bottom in red color and also to the log file.
|
Print given arguments to the message line at the bottom as 'errorfmt' and also to the log file.
|
||||||
.PP
|
.PP
|
||||||
.EX
|
.EX
|
||||||
cd
|
cd
|
||||||
@@ -401,7 +462,7 @@ Change the current file selection to the given argument.
|
|||||||
delete (modal)
|
delete (modal)
|
||||||
.EE
|
.EE
|
||||||
.PP
|
.PP
|
||||||
Remove the current file or selected file(s).
|
Remove the current file or selected file(s). A custom 'delete' command can be defined to override this default.
|
||||||
.PP
|
.PP
|
||||||
.EX
|
.EX
|
||||||
rename (modal) (default 'r')
|
rename (modal) (default 'r')
|
||||||
@@ -433,29 +494,23 @@ Read a command to evaluate.
|
|||||||
.PP
|
.PP
|
||||||
Read a shell command to execute.
|
Read a shell command to execute.
|
||||||
.PP
|
.PP
|
||||||
(See also 'Prefixes' and 'Shell Commands' sections)
|
|
||||||
.PP
|
|
||||||
.EX
|
.EX
|
||||||
shell-pipe (modal) (default '%')
|
shell-pipe (modal) (default '%')
|
||||||
.EE
|
.EE
|
||||||
.PP
|
.PP
|
||||||
Read a shell command to execute piping its standard I/O to the bottom statline.
|
Read a shell command to execute piping its standard I/O to the bottom statline.
|
||||||
.PP
|
.PP
|
||||||
(See also 'Prefixes' and 'Piping Shell Commands' sections)
|
|
||||||
.PP
|
|
||||||
.EX
|
.EX
|
||||||
shell-wait (modal) (default '!')
|
shell-wait (modal) (default '!')
|
||||||
.EE
|
.EE
|
||||||
.PP
|
.PP
|
||||||
Read a shell command to execute and wait for a key press in the end.
|
Read a shell command to execute and wait for a key press in the end.
|
||||||
.PP
|
.PP
|
||||||
(See also 'Prefixes' and 'Waiting Shell Commands' sections)
|
|
||||||
.PP
|
|
||||||
.EX
|
.EX
|
||||||
shell-async (modal) (default '&')
|
shell-async (modal) (default '&')
|
||||||
.EE
|
.EE
|
||||||
.PP
|
.PP
|
||||||
Read a shell command to execute synchronously without standard I/O.
|
Read a shell command to execute asynchronously without standard I/O.
|
||||||
.PP
|
.PP
|
||||||
.EX
|
.EX
|
||||||
find (modal) (default 'f')
|
find (modal) (default 'f')
|
||||||
@@ -466,8 +521,6 @@ Read a shell command to execute synchronously without standard I/O.
|
|||||||
.PP
|
.PP
|
||||||
Read key(s) to find the appropriate file name match in the forward/backward direction and jump to the next/previous match.
|
Read key(s) to find the appropriate file name match in the forward/backward direction and jump to the next/previous match.
|
||||||
.PP
|
.PP
|
||||||
(See also 'anchorfind', 'findlen', 'wrapscan', 'ignorecase', 'smartcase', 'ignoredia', and 'smartdia' options and 'Searching Files' section)
|
|
||||||
.PP
|
|
||||||
.EX
|
.EX
|
||||||
search (default '/')
|
search (default '/')
|
||||||
search-back (default '?')
|
search-back (default '?')
|
||||||
@@ -477,7 +530,12 @@ Read key(s) to find the appropriate file name match in the forward/backward dire
|
|||||||
.PP
|
.PP
|
||||||
Read a pattern to search for a file name match in the forward/backward direction and jump to the next/previous match.
|
Read a pattern to search for a file name match in the forward/backward direction and jump to the next/previous match.
|
||||||
.PP
|
.PP
|
||||||
(See also 'globsearch', 'incsearch', 'wrapscan', 'ignorecase', 'smartcase', 'ignoredia', and 'smartdia' options and 'Searching Files' section)
|
.EX
|
||||||
|
filter (modal)
|
||||||
|
setfilter
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Command 'filter' reads a pattern to filter out and only view files matching the pattern. Command 'setfilter' does the same but uses an argument to set the filter immediately. You can supply an argument to 'filter', in order to use that as the starting prompt.
|
||||||
.PP
|
.PP
|
||||||
.EX
|
.EX
|
||||||
mark-save (modal) (default 'm')
|
mark-save (modal) (default 'm')
|
||||||
@@ -492,10 +550,22 @@ Save the current directory as a bookmark assigned to the given key.
|
|||||||
Change the current directory to the bookmark assigned to the given key. A special bookmark "'" holds the previous directory after a 'mark-load', 'cd', or 'select' command.
|
Change the current directory to the bookmark assigned to the given key. A special bookmark "'" holds the previous directory after a 'mark-load', 'cd', or 'select' command.
|
||||||
.PP
|
.PP
|
||||||
.EX
|
.EX
|
||||||
mark-remove (modal) (default `"`)
|
mark-remove (modal) (default '"')
|
||||||
.EE
|
.EE
|
||||||
.PP
|
.PP
|
||||||
Remove a bookmark assigned to the given key.
|
Remove a bookmark assigned to the given key.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
tag
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Tag a file with '*' or a single width character given in the argument. You can define a new tag clearing command by combining 'tag' with 'tag-toggle' (i.e. 'cmd tag-clear :tag; tag-toggle').
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
tag-toggle (default 't')
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Tag a file with '*' or a single width character given in the argument if the file is untagged, otherwise remove the tag.
|
||||||
.SH COMMAND LINE COMMANDS
|
.SH COMMAND LINE COMMANDS
|
||||||
This section shows information about command line commands. These should be mostly compatible with readline keybindings. A character refers to a unicode code point, a word consists of letters and digits, and a unix word consists of any non-blank characters.
|
This section shows information about command line commands. These should be mostly compatible with readline keybindings. A character refers to a unicode code point, a word consists of letters and digits, and a unix word consists of any non-blank characters.
|
||||||
.PP
|
.PP
|
||||||
@@ -513,15 +583,10 @@ Autocomplete the current word.
|
|||||||
.PP
|
.PP
|
||||||
.EX
|
.EX
|
||||||
cmd-menu-complete
|
cmd-menu-complete
|
||||||
.EE
|
|
||||||
.PP
|
|
||||||
Autocomplete the current word, then you can press the binded key/s again to cycle completition options.
|
|
||||||
.PP
|
|
||||||
.EX
|
|
||||||
cmd-menu-complete-back
|
cmd-menu-complete-back
|
||||||
.EE
|
.EE
|
||||||
.PP
|
.PP
|
||||||
Autocomplete the current word, then you can press the binded key/s again to cycle completition options backwards.
|
Autocomplete the current word with menu selection. You need to assign keys to these commands (e.g. 'cmap <tab> cmd-menu-complete; cmap <backtab> cmd-menu-complete-back'). You can use the assigned keys assigned to display the menu and then cycle through completion options.
|
||||||
.PP
|
.PP
|
||||||
.EX
|
.EX
|
||||||
cmd-enter (default '<c-j>' and '<enter>')
|
cmd-enter (default '<c-j>' and '<enter>')
|
||||||
@@ -624,6 +689,18 @@ When this option is enabled, find command starts matching patterns from the begi
|
|||||||
.PP
|
.PP
|
||||||
Automatically quit server when there are no clients left connected.
|
Automatically quit server when there are no clients left connected.
|
||||||
.PP
|
.PP
|
||||||
|
.EX
|
||||||
|
cleaner string (default '') (not called if empty)
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
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. One argument is passed to the file, path to the file whose preview should be cleaned. Preview clearing is disabled when the value of this option is left empty.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
dircache bool (default on)
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Cache directory contents.
|
||||||
|
.PP
|
||||||
.EX
|
.EX
|
||||||
dircounts bool (default off)
|
dircounts bool (default off)
|
||||||
.EE
|
.EE
|
||||||
@@ -636,6 +713,12 @@ When this option is enabled, directory sizes show the number of items inside ins
|
|||||||
.PP
|
.PP
|
||||||
Show directories first above regular files.
|
Show directories first above regular files.
|
||||||
.PP
|
.PP
|
||||||
|
.EX
|
||||||
|
dironly bool (default off)
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Show only directories.
|
||||||
|
.PP
|
||||||
.EX
|
.EX
|
||||||
drawbox bool (default off)
|
drawbox bool (default off)
|
||||||
.EE
|
.EE
|
||||||
@@ -670,7 +753,7 @@ When this option is enabled, search command patterns are considered as globs, ot
|
|||||||
hidden bool (default off)
|
hidden bool (default off)
|
||||||
.EE
|
.EE
|
||||||
.PP
|
.PP
|
||||||
Show hidden files. On unix systems, hidden files are determined by the value of 'hiddenfiles'. On windows, only files with hidden attributes are considered hidden files.
|
Show hidden files. On Unix systems, hidden files are determined by the value of 'hiddenfiles'. On Windows, only files with hidden attributes are considered hidden files.
|
||||||
.PP
|
.PP
|
||||||
.EX
|
.EX
|
||||||
hiddenfiles []string (default '.*')
|
hiddenfiles []string (default '.*')
|
||||||
@@ -682,13 +765,13 @@ List of hidden file glob patterns. Patterns can be given as relative or absolute
|
|||||||
icons bool (default off)
|
icons bool (default off)
|
||||||
.EE
|
.EE
|
||||||
.PP
|
.PP
|
||||||
Show icons before each item in the list. By default, only two icons, 🗀 (U+1F5C0) and 🗎 (U+1F5CE), are used for directories and files respectively, as they are supported in the unicode standard. Icons can be configured with an environment variable named 'LF_ICONS'. The syntax of this variable is similar to 'LS_COLORS'. See the wiki page for an example icon configuration.
|
Show icons before each item in the list.
|
||||||
.PP
|
.PP
|
||||||
.EX
|
.EX
|
||||||
ifs string (default '')
|
ifs string (default '')
|
||||||
.EE
|
.EE
|
||||||
.PP
|
.PP
|
||||||
Sets 'IFS' variable in shell commands. It works by adding the assignment to the beginning of the command string as 'IFS='...'; ...'. The reason is that 'IFS' variable is not inherited by the shell for security reasons. This method assumes a POSIX shell syntax and so it can fail for non-POSIX shells. This option has no effect when the value is left empty. This option does not have any effect on windows.
|
Sets 'IFS' variable in shell commands. It works by adding the assignment to the beginning of the command string as "IFS='...'; ...". The reason is that 'IFS' variable is not inherited by the shell for security reasons. This method assumes a POSIX shell syntax and so it can fail for non-POSIX shells. This option has no effect when the value is left empty. This option does not have any effect on Windows.
|
||||||
.PP
|
.PP
|
||||||
.EX
|
.EX
|
||||||
ignorecase bool (default on)
|
ignorecase bool (default on)
|
||||||
@@ -708,12 +791,30 @@ Ignore diacritics in sorting and search patterns.
|
|||||||
.PP
|
.PP
|
||||||
Jump to the first match after each keystroke during searching.
|
Jump to the first match after each keystroke during searching.
|
||||||
.PP
|
.PP
|
||||||
|
.EX
|
||||||
|
incfilter bool (default off)
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Apply filter pattern after each keystroke during filtering.
|
||||||
|
.PP
|
||||||
.EX
|
.EX
|
||||||
info []string (default '')
|
info []string (default '')
|
||||||
.EE
|
.EE
|
||||||
.PP
|
.PP
|
||||||
List of information shown for directory items at the right side of pane. Currently supported information types are 'size', 'time', 'atime', and 'ctime'. Information is only shown when the pane width is more than twice the width of information.
|
List of information shown for directory items at the right side of pane. Currently supported information types are 'size', 'time', 'atime', and 'ctime'. Information is only shown when the pane width is more than twice the width of information.
|
||||||
.PP
|
.PP
|
||||||
|
.EX
|
||||||
|
infotimefmtnew string (default 'Jan _2 15:04')
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Format string of the file time shown in the info column when it matches this year.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
infotimefmtold string (default 'Jan _2 2006')
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Format string of the file time shown in the info column when it doesn't match this year.
|
||||||
|
.PP
|
||||||
.EX
|
.EX
|
||||||
mouse bool (default off)
|
mouse bool (default off)
|
||||||
.EE
|
.EE
|
||||||
@@ -724,7 +825,7 @@ Send mouse events as input.
|
|||||||
number bool (default off)
|
number bool (default off)
|
||||||
.EE
|
.EE
|
||||||
.PP
|
.PP
|
||||||
Show the position number for directory items at the left side of pane. When 'relativenumber' is enabled, only the current line shows the absolute position and relative positions are shown for the rest.
|
Show the position number for directory items at the left side of pane. When 'relativenumber' option is enabled, only the current line shows the absolute position and relative positions are shown for the rest.
|
||||||
.PP
|
.PP
|
||||||
.EX
|
.EX
|
||||||
period int (default 0)
|
period int (default 0)
|
||||||
@@ -742,19 +843,13 @@ Show previews of files and directories at the right most pane. If the file has m
|
|||||||
previewer string (default '') (not filtered if empty)
|
previewer string (default '') (not filtered if empty)
|
||||||
.EE
|
.EE
|
||||||
.PP
|
.PP
|
||||||
Set the path of a previewer file to filter the content of regular files for previewing. The file should be executable. Five arguments are passed to the file, first is the current file name; the second, third, fourth, and fifth are width, height, horizontal position, and vertical position of preview pane respectively. SIGPIPE signal is sent when enough lines are read. If the previewer returns a non-zero exit code, then the preview cache for the given file is disabled. This means that if the file is selected in the future, the previewer is called once again. Preview filtering is disabled and files are displayed as they are when the value of this option is left empty.
|
Set the path of a previewer file to filter the content of regular files for previewing. The file should be executable. 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. SIGPIPE signal is sent when enough lines are read. If the previewer returns a non-zero exit code, then the preview cache for the given file is disabled. This means that if the file is selected in the future, the previewer is called once again. Preview filtering is disabled and files are displayed as they are when the value of this option is left empty.
|
||||||
.PP
|
|
||||||
.EX
|
|
||||||
cleaner string (default '') (not called if empty)
|
|
||||||
.EE
|
|
||||||
.PP
|
|
||||||
Set the path of a cleaner file. This file will be called if previewing is enabled, the previewer is set, and the previously selected file had its preview cache disabled. The file should be executable. One argument is passed to the file; the path to the file whose preview should be cleaned. Preview clearing is disabled when the value of this option is left empty.
|
|
||||||
.PP
|
.PP
|
||||||
.EX
|
.EX
|
||||||
promptfmt string (default "\e033[32;1m%u@%h\e033[0m:\e033[34;1m%d\e033[0m\e033[1m%f\e033[0m")
|
promptfmt string (default "\e033[32;1m%u@%h\e033[0m:\e033[34;1m%d\e033[0m\e033[1m%f\e033[0m")
|
||||||
.EE
|
.EE
|
||||||
.PP
|
.PP
|
||||||
Format string of the prompt shown in the top line. Special expansions are provided, '%u' as the user name, '%h' as the host name, '%w' as the working directory, '%d' as the working directory with a trailing path separator, and '%f' as the file name. Home folder is shown as '~' in the working directory expansion. Directory names are automatically shortened to a single character starting from the left most parent when the prompt does not fit to the screen.
|
Format string of the prompt shown in the top line. Special expansions are provided, '%u' as the user name, '%h' as the host name, '%w' as the working directory, '%d' as the working directory with a trailing path separator, '%f' as the file name, and '%F' as the current filter. Home folder is shown as '~' in the working directory expansion. Directory names are automatically shortened to a single character starting from the left most parent when the prompt does not fit to the screen.
|
||||||
.PP
|
.PP
|
||||||
.EX
|
.EX
|
||||||
ratios []int (default '1:2:3')
|
ratios []int (default '1:2:3')
|
||||||
@@ -781,13 +876,13 @@ Reverse the direction of sort.
|
|||||||
Minimum number of offset lines shown at all times in the top and the bottom of the screen when scrolling. The current line is kept in the middle when this option is set to a large value that is bigger than the half of number of lines. A smaller offset can be used when the current file is close to the beginning or end of the list to show the maximum number of items.
|
Minimum number of offset lines shown at all times in the top and the bottom of the screen when scrolling. The current line is kept in the middle when this option is set to a large value that is bigger than the half of number of lines. A smaller offset can be used when the current file is close to the beginning or end of the list to show the maximum number of items.
|
||||||
.PP
|
.PP
|
||||||
.EX
|
.EX
|
||||||
shell string (default 'sh' for unix and 'cmd' for windows)
|
shell string (default 'sh' for Unix and 'cmd' for Windows)
|
||||||
.EE
|
.EE
|
||||||
.PP
|
.PP
|
||||||
Shell executable to use for shell commands. Shell commands are executed as 'shell shellopts shellflag command -- arguments'.
|
Shell executable to use for shell commands. Shell commands are executed as 'shell shellopts shellflag command -- arguments'.
|
||||||
.PP
|
.PP
|
||||||
.EX
|
.EX
|
||||||
shellflag string (default '-c' for unix and '/c' for windows)
|
shellflag string (default '-c' for Unix and '/c' for Windows)
|
||||||
.EE
|
.EE
|
||||||
.PP
|
.PP
|
||||||
Command line flag used to pass shell commands.
|
Command line flag used to pass shell commands.
|
||||||
@@ -822,6 +917,18 @@ Sort type for directories. Currently supported sort types are 'natural', 'name',
|
|||||||
.PP
|
.PP
|
||||||
Number of space characters to show for horizontal tabulation (U+0009) character.
|
Number of space characters to show for horizontal tabulation (U+0009) character.
|
||||||
.PP
|
.PP
|
||||||
|
.EX
|
||||||
|
tagfmt string (default "\e033[31m%s\e033[0m")
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Format string of the tags.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
tempmarks string (default '')
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Marks to be considered temporary (e.g. 'abc' refers to marks 'a', 'b', and 'c'). These marks are not synced to other clients and they are not saved in the bookmarks file. Note that the special bookmark "'" is always treated as temporary and it does not need to be specified.
|
||||||
|
.PP
|
||||||
.EX
|
.EX
|
||||||
timefmt string (default 'Mon Jan _2 15:04:05 2006')
|
timefmt string (default 'Mon Jan _2 15:04:05 2006')
|
||||||
.EE
|
.EE
|
||||||
@@ -906,19 +1013,67 @@ If this variable is set in the environment, use the same value, otherwise set th
|
|||||||
EDITOR
|
EDITOR
|
||||||
.EE
|
.EE
|
||||||
.PP
|
.PP
|
||||||
If this variable is set in the environment, use the same value, otherwise set the value to 'vi' on unix, 'notepad' in Windows.
|
If this variable is set in the environment, use the same value, otherwise set the value to 'vi' on Unix, 'notepad' in Windows.
|
||||||
.PP
|
.PP
|
||||||
.EX
|
.EX
|
||||||
PAGER
|
PAGER
|
||||||
.EE
|
.EE
|
||||||
.PP
|
.PP
|
||||||
If this variable is set in the environment, use the same value, otherwise set the value to 'less' on unix, 'more' in Windows.
|
If this variable is set in the environment, use the same value, otherwise set the value to 'less' on Unix, 'more' in Windows.
|
||||||
.PP
|
.PP
|
||||||
.EX
|
.EX
|
||||||
SHELL
|
SHELL
|
||||||
.EE
|
.EE
|
||||||
.PP
|
.PP
|
||||||
If this variable is set in the environment, use the same value, otherwise set the value to 'sh' on unix, 'cmd' in Windows.
|
If this variable is set in the environment, use the same value, otherwise set the value to 'sh' on Unix, 'cmd' in Windows.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
lf_{option}
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Value of the {option}.
|
||||||
|
.SH SPECIAL COMMANDS
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
open
|
||||||
|
.EE
|
||||||
|
This shell command can be defined to override the default 'open' command when the current file is not a directory.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
paste
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
This shell command can be defined to override the default 'paste' command.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
rename
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
This shell command can be defined to override the default 'paste' command.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
delete
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
This shell command can be defined to override the default 'delete' command.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
pre-cd
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
This shell command can be defined to be executed before changing a directory.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
on-cd
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
This shell command can be defined to be executed after changing a directory.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
on-quit
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
This shell command can be defined to be executed before quit.
|
||||||
.SH PREFIXES
|
.SH PREFIXES
|
||||||
The following command prefixes are used by lf:
|
The following command prefixes are used by lf:
|
||||||
.PP
|
.PP
|
||||||
@@ -938,7 +1093,7 @@ Characters from '#' to newline are comments and ignored:
|
|||||||
# comments start with '#'
|
# comments start with '#'
|
||||||
.EE
|
.EE
|
||||||
.PP
|
.PP
|
||||||
There are three special commands ('set', 'map', and 'cmd') and their variants for configuration.
|
There are three special commands ('set', 'map', 'cmap', and 'cmd') for configuration.
|
||||||
.PP
|
.PP
|
||||||
Command 'set' is used to set an option which can be boolean, integer, or string:
|
Command 'set' is used to set an option which can be boolean, integer, or string:
|
||||||
.PP
|
.PP
|
||||||
@@ -1148,7 +1303,7 @@ Finally note that we set 'IFS' variable manually in these commands. Instead we c
|
|||||||
.SH PIPING SHELL COMMANDS
|
.SH PIPING SHELL COMMANDS
|
||||||
Regular shell commands have some limitations in some cases. When an output or error message is given and the command exits afterwards, the ui is immediately resumed and there is no way to see the message without dropping to shell again. Also, even when there is no output or error, the ui still needs to be paused while the command is running. This can cause flickering on the screen for short commands and similar distractions for longer commands.
|
Regular shell commands have some limitations in some cases. When an output or error message is given and the command exits afterwards, the ui is immediately resumed and there is no way to see the message without dropping to shell again. Also, even when there is no output or error, the ui still needs to be paused while the command is running. This can cause flickering on the screen for short commands and similar distractions for longer commands.
|
||||||
.PP
|
.PP
|
||||||
Instead of pausing the ui, piping shell commands connects stdin, stdout, and stderr of the command to the statline in the bottom of the ui. This can be useful for programs following the unix philosophy to give no output in the success case, and brief error messages or prompts in other cases.
|
Instead of pausing the ui, piping shell commands connects stdin, stdout, and stderr of the command to the statline in the bottom of the ui. This can be useful for programs following the Unix philosophy to give no output in the success case, and brief error messages or prompts in other cases.
|
||||||
.PP
|
.PP
|
||||||
For example, following rename command prompts for overwrite in the statline if there is an existing file with the given name:
|
For example, following rename command prompts for overwrite in the statline if there is an existing file with the given name:
|
||||||
.PP
|
.PP
|
||||||
@@ -1170,10 +1325,10 @@ Asynchronous shell commands are used to start a command in the background and th
|
|||||||
.SH REMOTE COMMANDS
|
.SH REMOTE COMMANDS
|
||||||
One of the more advanced features in lf is remote commands. All clients connect to a server on startup. It is possible to send commands to all or any of the connected clients over the common server. This is used internally to notify file selection changes to other clients.
|
One of the more advanced features in lf is remote commands. All clients connect to a server on startup. It is possible to send commands to all or any of the connected clients over the common server. This is used internally to notify file selection changes to other clients.
|
||||||
.PP
|
.PP
|
||||||
To use this feature, you need to use a client which supports communicating with a UNIX-domain socket. OpenBSD implementation of netcat (nc) is one such example. You can use it to send a command to the socket file:
|
To use this feature, you need to use a client which supports communicating with a Unix domain socket. OpenBSD implementation of netcat (nc) is one such example. You can use it to send a command to the socket file:
|
||||||
.PP
|
.PP
|
||||||
.EX
|
.EX
|
||||||
echo 'send echo hello world' | nc -U /tmp/lf.${USER}.sock
|
echo 'send echo hello world' | nc -U ${XDG_RUNTIME_DIR:-/tmp}/lf.${USER}.sock
|
||||||
.EE
|
.EE
|
||||||
.PP
|
.PP
|
||||||
Since such a client may not be available everywhere, lf comes bundled with a command line flag to be used as such. When using lf, you do not need to specify the address of the socket file. This is the recommended way of using remote commands since it is shorter and immune to socket file address changes:
|
Since such a client may not be available everywhere, lf comes bundled with a command line flag to be used as such. When using lf, you do not need to specify the address of the socket file. This is the recommended way of using remote commands since it is shorter and immune to socket file address changes:
|
||||||
@@ -1233,9 +1388,9 @@ You can customize copy and move operations by defining a 'paste' command. This i
|
|||||||
cp -R $list .
|
cp -R $list .
|
||||||
elif [ $mode = 'move' ]; then
|
elif [ $mode = 'move' ]; then
|
||||||
mv $list .
|
mv $list .
|
||||||
fi
|
|
||||||
rm ~/.local/share/lf/files
|
rm ~/.local/share/lf/files
|
||||||
lf -remote 'send clear'
|
lf -remote 'send clear'
|
||||||
|
fi
|
||||||
}}
|
}}
|
||||||
.EE
|
.EE
|
||||||
.PP
|
.PP
|
||||||
@@ -1292,16 +1447,16 @@ Following command is provided by default:
|
|||||||
.PP
|
.PP
|
||||||
You may also use any other existing file openers as you like. Possible options are 'libfile-mimeinfo-perl' (executable name is 'mimeopen'), 'rifle' (ranger's default file opener), or 'mimeo' to name a few.
|
You may also use any other existing file openers as you like. Possible options are 'libfile-mimeinfo-perl' (executable name is 'mimeopen'), 'rifle' (ranger's default file opener), or 'mimeo' to name a few.
|
||||||
.SH PREVIEWING FILES
|
.SH PREVIEWING FILES
|
||||||
lf previews files on the preview pane by printing the file until the end or the preview pane is filled. This output can be enhanced by providing a custom preview script for filtering. This can be used to highlight source codes, list contents of archive files or view pdf or image files as text to name few. For coloring lf recognizes ansi escape codes.
|
lf previews files on the preview pane by printing the file until the end or the preview pane is filled. This output can be enhanced by providing a custom preview script for filtering. This can be used to highlight source codes, list contents of archive files or view pdf or image files to name few. For coloring lf recognizes ansi escape codes.
|
||||||
.PP
|
.PP
|
||||||
In order to use this feature you need to set the value of 'previewer' option to the path of an executable file. lf passes the current file name as the first argument and the height of the preview pane as the second argument when running this file. Output of the execution is printed in the preview pane. You may want to use the same script in your pager mapping as well if any:
|
In order to use this feature you need to set the value of 'previewer' option to the path of an executable file. Five arguments are passed to the file, (1) current file name, (2) width, (3) height, (4) horizontal position, and (5) vertical position of preview pane respectively. Output of the execution is printed in the preview pane. You may also want to use the same script in your pager mapping as well:
|
||||||
.PP
|
.PP
|
||||||
.EX
|
.EX
|
||||||
set previewer ~/.config/lf/pv.sh
|
set previewer ~/.config/lf/pv.sh
|
||||||
map i $~/.config/lf/pv.sh $f | less -R
|
map i $~/.config/lf/pv.sh $f | less -R
|
||||||
.EE
|
.EE
|
||||||
.PP
|
.PP
|
||||||
For 'less' pager, you may instead utilize 'LESSOPEN' mechanism so that useful information about the file such as the full path of the file can be displayed in the statusline below:
|
For 'less' pager, you may instead utilize 'LESSOPEN' mechanism so that useful information about the file such as the full path of the file can still be displayed in the statusline below:
|
||||||
.PP
|
.PP
|
||||||
.EX
|
.EX
|
||||||
set previewer ~/.config/lf/pv.sh
|
set previewer ~/.config/lf/pv.sh
|
||||||
@@ -1333,7 +1488,7 @@ Another important consideration for efficiency is the use of programs with short
|
|||||||
.PP
|
.PP
|
||||||
You may also use an existing preview filter as you like. Your system may already come with a preview filter named 'lesspipe'. These filters may have a mechanism to add user customizations as well. See the related documentations for more information.
|
You may also use an existing preview filter as you like. Your system may already come with a preview filter named 'lesspipe'. These filters may have a mechanism to add user customizations as well. See the related documentations for more information.
|
||||||
.SH CHANGING DIRECTORY
|
.SH CHANGING DIRECTORY
|
||||||
lf changes the working directory of the process to the current directory so that shell commands always work in the displayed directory. After quitting, it returns to the original directory where it is first launched like all shell programs. If you want to stay in the current directory after quitting, you can use one of the example wrapper shell scripts provided in the repository.
|
lf changes the working directory of the process to the current directory so that shell commands always work in the displayed directory. After quitting, it returns to the original directory where it is first launched like all shell programs. If you want to stay in the current directory after quitting, you can use one of the example lfcd wrapper shell scripts provided in the repository at https://github.com/gokcehan/lf/tree/master/etc
|
||||||
.PP
|
.PP
|
||||||
There is a special command 'on-cd' that runs a shell command when it is defined and the directory is changed. You can define it just as you would define any other command:
|
There is a special command 'on-cd' that runs a shell command when it is defined and the directory is changed. You can define it just as you would define any other command:
|
||||||
.PP
|
.PP
|
||||||
@@ -1362,11 +1517,13 @@ If you want to print escape sequences, you may redirect 'printf' output to '/dev
|
|||||||
This command runs whenever you change directory but not on startup. You can add an extra call to make it run on startup as well:
|
This command runs whenever you change directory but not on startup. You can add an extra call to make it run on startup as well:
|
||||||
.PP
|
.PP
|
||||||
.EX
|
.EX
|
||||||
cmd on-cd &{{ # ... }}
|
cmd on-cd &{{ ... }}
|
||||||
on-cd
|
on-cd
|
||||||
.EE
|
.EE
|
||||||
.PP
|
.PP
|
||||||
Note that all shell commands are possible but `%` and `&` are usually more appropriate as `$` and `!` causes flickers and pauses respectively.
|
Note that all shell commands are possible but '%' and '&' are usually more appropriate as '$' and '!' causes flickers and pauses respectively.
|
||||||
|
.PP
|
||||||
|
There is also a 'pre-cd' command, that works like 'on-cd', but is run before the directory is actually changed.
|
||||||
.SH COLORS
|
.SH COLORS
|
||||||
lf tries to automatically adapt its colors to the environment. It starts with a default colorscheme and updates colors using values of existing environment variables possibly by overwriting its previous values. Colors are set in the following order:
|
lf tries to automatically adapt its colors to the environment. It starts with a default colorscheme and updates colors using values of existing environment variables possibly by overwriting its previous values. Colors are set in the following order:
|
||||||
.PP
|
.PP
|
||||||
@@ -1375,17 +1532,18 @@ lf tries to automatically adapt its colors to the environment. It starts with a
|
|||||||
2. LSCOLORS (Mac/BSD ls)
|
2. LSCOLORS (Mac/BSD ls)
|
||||||
3. LS_COLORS (GNU ls)
|
3. LS_COLORS (GNU ls)
|
||||||
4. LF_COLORS (lf specific)
|
4. LF_COLORS (lf specific)
|
||||||
|
5. colors file (lf specific)
|
||||||
.EE
|
.EE
|
||||||
.PP
|
.PP
|
||||||
Please refer to the corresponding man pages for more information about 'LSCOLORS' and 'LS_COLORS'. 'LF_COLORS' is provided with the same syntax as 'LS_COLORS' in case you want to configure colors only for lf but not ls. This can be useful since there are some differences between ls and lf, though one should expect the same behavior for common cases.
|
Please refer to the corresponding man pages for more information about 'LSCOLORS' and 'LS_COLORS'. 'LF_COLORS' is provided with the same syntax as 'LS_COLORS' in case you want to configure colors only for lf but not ls. This can be useful since there are some differences between ls and lf, though one should expect the same behavior for common cases. Colors file is provided for easier configuration without environment variables. This file should consist of whitespace separated pairs with '#' character to start comments until the end of line.
|
||||||
.PP
|
.PP
|
||||||
You can configure lf colors in two different ways. First, you can only configure 8 basic colors used by your terminal and lf should pick up those colors automatically. Depending on your terminal, you should be able to select your colors from a 24-bit palette. This is the recommended approach as colors used by other programs will also match each other.
|
You can configure lf colors in two different ways. First, you can only configure 8 basic colors used by your terminal and lf should pick up those colors automatically. Depending on your terminal, you should be able to select your colors from a 24-bit palette. This is the recommended approach as colors used by other programs will also match each other.
|
||||||
.PP
|
.PP
|
||||||
Second, you can set the values of environmental variables mentioned above for fine grained customization. Note that 'LS_COLORS/LF_COLORS' are more powerful than 'LSCOLORS' and they can be used even when GNU programs are not installed on the system. You can combine this second method with the first method for best results.
|
Second, you can set the values of environment variables or colors file mentioned above for fine grained customization. Note that 'LS_COLORS/LF_COLORS' are more powerful than 'LSCOLORS' and they can be used even when GNU programs are not installed on the system. You can combine this second method with the first method for best results.
|
||||||
.PP
|
.PP
|
||||||
Lastly, you may also want to configure the colors of the prompt line to match the rest of the colors. Colors of the prompt line can be configured using the 'promptfmt' option which can include hardcoded colors as ansi escapes. See the default value of this option to have an idea about how to color this line.
|
Lastly, you may also want to configure the colors of the prompt line to match the rest of the colors. Colors of the prompt line can be configured using the 'promptfmt' option which can include hardcoded colors as ansi escapes. See the default value of this option to have an idea about how to color this line.
|
||||||
.PP
|
.PP
|
||||||
It is worth noting that lf uses as many colors are advertised by your terminal's entry in your systems terminfo or infocmp database, if this is not present lf will default to an internal database. For terminals supporting 24-bit (or "true") color that do not have a database entry (or one that does not advertise all capabilities), support can be enabled by either setting the '$COLORTERM' variable to "truecolor" or ensuring '$TERM' is set to a value that ends with "-truecolor".
|
It is worth noting that lf uses as many colors advertised by your terminal's entry in terminfo or infocmp databases on your system. If an entry is not present, it falls back to an internal database. If your terminal supports 24-bit colors but either does not have a database entry or does not advertise all capabilities, you can enable support by setting the '$COLORTERM' variable to 'truecolor' or ensuring '$TERM' is set to a value that ends with '-truecolor'.
|
||||||
.PP
|
.PP
|
||||||
Default lf colors are mostly taken from GNU dircolors defaults. These defaults use 8 basic colors and bold attribute. Default dircolors entries with background colors are simplified to avoid confusion with current file selection in lf. Similarly, there are only file type matchings and extension matchings are left out for simplicity. Default values are as follows given with their matching order in lf:
|
Default lf colors are mostly taken from GNU dircolors defaults. These defaults use 8 basic colors and bold attribute. Default dircolors entries with background colors are simplified to avoid confusion with current file selection in lf. Similarly, there are only file type matchings and extension matchings are left out for simplicity. Default values are as follows given with their matching order in lf:
|
||||||
.PP
|
.PP
|
||||||
@@ -1406,16 +1564,17 @@ Default lf colors are mostly taken from GNU dircolors defaults. These defaults u
|
|||||||
fi 00
|
fi 00
|
||||||
.EE
|
.EE
|
||||||
.PP
|
.PP
|
||||||
Note that, lf first tries matching file names and then falls back to file types. The full order of matchings from most specific to least are as follows:
|
Note that lf first tries matching file names and then falls back to file types. The full order of matchings from most specific to least are as follows:
|
||||||
.PP
|
.PP
|
||||||
.EX
|
.EX
|
||||||
1. Full Path (e.g. '~/.config/lf/lfrc')
|
1. Full Path (e.g. '~/.config/lf/lfrc')
|
||||||
2. Dir Name (e.g. '.git/') (only matches dirs with a trailing slash at the end)
|
2. Dir Name (e.g. '.git/') (only matches dirs with a trailing slash at the end)
|
||||||
3. File Type (e.g. 'ln') (except 'fi')
|
3. File Type (e.g. 'ln') (except 'fi')
|
||||||
4. File Name (e.g. '.git*') (only matches files with a trailing star at the end)
|
4. File Name (e.g. 'README*')
|
||||||
5. Base Name (e.g. 'README.*')
|
5. File Name (e.g. '*README')
|
||||||
6. Extension (e.g. '*.txt')
|
6. Base Name (e.g. 'README.*')
|
||||||
7. Default (i.e. 'fi')
|
7. Extension (e.g. '*.txt')
|
||||||
|
8. Default (i.e. 'fi')
|
||||||
.EE
|
.EE
|
||||||
.PP
|
.PP
|
||||||
For example, given a regular text file '/path/to/README.txt', the following entries are checked in the configuration and the first one to match is used:
|
For example, given a regular text file '/path/to/README.txt', the following entries are checked in the configuration and the first one to match is used:
|
||||||
@@ -1425,9 +1584,10 @@ For example, given a regular text file '/path/to/README.txt', the following entr
|
|||||||
2. (skipped since the file is not a directory)
|
2. (skipped since the file is not a directory)
|
||||||
3. (skipped since the file is of type 'fi')
|
3. (skipped since the file is of type 'fi')
|
||||||
4. 'README.txt*'
|
4. 'README.txt*'
|
||||||
5. 'README.*'
|
5. '*README.txt'
|
||||||
6. '*.txt'
|
6. 'README.*'
|
||||||
7. 'fi'
|
7. '*.txt'
|
||||||
|
8. 'fi'
|
||||||
.EE
|
.EE
|
||||||
.PP
|
.PP
|
||||||
Given a regular directory '/path/to/example.d', the following entries are checked in the configuration and the first one to match is used:
|
Given a regular directory '/path/to/example.d', the following entries are checked in the configuration and the first one to match is used:
|
||||||
@@ -1437,9 +1597,10 @@ Given a regular directory '/path/to/example.d', the following entries are checke
|
|||||||
2. 'example.d/'
|
2. 'example.d/'
|
||||||
3. 'di'
|
3. 'di'
|
||||||
4. 'example.d*'
|
4. 'example.d*'
|
||||||
5. 'example.*'
|
5. '*example.d'
|
||||||
6. '*.d'
|
6. 'example.*'
|
||||||
7. 'fi'
|
7. '*.d'
|
||||||
|
8. 'fi'
|
||||||
.EE
|
.EE
|
||||||
.PP
|
.PP
|
||||||
Note that glob-like patterns do not actually perform glob matching due to performance reasons.
|
Note that glob-like patterns do not actually perform glob matching due to performance reasons.
|
||||||
@@ -1447,7 +1608,7 @@ Note that glob-like patterns do not actually perform glob matching due to perfor
|
|||||||
For example, you can set a variable as follows:
|
For example, you can set a variable as follows:
|
||||||
.PP
|
.PP
|
||||||
.EX
|
.EX
|
||||||
export LF_COLORS="~/Documents=01;31:~/Downloads=01;31:~/.local/share=01;31:~/.config/lf/lfrc=31:.git/=01;32:.git=32:.gitignore=32:Makefile=32:README.*=33:*.txt=34:*.md=34:ln=01;36:di=01;34:ex=01;32:"
|
export LF_COLORS="~/Documents=01;31:~/Downloads=01;31:~/.local/share=01;31:~/.config/lf/lfrc=31:.git/=01;32:.git*=32:*.gitignore=32:*Makefile=32:README.*=33:*.txt=34:*.md=34:ln=01;36:di=01;34:ex=01;32:"
|
||||||
.EE
|
.EE
|
||||||
.PP
|
.PP
|
||||||
Having all entries on a single line can make it hard to read. You may instead divide it to multiple lines in between double quotes by escaping newlines with backslashes as follows:
|
Having all entries on a single line can make it hard to read. You may instead divide it to multiple lines in between double quotes by escaping newlines with backslashes as follows:
|
||||||
@@ -1459,9 +1620,9 @@ Having all entries on a single line can make it hard to read. You may instead di
|
|||||||
~/.local/share=01;31:\e
|
~/.local/share=01;31:\e
|
||||||
~/.config/lf/lfrc=31:\e
|
~/.config/lf/lfrc=31:\e
|
||||||
.git/=01;32:\e
|
.git/=01;32:\e
|
||||||
.git=32:\e
|
.git*=32:\e
|
||||||
.gitignore=32:\e
|
*.gitignore=32:\e
|
||||||
Makefile=32:\e
|
*Makefile=32:\e
|
||||||
README.*=33:\e
|
README.*=33:\e
|
||||||
*.txt=34:\e
|
*.txt=34:\e
|
||||||
*.md=34:\e
|
*.md=34:\e
|
||||||
@@ -1471,31 +1632,25 @@ Having all entries on a single line can make it hard to read. You may instead di
|
|||||||
"
|
"
|
||||||
.EE
|
.EE
|
||||||
.PP
|
.PP
|
||||||
Having such a long variable definition in a shell configuration file might be undesirable. You may instead put this definition in a separate file and source it in your shell configuration file as follows:
|
Having such a long variable definition in a shell configuration file might be undesirable. You may instead use the colors file for configuration. A sample colors file can be found at https://github.com/gokcehan/lf/blob/master/etc/colors.example You may also see the wiki page for ansi escape codes https://en.wikipedia.org/wiki/ANSI_escape_code
|
||||||
.PP
|
|
||||||
.EX
|
|
||||||
[ -f "/path/to/colors" ] && source "/path/to/colors"
|
|
||||||
.EE
|
|
||||||
.PP
|
|
||||||
See the wiki page for ansi escape codes https://en.wikipedia.org/wiki/ANSI_escape_code.
|
|
||||||
.SH ICONS
|
.SH ICONS
|
||||||
Icons are configured using 'LF_ICONS' environment variable. This variable uses the same syntax as 'LS_COLORS/LF_COLORS'. Instead of colors, you should put a single characters as values of entries. Do not forget to enable 'icons' option to see the icons. Default values are as follows given with their matching order in lf:
|
Icons are configured using 'LF_ICONS' environment variable or an icons file. The variable uses the same syntax as 'LS_COLORS/LF_COLORS'. Instead of colors, you should put a single characters as values of entries. Icons file should consist of whitespace separated pairs with '#' character to start comments until the end of line. Do not forget to enable 'icons' option to see the icons. Default values are as follows given with their matching order in lf:
|
||||||
.PP
|
.PP
|
||||||
.EX
|
.EX
|
||||||
ln 🗎
|
ln l
|
||||||
or 🗎
|
or l
|
||||||
tw 🗀
|
tw t
|
||||||
ow 🗀
|
ow d
|
||||||
st 🗀
|
st t
|
||||||
di 🗀
|
di d
|
||||||
pi 🗎
|
pi p
|
||||||
so 🗎
|
so s
|
||||||
bd 🗎
|
bd b
|
||||||
cd 🗎
|
cd c
|
||||||
su 🗎
|
su u
|
||||||
sg 🗎
|
sg g
|
||||||
ex 🗎
|
ex x
|
||||||
fi 🗎
|
fi -
|
||||||
.EE
|
.EE
|
||||||
.PP
|
.PP
|
||||||
See the wiki page for an example icons configuration https://github.com/gokcehan/lf/wiki/Icons.
|
A sample icons file can be found at https://github.com/gokcehan/lf/blob/master/etc/icons.example
|
||||||
@@ -30,7 +30,6 @@ var (
|
|||||||
gSocketProt string
|
gSocketProt string
|
||||||
gSocketPath string
|
gSocketPath string
|
||||||
gLogPath string
|
gLogPath string
|
||||||
gServerLogPath string
|
|
||||||
gSelect string
|
gSelect string
|
||||||
gConfigPath string
|
gConfigPath string
|
||||||
gCommands arrayFlag
|
gCommands arrayFlag
|
||||||
@@ -68,7 +67,7 @@ func exportEnvVars() {
|
|||||||
|
|
||||||
dir, err := os.Getwd()
|
dir, err := os.Getwd()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "%s\n", err)
|
fmt.Fprintf(os.Stderr, "getting current directory: %s\n", err)
|
||||||
}
|
}
|
||||||
os.Setenv("OLDPWD", dir)
|
os.Setenv("OLDPWD", dir)
|
||||||
|
|
||||||
@@ -185,6 +184,18 @@ func checkServer() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
flag.Usage = func() {
|
||||||
|
f := flag.CommandLine.Output()
|
||||||
|
fmt.Fprintln(f, "lf - Terminal file manager")
|
||||||
|
fmt.Fprintln(f, "")
|
||||||
|
fmt.Fprintf(f, "Usage: %s [options] [cd-or-select-path]\n\n", os.Args[0])
|
||||||
|
fmt.Fprintln(f, " cd-or-select-path")
|
||||||
|
fmt.Fprintln(f, " set the initial dir or file selection to the given argument")
|
||||||
|
fmt.Fprintln(f, "")
|
||||||
|
fmt.Fprintln(f, "Options:")
|
||||||
|
flag.PrintDefaults()
|
||||||
|
}
|
||||||
|
|
||||||
showDoc := flag.Bool(
|
showDoc := flag.Bool(
|
||||||
"doc",
|
"doc",
|
||||||
false,
|
false,
|
||||||
@@ -239,6 +250,11 @@ func main() {
|
|||||||
"command",
|
"command",
|
||||||
"command to execute on client initialization")
|
"command to execute on client initialization")
|
||||||
|
|
||||||
|
flag.StringVar(&gLogPath,
|
||||||
|
"log",
|
||||||
|
"",
|
||||||
|
"path to the log file to write messages")
|
||||||
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
gSocketProt = gDefaultSocketProt
|
gSocketProt = gDefaultSocketProt
|
||||||
@@ -265,8 +281,15 @@ func main() {
|
|||||||
log.Fatalf("remote command: %s", err)
|
log.Fatalf("remote command: %s", err)
|
||||||
}
|
}
|
||||||
case *serverMode:
|
case *serverMode:
|
||||||
|
if gLogPath != "" && !filepath.IsAbs(gLogPath) {
|
||||||
|
wd, err := os.Getwd()
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("getting current directory: %s", err)
|
||||||
|
} else {
|
||||||
|
gLogPath = filepath.Join(wd, gLogPath)
|
||||||
|
}
|
||||||
|
}
|
||||||
os.Chdir(gUser.HomeDir)
|
os.Chdir(gUser.HomeDir)
|
||||||
gServerLogPath = filepath.Join(os.TempDir(), fmt.Sprintf("lf.%s.server.log", gUser.Username))
|
|
||||||
serve()
|
serve()
|
||||||
default:
|
default:
|
||||||
gSingleMode = *singleMode
|
gSingleMode = *singleMode
|
||||||
@@ -276,12 +299,12 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
gClientID = os.Getpid()
|
gClientID = os.Getpid()
|
||||||
gLogPath = filepath.Join(os.TempDir(), fmt.Sprintf("lf.%s.%d.log", gUser.Username, gClientID))
|
|
||||||
switch flag.NArg() {
|
switch flag.NArg() {
|
||||||
case 0:
|
case 0:
|
||||||
_, err := os.Getwd()
|
_, err := os.Getwd()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "%s\n", err)
|
fmt.Fprintf(os.Stderr, "getting current directory: %s\n", err)
|
||||||
os.Exit(2)
|
os.Exit(2)
|
||||||
}
|
}
|
||||||
case 1:
|
case 1:
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bufio"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
@@ -133,6 +135,72 @@ func splitWord(s string) (word, rest string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This function reads whitespace separated string pairs at each line. Single
|
||||||
|
// or double quotes can be used to escape whitespaces. Hash characters can be
|
||||||
|
// used to add a comment until the end of line. Leading and trailing space is
|
||||||
|
// trimmed. Empty lines are skipped.
|
||||||
|
func readPairs(r io.Reader) ([][]string, error) {
|
||||||
|
var pairs [][]string
|
||||||
|
s := bufio.NewScanner(r)
|
||||||
|
for s.Scan() {
|
||||||
|
line := s.Text()
|
||||||
|
|
||||||
|
squote, dquote := false, false
|
||||||
|
for i := 0; i < len(line); i++ {
|
||||||
|
if line[i] == '\'' && !dquote {
|
||||||
|
squote = !squote
|
||||||
|
} else if line[i] == '"' && !squote {
|
||||||
|
dquote = !dquote
|
||||||
|
}
|
||||||
|
if !squote && !dquote && line[i] == '#' {
|
||||||
|
line = line[:i]
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
line = strings.TrimSpace(line)
|
||||||
|
|
||||||
|
if line == "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
squote, dquote = false, false
|
||||||
|
pair := strings.FieldsFunc(line, func(r rune) bool {
|
||||||
|
if r == '\'' && !dquote {
|
||||||
|
squote = !squote
|
||||||
|
} else if r == '"' && !squote {
|
||||||
|
dquote = !dquote
|
||||||
|
}
|
||||||
|
return !squote && !dquote && unicode.IsSpace(r)
|
||||||
|
})
|
||||||
|
|
||||||
|
if len(pair) != 2 {
|
||||||
|
return nil, fmt.Errorf("expected pair but found: %s", s.Text())
|
||||||
|
}
|
||||||
|
|
||||||
|
for i := 0; i < len(pair); i++ {
|
||||||
|
squote, dquote = false, false
|
||||||
|
buf := make([]rune, 0, len(pair[i]))
|
||||||
|
for _, r := range pair[i] {
|
||||||
|
if r == '\'' && !dquote {
|
||||||
|
squote = !squote
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if r == '"' && !squote {
|
||||||
|
dquote = !dquote
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
buf = append(buf, r)
|
||||||
|
}
|
||||||
|
pair[i] = string(buf)
|
||||||
|
}
|
||||||
|
|
||||||
|
pairs = append(pairs, pair)
|
||||||
|
}
|
||||||
|
|
||||||
|
return pairs, nil
|
||||||
|
}
|
||||||
|
|
||||||
// This function converts a size in bytes to a human readable form using metric
|
// This function converts a size in bytes to a human readable form using metric
|
||||||
// suffixes (e.g. 1K = 1000). For values less than 10 the first significant
|
// suffixes (e.g. 1K = 1000). For values less than 10 the first significant
|
||||||
// digit is shown, otherwise it is hidden. Numbers are always rounded down.
|
// digit is shown, otherwise it is hidden. Numbers are always rounded down.
|
||||||
|
|||||||
+27
-2
@@ -1,13 +1,16 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"os"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestIsRoot(t *testing.T) {
|
func TestIsRoot(t *testing.T) {
|
||||||
if !isRoot("/") {
|
sep := string(os.PathSeparator)
|
||||||
t.Errorf(`"/" is root`)
|
if !isRoot(sep) {
|
||||||
|
t.Errorf(`"%s" is root`, sep)
|
||||||
}
|
}
|
||||||
|
|
||||||
paths := []string{
|
paths := []string{
|
||||||
@@ -163,6 +166,28 @@ func TestSplitWord(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestReadPairs(t *testing.T) {
|
||||||
|
tests := []struct {
|
||||||
|
s string
|
||||||
|
exp [][]string
|
||||||
|
}{
|
||||||
|
{"foo bar", [][]string{{"foo", "bar"}}},
|
||||||
|
{"foo bar ", [][]string{{"foo", "bar"}}},
|
||||||
|
{" foo bar", [][]string{{"foo", "bar"}}},
|
||||||
|
{" foo bar ", [][]string{{"foo", "bar"}}},
|
||||||
|
{"foo bar#baz", [][]string{{"foo", "bar"}}},
|
||||||
|
{"foo bar #baz", [][]string{{"foo", "bar"}}},
|
||||||
|
{`'foo#baz' bar`, [][]string{{"foo#baz", "bar"}}},
|
||||||
|
{`"foo#baz" bar`, [][]string{{"foo#baz", "bar"}}},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, test := range tests {
|
||||||
|
if got, _ := readPairs(strings.NewReader(test.s)); !reflect.DeepEqual(got, test.exp) {
|
||||||
|
t.Errorf("at input '%v' expected '%v' but got '%v'", test.s, test.exp, got)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestHumanize(t *testing.T) {
|
func TestHumanize(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
i int64
|
i int64
|
||||||
|
|||||||
@@ -32,11 +32,22 @@ type file struct {
|
|||||||
linkTarget string
|
linkTarget string
|
||||||
path string
|
path string
|
||||||
dirCount int
|
dirCount int
|
||||||
|
dirSize int64
|
||||||
accessTime time.Time
|
accessTime time.Time
|
||||||
changeTime time.Time
|
changeTime time.Time
|
||||||
ext string
|
ext string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (file *file) TotalSize() int64 {
|
||||||
|
if file.IsDir() {
|
||||||
|
if file.dirSize >= 0 {
|
||||||
|
return file.dirSize
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
return file.Size()
|
||||||
|
}
|
||||||
|
|
||||||
func readdir(path string) ([]*file, error) {
|
func readdir(path string) ([]*file, error) {
|
||||||
f, err := os.Open(path)
|
f, err := os.Open(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -50,11 +61,13 @@ func readdir(path string) ([]*file, error) {
|
|||||||
fpath := filepath.Join(path, fname)
|
fpath := filepath.Join(path, fname)
|
||||||
|
|
||||||
lstat, err := os.Lstat(fpath)
|
lstat, err := os.Lstat(fpath)
|
||||||
|
|
||||||
if os.IsNotExist(err) {
|
if os.IsNotExist(err) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return files, err
|
log.Printf("getting file information: %s", err)
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
var linkState linkState
|
var linkState linkState
|
||||||
@@ -89,12 +102,30 @@ func readdir(path string) ([]*file, error) {
|
|||||||
// i.e. directories, filenames without extensions
|
// i.e. directories, filenames without extensions
|
||||||
ext := filepath.Ext(fpath)
|
ext := filepath.Ext(fpath)
|
||||||
|
|
||||||
|
dirCount := -1
|
||||||
|
if lstat.IsDir() && gOpts.dircounts {
|
||||||
|
d, err := os.Open(fpath)
|
||||||
|
if err != nil {
|
||||||
|
dirCount = -2
|
||||||
|
} else {
|
||||||
|
names, err := d.Readdirnames(1000)
|
||||||
|
d.Close()
|
||||||
|
|
||||||
|
if names == nil && err != io.EOF {
|
||||||
|
dirCount = -2
|
||||||
|
} else {
|
||||||
|
dirCount = len(names)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
files = append(files, &file{
|
files = append(files, &file{
|
||||||
FileInfo: lstat,
|
FileInfo: lstat,
|
||||||
linkState: linkState,
|
linkState: linkState,
|
||||||
linkTarget: linkTarget,
|
linkTarget: linkTarget,
|
||||||
path: fpath,
|
path: fpath,
|
||||||
dirCount: -1,
|
dirCount: dirCount,
|
||||||
|
dirSize: -1,
|
||||||
accessTime: at,
|
accessTime: at,
|
||||||
changeTime: ct,
|
changeTime: ct,
|
||||||
ext: ext,
|
ext: ext,
|
||||||
@@ -113,7 +144,9 @@ type dir struct {
|
|||||||
files []*file // displayed files in directory including or excluding hidden ones
|
files []*file // displayed files in directory including or excluding hidden ones
|
||||||
allFiles []*file // all files in directory including hidden ones (same array as files)
|
allFiles []*file // all files in directory including hidden ones (same array as files)
|
||||||
sortType sortType // sort method and options from last sort
|
sortType sortType // sort method and options from last sort
|
||||||
|
dironly bool // dironly value from last sort
|
||||||
hiddenfiles []string // hiddenfiles value from last sort
|
hiddenfiles []string // hiddenfiles value from last sort
|
||||||
|
filter []string // last filter for this directory
|
||||||
ignorecase bool // ignorecase value from last sort
|
ignorecase bool // ignorecase value from last sort
|
||||||
ignoredia bool // ignoredia value from last sort
|
ignoredia bool // ignoredia value from last sort
|
||||||
noPerm bool // whether lf has no permission to open the directory
|
noPerm bool // whether lf has no permission to open the directory
|
||||||
@@ -150,6 +183,7 @@ func normalize(s1, s2 string, ignorecase, ignoredia bool) (string, string) {
|
|||||||
|
|
||||||
func (dir *dir) sort() {
|
func (dir *dir) sort() {
|
||||||
dir.sortType = gOpts.sortType
|
dir.sortType = gOpts.sortType
|
||||||
|
dir.dironly = gOpts.dironly
|
||||||
dir.hiddenfiles = gOpts.hiddenfiles
|
dir.hiddenfiles = gOpts.hiddenfiles
|
||||||
dir.ignorecase = gOpts.ignorecase
|
dir.ignorecase = gOpts.ignorecase
|
||||||
dir.ignoredia = gOpts.ignoredia
|
dir.ignoredia = gOpts.ignoredia
|
||||||
@@ -169,7 +203,7 @@ func (dir *dir) sort() {
|
|||||||
})
|
})
|
||||||
case sizeSort:
|
case sizeSort:
|
||||||
sort.SliceStable(dir.files, func(i, j int) bool {
|
sort.SliceStable(dir.files, func(i, j int) bool {
|
||||||
return dir.files[i].Size() < dir.files[j].Size()
|
return dir.files[i].TotalSize() < dir.files[j].TotalSize()
|
||||||
})
|
})
|
||||||
case timeSort:
|
case timeSort:
|
||||||
sort.SliceStable(dir.files, func(i, j int) bool {
|
sort.SliceStable(dir.files, func(i, j int) bool {
|
||||||
@@ -219,6 +253,26 @@ func (dir *dir) sort() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// when dironly option is enabled, we move files to the beginning of our file
|
||||||
|
// list and then set the beginning of displayed files to the first directory
|
||||||
|
// in the list
|
||||||
|
if dir.dironly {
|
||||||
|
sort.SliceStable(dir.files, func(i, j int) bool {
|
||||||
|
if !dir.files[i].IsDir() && !dir.files[j].IsDir() {
|
||||||
|
return i < j
|
||||||
|
}
|
||||||
|
return !dir.files[i].IsDir()
|
||||||
|
})
|
||||||
|
dir.files = func() []*file {
|
||||||
|
for i, f := range dir.files {
|
||||||
|
if f.IsDir() {
|
||||||
|
return dir.files[i:]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return dir.files[len(dir.files):]
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
|
||||||
// when hidden option is disabled, we move hidden files to the
|
// when hidden option is disabled, we move hidden files to the
|
||||||
// beginning of our file list and then set the beginning of displayed
|
// beginning of our file list and then set the beginning of displayed
|
||||||
// files to the first non-hidden file in the list
|
// files to the first non-hidden file in the list
|
||||||
@@ -232,21 +286,41 @@ func (dir *dir) sort() {
|
|||||||
for i, f := range dir.files {
|
for i, f := range dir.files {
|
||||||
if !isHidden(f, dir.path, dir.hiddenfiles) {
|
if !isHidden(f, dir.path, dir.hiddenfiles) {
|
||||||
dir.files = dir.files[i:]
|
dir.files = dir.files[i:]
|
||||||
return
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if len(dir.files) > 0 && isHidden(dir.files[len(dir.files)-1], dir.path, dir.hiddenfiles) {
|
||||||
dir.files = dir.files[len(dir.files):]
|
dir.files = dir.files[len(dir.files):]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(dir.filter) != 0 {
|
||||||
|
sort.SliceStable(dir.files, func(i, j int) bool {
|
||||||
|
if isFiltered(dir.files[i], dir.filter) && isFiltered(dir.files[j], dir.filter) {
|
||||||
|
return i < j
|
||||||
|
}
|
||||||
|
return isFiltered(dir.files[i], dir.filter)
|
||||||
|
})
|
||||||
|
for i, f := range dir.files {
|
||||||
|
if !isFiltered(f, dir.filter) {
|
||||||
|
dir.files = dir.files[i:]
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(dir.files) > 0 && isFiltered(dir.files[len(dir.files)-1], dir.filter) {
|
||||||
|
dir.files = dir.files[len(dir.files):]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dir.ind = max(dir.ind, 0)
|
||||||
|
dir.ind = min(dir.ind, len(dir.files)-1)
|
||||||
|
}
|
||||||
|
|
||||||
func (dir *dir) name() string {
|
func (dir *dir) name() string {
|
||||||
if len(dir.files) == 0 {
|
if len(dir.files) == 0 {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
dir.ind = max(dir.ind, 0)
|
|
||||||
dir.ind = min(dir.ind, len(dir.files)-1)
|
|
||||||
|
|
||||||
return dir.files[dir.ind].Name()
|
return dir.files[dir.ind].Name()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -273,6 +347,7 @@ func (dir *dir) sel(name string, height int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type nav struct {
|
type nav struct {
|
||||||
|
init bool
|
||||||
dirs []*dir
|
dirs []*dir
|
||||||
copyBytes int64
|
copyBytes int64
|
||||||
copyTotal int64
|
copyTotal int64
|
||||||
@@ -299,6 +374,7 @@ type nav struct {
|
|||||||
renameOldPath string
|
renameOldPath string
|
||||||
renameNewPath string
|
renameNewPath string
|
||||||
selections map[string]int
|
selections map[string]int
|
||||||
|
tags map[string]string
|
||||||
selectionInd int
|
selectionInd int
|
||||||
height int
|
height int
|
||||||
find string
|
find string
|
||||||
@@ -307,12 +383,13 @@ type nav struct {
|
|||||||
searchBack bool
|
searchBack bool
|
||||||
searchInd int
|
searchInd int
|
||||||
searchPos int
|
searchPos int
|
||||||
|
prevFilter []string
|
||||||
volatilePreview bool
|
volatilePreview bool
|
||||||
|
jumpList []string
|
||||||
|
jumpListInd int
|
||||||
}
|
}
|
||||||
|
|
||||||
func (nav *nav) loadDir(path string) *dir {
|
func (nav *nav) loadDirInternal(path string) *dir {
|
||||||
d, ok := nav.dirCache[path]
|
|
||||||
if !ok {
|
|
||||||
d := &dir{
|
d := &dir{
|
||||||
loading: true,
|
loading: true,
|
||||||
loadTime: time.Now(),
|
loadTime: time.Now(),
|
||||||
@@ -322,7 +399,6 @@ func (nav *nav) loadDir(path string) *dir {
|
|||||||
ignorecase: gOpts.ignorecase,
|
ignorecase: gOpts.ignorecase,
|
||||||
ignoredia: gOpts.ignoredia,
|
ignoredia: gOpts.ignoredia,
|
||||||
}
|
}
|
||||||
nav.dirCache[path] = d
|
|
||||||
go func() {
|
go func() {
|
||||||
d := newDir(path)
|
d := newDir(path)
|
||||||
d.sort()
|
d.sort()
|
||||||
@@ -332,10 +408,21 @@ func (nav *nav) loadDir(path string) *dir {
|
|||||||
return d
|
return d
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (nav *nav) loadDir(path string) *dir {
|
||||||
|
if gOpts.dircache {
|
||||||
|
d, ok := nav.dirCache[path]
|
||||||
|
if !ok {
|
||||||
|
d = nav.loadDirInternal(path)
|
||||||
|
nav.dirCache[path] = d
|
||||||
|
return d
|
||||||
|
}
|
||||||
|
|
||||||
nav.checkDir(d)
|
nav.checkDir(d)
|
||||||
|
|
||||||
return d
|
return d
|
||||||
}
|
}
|
||||||
|
return nav.loadDirInternal(path)
|
||||||
|
}
|
||||||
|
|
||||||
func (nav *nav) checkDir(dir *dir) {
|
func (nav *nav) checkDir(dir *dir) {
|
||||||
s, err := os.Stat(dir.path)
|
s, err := os.Stat(dir.path)
|
||||||
@@ -358,10 +445,12 @@ func (nav *nav) checkDir(dir *dir) {
|
|||||||
dir.loadTime = now
|
dir.loadTime = now
|
||||||
go func() {
|
go func() {
|
||||||
nd := newDir(dir.path)
|
nd := newDir(dir.path)
|
||||||
|
nd.filter = dir.filter
|
||||||
nd.sort()
|
nd.sort()
|
||||||
nav.dirChan <- nd
|
nav.dirChan <- nd
|
||||||
}()
|
}()
|
||||||
case dir.sortType != gOpts.sortType ||
|
case dir.sortType != gOpts.sortType ||
|
||||||
|
dir.dironly != gOpts.dironly ||
|
||||||
!reflect.DeepEqual(dir.hiddenfiles, gOpts.hiddenfiles) ||
|
!reflect.DeepEqual(dir.hiddenfiles, gOpts.hiddenfiles) ||
|
||||||
dir.ignorecase != gOpts.ignorecase ||
|
dir.ignorecase != gOpts.ignorecase ||
|
||||||
dir.ignoredia != gOpts.ignoredia:
|
dir.ignoredia != gOpts.ignoredia:
|
||||||
@@ -377,6 +466,8 @@ func (nav *nav) checkDir(dir *dir) {
|
|||||||
func (nav *nav) getDirs(wd string) {
|
func (nav *nav) getDirs(wd string) {
|
||||||
var dirs []*dir
|
var dirs []*dir
|
||||||
|
|
||||||
|
wd = filepath.Clean(wd)
|
||||||
|
|
||||||
for curr, base := wd, ""; !isRoot(base); curr, base = filepath.Dir(curr), filepath.Base(curr) {
|
for curr, base := wd, ""; !isRoot(base); curr, base = filepath.Dir(curr), filepath.Base(curr) {
|
||||||
dir := nav.loadDir(curr)
|
dir := nav.loadDir(curr)
|
||||||
dir.sel(base, nav.height)
|
dir.sel(base, nav.height)
|
||||||
@@ -391,11 +482,6 @@ func (nav *nav) getDirs(wd string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func newNav(height int) *nav {
|
func newNav(height int) *nav {
|
||||||
wd, err := os.Getwd()
|
|
||||||
if err != nil {
|
|
||||||
log.Printf("getting current directory: %s", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
nav := &nav{
|
nav := &nav{
|
||||||
copyBytesChan: make(chan int64, 1024),
|
copyBytesChan: make(chan int64, 1024),
|
||||||
copyTotalChan: make(chan int64, 1024),
|
copyTotalChan: make(chan int64, 1024),
|
||||||
@@ -411,15 +497,46 @@ func newNav(height int) *nav {
|
|||||||
saves: make(map[string]bool),
|
saves: make(map[string]bool),
|
||||||
marks: make(map[string]string),
|
marks: make(map[string]string),
|
||||||
selections: make(map[string]int),
|
selections: make(map[string]int),
|
||||||
|
tags: make(map[string]string),
|
||||||
selectionInd: 0,
|
selectionInd: 0,
|
||||||
height: height,
|
height: height,
|
||||||
|
jumpList: make([]string, 0),
|
||||||
|
jumpListInd: -1,
|
||||||
}
|
}
|
||||||
|
|
||||||
nav.getDirs(wd)
|
|
||||||
|
|
||||||
return nav
|
return nav
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (nav *nav) addJumpList() {
|
||||||
|
currPath := nav.currDir().path
|
||||||
|
if nav.jumpListInd >= 0 && nav.jumpListInd < len(nav.jumpList)-1 {
|
||||||
|
if nav.jumpList[nav.jumpListInd] == currPath {
|
||||||
|
// walking the jumpList
|
||||||
|
return
|
||||||
|
}
|
||||||
|
nav.jumpList = nav.jumpList[:nav.jumpListInd+1]
|
||||||
|
}
|
||||||
|
if len(nav.jumpList) == 0 || nav.jumpList[len(nav.jumpList)-1] != currPath {
|
||||||
|
nav.jumpList = append(nav.jumpList, currPath)
|
||||||
|
}
|
||||||
|
nav.jumpListInd = len(nav.jumpList) - 1
|
||||||
|
}
|
||||||
|
|
||||||
|
func (nav *nav) cdJumpListPrev() {
|
||||||
|
// currPath := nav.currDir().path
|
||||||
|
if nav.jumpListInd > 0 {
|
||||||
|
nav.jumpListInd -= 1
|
||||||
|
nav.cd(nav.jumpList[nav.jumpListInd])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (nav *nav) cdJumpListNext() {
|
||||||
|
if nav.jumpListInd < len(nav.jumpList)-1 {
|
||||||
|
nav.jumpListInd += 1
|
||||||
|
nav.cd(nav.jumpList[nav.jumpListInd])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (nav *nav) renew() {
|
func (nav *nav) renew() {
|
||||||
for _, d := range nav.dirs {
|
for _, d := range nav.dirs {
|
||||||
nav.checkDir(d)
|
nav.checkDir(d)
|
||||||
@@ -456,6 +573,10 @@ func (nav *nav) reload() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (nav *nav) position() {
|
func (nav *nav) position() {
|
||||||
|
if !nav.init {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
path := nav.currDir().path
|
path := nav.currDir().path
|
||||||
for i := len(nav.dirs) - 2; i >= 0; i-- {
|
for i := len(nav.dirs) - 2; i >= 0; i-- {
|
||||||
nav.dirs[i].sel(filepath.Base(path), nav.height)
|
nav.dirs[i].sel(filepath.Base(path), nav.height)
|
||||||
@@ -463,6 +584,21 @@ func (nav *nav) position() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (nav *nav) exportFiles() {
|
||||||
|
if !nav.init {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var currFile string
|
||||||
|
if curr, err := nav.currFile(); err == nil {
|
||||||
|
currFile = curr.path
|
||||||
|
}
|
||||||
|
|
||||||
|
currSelections := nav.currSelections()
|
||||||
|
|
||||||
|
exportFiles(currFile, currSelections, nav.currDir().path)
|
||||||
|
}
|
||||||
|
|
||||||
func (nav *nav) previewLoop(ui *ui) {
|
func (nav *nav) previewLoop(ui *ui) {
|
||||||
var prev string
|
var prev string
|
||||||
for path := range nav.previewChan {
|
for path := range nav.previewChan {
|
||||||
@@ -477,6 +613,8 @@ func (nav *nav) previewLoop(ui *ui) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if clear && len(gOpts.previewer) != 0 && len(gOpts.cleaner) != 0 && nav.volatilePreview {
|
if clear && len(gOpts.previewer) != 0 && len(gOpts.cleaner) != 0 && nav.volatilePreview {
|
||||||
|
nav.exportFiles()
|
||||||
|
exportOpts()
|
||||||
cmd := exec.Command(gOpts.cleaner, prev)
|
cmd := exec.Command(gOpts.cleaner, prev)
|
||||||
if err := cmd.Run(); err != nil {
|
if err := cmd.Run(); err != nil {
|
||||||
log.Printf("cleaning preview: %s", err)
|
log.Printf("cleaning preview: %s", err)
|
||||||
@@ -491,6 +629,21 @@ func (nav *nav) previewLoop(ui *ui) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func matchPattern(pattern, name, path string) bool {
|
||||||
|
s := name
|
||||||
|
|
||||||
|
pattern = replaceTilde(pattern)
|
||||||
|
|
||||||
|
if filepath.IsAbs(pattern) {
|
||||||
|
s = filepath.Join(path, name)
|
||||||
|
}
|
||||||
|
|
||||||
|
// pattern errors are checked when 'hiddenfiles' option is set
|
||||||
|
matched, _ := filepath.Match(pattern, s)
|
||||||
|
|
||||||
|
return matched
|
||||||
|
}
|
||||||
|
|
||||||
func (nav *nav) preview(path string, win *win) {
|
func (nav *nav) preview(path string, win *win) {
|
||||||
reg := ®{loadTime: time.Now(), path: path}
|
reg := ®{loadTime: time.Now(), path: path}
|
||||||
defer func() { nav.regChan <- reg }()
|
defer func() { nav.regChan <- reg }()
|
||||||
@@ -498,6 +651,7 @@ func (nav *nav) preview(path string, win *win) {
|
|||||||
var reader io.Reader
|
var reader io.Reader
|
||||||
|
|
||||||
if len(gOpts.previewer) != 0 {
|
if len(gOpts.previewer) != 0 {
|
||||||
|
nav.exportFiles()
|
||||||
exportOpts()
|
exportOpts()
|
||||||
cmd := exec.Command(gOpts.previewer, path,
|
cmd := exec.Command(gOpts.previewer, path,
|
||||||
strconv.Itoa(win.w),
|
strconv.Itoa(win.w),
|
||||||
@@ -601,6 +755,27 @@ func (nav *nav) sort() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (nav *nav) setFilter(filter []string) error {
|
||||||
|
newfilter := []string{}
|
||||||
|
for _, tok := range filter {
|
||||||
|
_, err := filepath.Match(tok, "a")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if tok != "" {
|
||||||
|
newfilter = append(newfilter, tok)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dir := nav.currDir()
|
||||||
|
dir.filter = newfilter
|
||||||
|
|
||||||
|
// Apply filter, by sorting current dir (see nav.sort())
|
||||||
|
name := dir.name()
|
||||||
|
dir.sort()
|
||||||
|
dir.sel(name, nav.height)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (nav *nav) up(dist int) bool {
|
func (nav *nav) up(dist int) bool {
|
||||||
dir := nav.currDir()
|
dir := nav.currDir()
|
||||||
|
|
||||||
@@ -653,6 +828,64 @@ func (nav *nav) down(dist int) bool {
|
|||||||
return old != dir.ind
|
return old != dir.ind
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (nav *nav) scrollUp(dist int) bool {
|
||||||
|
dir := nav.currDir()
|
||||||
|
|
||||||
|
// when reached top do nothing
|
||||||
|
if istop := dir.ind == dir.pos; istop {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
old := dir.ind
|
||||||
|
|
||||||
|
minedge := min(nav.height/2, gOpts.scrolloff)
|
||||||
|
|
||||||
|
dir.pos += dist
|
||||||
|
|
||||||
|
// jump to ensure minedge when edge < minedge
|
||||||
|
edge := nav.height - dir.pos
|
||||||
|
delta := min(0, edge-minedge-1)
|
||||||
|
dir.pos = min(dir.pos, nav.height-minedge-1)
|
||||||
|
// update dir.ind accordingly
|
||||||
|
dir.ind = dir.ind + delta
|
||||||
|
|
||||||
|
dir.ind = min(dir.ind, dir.ind-(dir.pos-nav.height+1))
|
||||||
|
|
||||||
|
// prevent cursor disappearing downwards
|
||||||
|
dir.pos = min(dir.pos, nav.height-1)
|
||||||
|
|
||||||
|
return old != dir.ind
|
||||||
|
}
|
||||||
|
|
||||||
|
func (nav *nav) scrollDown(dist int) bool {
|
||||||
|
dir := nav.currDir()
|
||||||
|
maxind := len(dir.files) - 1
|
||||||
|
|
||||||
|
// reached bottom
|
||||||
|
if dir.ind-dir.pos > maxind-nav.height {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
old := dir.ind
|
||||||
|
|
||||||
|
minedge := min(nav.height/2, gOpts.scrolloff)
|
||||||
|
|
||||||
|
dir.pos -= dist
|
||||||
|
|
||||||
|
// jump to ensure minedge when edge < minedge
|
||||||
|
delta := min(0, dir.pos-minedge)
|
||||||
|
dir.pos = max(dir.pos, minedge)
|
||||||
|
// update dir.ind accordingly
|
||||||
|
dir.ind = dir.ind - delta
|
||||||
|
dir.ind = max(dir.ind, dir.ind-(dir.pos-minedge))
|
||||||
|
|
||||||
|
dir.ind = min(maxind, dir.ind)
|
||||||
|
// prevent disappearing
|
||||||
|
dir.pos = max(dir.pos, 0)
|
||||||
|
|
||||||
|
return old != dir.ind
|
||||||
|
}
|
||||||
|
|
||||||
func (nav *nav) updir() error {
|
func (nav *nav) updir() error {
|
||||||
if len(nav.dirs) <= 1 {
|
if len(nav.dirs) <= 1 {
|
||||||
return nil
|
return nil
|
||||||
@@ -731,6 +964,48 @@ func (nav *nav) toggle() {
|
|||||||
nav.toggleSelection(curr.path)
|
nav.toggleSelection(curr.path)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (nav *nav) tagToggleSelection(path string, tag string) {
|
||||||
|
if _, ok := nav.tags[path]; ok {
|
||||||
|
delete(nav.tags, path)
|
||||||
|
} else {
|
||||||
|
nav.tags[path] = tag
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (nav *nav) tagToggle(tag string) error {
|
||||||
|
list, err := nav.currFileOrSelections()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if printLength(tag) != 1 {
|
||||||
|
return errors.New("tag should be single width character")
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, path := range list {
|
||||||
|
nav.tagToggleSelection(path, tag)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (nav *nav) tag(tag string) error {
|
||||||
|
list, err := nav.currFileOrSelections()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if printLength(tag) != 1 {
|
||||||
|
return errors.New("tag should be single width character")
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, path := range list {
|
||||||
|
nav.tags[path] = tag
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (nav *nav) invert() {
|
func (nav *nav) invert() {
|
||||||
dir := nav.currDir()
|
dir := nav.currDir()
|
||||||
for _, f := range dir.files {
|
for _, f := range dir.files {
|
||||||
@@ -938,8 +1213,6 @@ func (nav *nav) paste(ui *ui) error {
|
|||||||
go nav.copyAsync(ui, srcs, dstDir)
|
go nav.copyAsync(ui, srcs, dstDir)
|
||||||
} else {
|
} else {
|
||||||
go nav.moveAsync(ui, srcs, dstDir)
|
go nav.moveAsync(ui, srcs, dstDir)
|
||||||
}
|
|
||||||
|
|
||||||
if err := saveFiles(nil, false); err != nil {
|
if err := saveFiles(nil, false); err != nil {
|
||||||
return fmt.Errorf("clearing copy/cut buffer: %s", err)
|
return fmt.Errorf("clearing copy/cut buffer: %s", err)
|
||||||
}
|
}
|
||||||
@@ -953,6 +1226,7 @@ func (nav *nav) paste(ui *ui) error {
|
|||||||
return fmt.Errorf("paste: %s", err)
|
return fmt.Errorf("paste: %s", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -1031,12 +1305,15 @@ func (nav *nav) sync() error {
|
|||||||
nav.saves[f] = cp
|
nav.saves[f] = cp
|
||||||
}
|
}
|
||||||
|
|
||||||
path, ok := nav.marks["'"]
|
oldmarks := nav.marks
|
||||||
err = nav.readMarks()
|
err = nav.readMarks()
|
||||||
if ok {
|
for _, ch := range gOpts.tempmarks {
|
||||||
nav.marks["'"] = path
|
tmp := string(ch)
|
||||||
|
if v, e := oldmarks[tmp]; e {
|
||||||
|
nav.marks[tmp] = v
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
err = nav.readTags()
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1053,7 +1330,7 @@ func (nav *nav) cd(wd string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
nav.getDirs(wd)
|
nav.getDirs(wd)
|
||||||
|
nav.addJumpList()
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1251,6 +1528,22 @@ func (nav *nav) searchPrev() (bool, error) {
|
|||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func isFiltered(f os.FileInfo, filter []string) bool {
|
||||||
|
for _, pattern := range filter {
|
||||||
|
matched, err := searchMatch(f.Name(), strings.TrimPrefix(pattern, "!"))
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("Filter Error: %s", err)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if strings.HasPrefix(pattern, "!") && matched {
|
||||||
|
return true
|
||||||
|
} else if !strings.HasPrefix(pattern, "!") && !matched {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
func (nav *nav) removeMark(mark string) error {
|
func (nav *nav) removeMark(mark string) error {
|
||||||
if _, ok := nav.marks[mark]; ok {
|
if _, ok := nav.marks[mark]; ok {
|
||||||
delete(nav.marks, mark)
|
delete(nav.marks, mark)
|
||||||
@@ -1298,8 +1591,10 @@ func (nav *nav) writeMarks() error {
|
|||||||
|
|
||||||
var keys []string
|
var keys []string
|
||||||
for k := range nav.marks {
|
for k := range nav.marks {
|
||||||
|
if !strings.Contains(gOpts.tempmarks, k) {
|
||||||
keys = append(keys, k)
|
keys = append(keys, k)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
sort.Strings(keys)
|
sort.Strings(keys)
|
||||||
|
|
||||||
for _, k := range keys {
|
for _, k := range keys {
|
||||||
@@ -1312,6 +1607,59 @@ func (nav *nav) writeMarks() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (nav *nav) readTags() error {
|
||||||
|
nav.tags = make(map[string]string)
|
||||||
|
f, err := os.Open(gTagsPath)
|
||||||
|
if os.IsNotExist(err) {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("opening tags file: %s", err)
|
||||||
|
}
|
||||||
|
defer f.Close()
|
||||||
|
|
||||||
|
scanner := bufio.NewScanner(f)
|
||||||
|
for scanner.Scan() {
|
||||||
|
toks := strings.SplitN(scanner.Text(), ":", 2)
|
||||||
|
if _, ok := nav.tags[toks[0]]; !ok {
|
||||||
|
nav.tags[toks[0]] = toks[1]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := scanner.Err(); err != nil {
|
||||||
|
return fmt.Errorf("reading tags file: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (nav *nav) writeTags() error {
|
||||||
|
if err := os.MkdirAll(filepath.Dir(gTagsPath), os.ModePerm); err != nil {
|
||||||
|
return fmt.Errorf("creating data directory: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
f, err := os.Create(gTagsPath)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("creating tags file: %s", err)
|
||||||
|
}
|
||||||
|
defer f.Close()
|
||||||
|
|
||||||
|
var keys []string
|
||||||
|
for k := range nav.tags {
|
||||||
|
keys = append(keys, k)
|
||||||
|
}
|
||||||
|
sort.Strings(keys)
|
||||||
|
|
||||||
|
for _, k := range keys {
|
||||||
|
_, err = f.WriteString(fmt.Sprintf("%s:%s\n", k, nav.tags[k]))
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("writing tags file: %s", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (nav *nav) currDir() *dir {
|
func (nav *nav) currDir() *dir {
|
||||||
return nav.dirs[len(nav.dirs)-1]
|
return nav.dirs[len(nav.dirs)-1]
|
||||||
}
|
}
|
||||||
@@ -1322,6 +1670,7 @@ func (nav *nav) currFile() (*file, error) {
|
|||||||
if len(dir.files) == 0 {
|
if len(dir.files) == 0 {
|
||||||
return nil, fmt.Errorf("empty directory")
|
return nil, fmt.Errorf("empty directory")
|
||||||
}
|
}
|
||||||
|
|
||||||
return dir.files[dir.ind], nil
|
return dir.files[dir.ind], nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1362,3 +1711,45 @@ func (nav *nav) currFileOrSelections() (list []string, err error) {
|
|||||||
|
|
||||||
return nav.currSelections(), nil
|
return nav.currSelections(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (nav *nav) calcDirSize() error {
|
||||||
|
calc := func(f *file) error {
|
||||||
|
if f.IsDir() {
|
||||||
|
total, err := copySize([]string{f.path})
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
f.dirSize = total
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(nav.selections) == 0 {
|
||||||
|
curr, err := nav.currFile()
|
||||||
|
if err != nil {
|
||||||
|
return errors.New("no file selected")
|
||||||
|
}
|
||||||
|
return calc(curr)
|
||||||
|
}
|
||||||
|
|
||||||
|
for sel := range nav.selections {
|
||||||
|
lstat, err := os.Lstat(sel)
|
||||||
|
if err != nil || !lstat.IsDir() {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
path, name := filepath.Dir(sel), filepath.Base(sel)
|
||||||
|
dir := nav.loadDir(path)
|
||||||
|
|
||||||
|
for _, f := range dir.files {
|
||||||
|
if f.Name() == name {
|
||||||
|
err := calc(f)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
@@ -30,12 +30,15 @@ type sortType struct {
|
|||||||
var gOpts struct {
|
var gOpts struct {
|
||||||
anchorfind bool
|
anchorfind bool
|
||||||
autoquit bool
|
autoquit bool
|
||||||
|
dircache bool
|
||||||
dircounts bool
|
dircounts bool
|
||||||
|
dironly bool
|
||||||
drawbox bool
|
drawbox bool
|
||||||
globsearch bool
|
globsearch bool
|
||||||
icons bool
|
icons bool
|
||||||
ignorecase bool
|
ignorecase bool
|
||||||
ignoredia bool
|
ignoredia bool
|
||||||
|
incfilter bool
|
||||||
incsearch bool
|
incsearch bool
|
||||||
mouse bool
|
mouse bool
|
||||||
number bool
|
number bool
|
||||||
@@ -59,6 +62,8 @@ var gOpts struct {
|
|||||||
shell string
|
shell string
|
||||||
shellflag string
|
shellflag string
|
||||||
timefmt string
|
timefmt string
|
||||||
|
infotimefmtnew string
|
||||||
|
infotimefmtold string
|
||||||
truncatechar string
|
truncatechar string
|
||||||
ratios []int
|
ratios []int
|
||||||
hiddenfiles []string
|
hiddenfiles []string
|
||||||
@@ -68,17 +73,22 @@ var gOpts struct {
|
|||||||
cmdkeys map[string]expr
|
cmdkeys map[string]expr
|
||||||
cmds map[string]expr
|
cmds map[string]expr
|
||||||
sortType sortType
|
sortType sortType
|
||||||
|
tempmarks string
|
||||||
|
tagfmt string
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
gOpts.anchorfind = true
|
gOpts.anchorfind = true
|
||||||
gOpts.autoquit = false
|
gOpts.autoquit = false
|
||||||
|
gOpts.dircache = true
|
||||||
gOpts.dircounts = false
|
gOpts.dircounts = false
|
||||||
|
gOpts.dironly = false
|
||||||
gOpts.drawbox = false
|
gOpts.drawbox = false
|
||||||
gOpts.globsearch = false
|
gOpts.globsearch = false
|
||||||
gOpts.icons = false
|
gOpts.icons = false
|
||||||
gOpts.ignorecase = true
|
gOpts.ignorecase = true
|
||||||
gOpts.ignoredia = true
|
gOpts.ignoredia = true
|
||||||
|
gOpts.incfilter = false
|
||||||
gOpts.incsearch = false
|
gOpts.incsearch = false
|
||||||
gOpts.mouse = false
|
gOpts.mouse = false
|
||||||
gOpts.number = false
|
gOpts.number = false
|
||||||
@@ -102,12 +112,16 @@ func init() {
|
|||||||
gOpts.shell = gDefaultShell
|
gOpts.shell = gDefaultShell
|
||||||
gOpts.shellflag = gDefaultShellFlag
|
gOpts.shellflag = gDefaultShellFlag
|
||||||
gOpts.timefmt = time.ANSIC
|
gOpts.timefmt = time.ANSIC
|
||||||
|
gOpts.infotimefmtnew = "Jan _2 15:04"
|
||||||
|
gOpts.infotimefmtold = "Jan _2 2006"
|
||||||
gOpts.truncatechar = "~"
|
gOpts.truncatechar = "~"
|
||||||
gOpts.ratios = []int{1, 2, 3}
|
gOpts.ratios = []int{1, 2, 3}
|
||||||
gOpts.hiddenfiles = []string{".*"}
|
gOpts.hiddenfiles = []string{".*"}
|
||||||
gOpts.info = nil
|
gOpts.info = nil
|
||||||
gOpts.shellopts = nil
|
gOpts.shellopts = nil
|
||||||
gOpts.sortType = sortType{naturalSort, dirfirstSort}
|
gOpts.sortType = sortType{naturalSort, dirfirstSort}
|
||||||
|
gOpts.tempmarks = "'"
|
||||||
|
gOpts.tagfmt = "\033[31m%s\033[0m"
|
||||||
|
|
||||||
gOpts.keys = make(map[string]expr)
|
gOpts.keys = make(map[string]expr)
|
||||||
|
|
||||||
@@ -116,11 +130,13 @@ func init() {
|
|||||||
gOpts.keys["<c-u>"] = &callExpr{"half-up", nil, 1}
|
gOpts.keys["<c-u>"] = &callExpr{"half-up", nil, 1}
|
||||||
gOpts.keys["<c-b>"] = &callExpr{"page-up", nil, 1}
|
gOpts.keys["<c-b>"] = &callExpr{"page-up", nil, 1}
|
||||||
gOpts.keys["<pgup>"] = &callExpr{"page-up", nil, 1}
|
gOpts.keys["<pgup>"] = &callExpr{"page-up", nil, 1}
|
||||||
|
gOpts.keys["<c-y>"] = &callExpr{"scroll-up", nil, 1}
|
||||||
gOpts.keys["j"] = &callExpr{"down", nil, 1}
|
gOpts.keys["j"] = &callExpr{"down", nil, 1}
|
||||||
gOpts.keys["<down>"] = &callExpr{"down", nil, 1}
|
gOpts.keys["<down>"] = &callExpr{"down", nil, 1}
|
||||||
gOpts.keys["<c-d>"] = &callExpr{"half-down", nil, 1}
|
gOpts.keys["<c-d>"] = &callExpr{"half-down", nil, 1}
|
||||||
gOpts.keys["<c-f>"] = &callExpr{"page-down", nil, 1}
|
gOpts.keys["<c-f>"] = &callExpr{"page-down", nil, 1}
|
||||||
gOpts.keys["<pgdn>"] = &callExpr{"page-down", nil, 1}
|
gOpts.keys["<pgdn>"] = &callExpr{"page-down", nil, 1}
|
||||||
|
gOpts.keys["<c-e>"] = &callExpr{"scroll-down", nil, 1}
|
||||||
gOpts.keys["h"] = &callExpr{"updir", nil, 1}
|
gOpts.keys["h"] = &callExpr{"updir", nil, 1}
|
||||||
gOpts.keys["<left>"] = &callExpr{"updir", nil, 1}
|
gOpts.keys["<left>"] = &callExpr{"updir", nil, 1}
|
||||||
gOpts.keys["l"] = &callExpr{"open", nil, 1}
|
gOpts.keys["l"] = &callExpr{"open", nil, 1}
|
||||||
@@ -130,7 +146,10 @@ func init() {
|
|||||||
gOpts.keys["<home>"] = &callExpr{"top", nil, 1}
|
gOpts.keys["<home>"] = &callExpr{"top", nil, 1}
|
||||||
gOpts.keys["G"] = &callExpr{"bottom", nil, 1}
|
gOpts.keys["G"] = &callExpr{"bottom", nil, 1}
|
||||||
gOpts.keys["<end>"] = &callExpr{"bottom", nil, 1}
|
gOpts.keys["<end>"] = &callExpr{"bottom", nil, 1}
|
||||||
|
gOpts.keys["["] = &callExpr{"jump-prev", nil, 1}
|
||||||
|
gOpts.keys["]"] = &callExpr{"jump-next", nil, 1}
|
||||||
gOpts.keys["<space>"] = &listExpr{[]expr{&callExpr{"toggle", nil, 1}, &callExpr{"down", nil, 1}}, 1}
|
gOpts.keys["<space>"] = &listExpr{[]expr{&callExpr{"toggle", nil, 1}, &callExpr{"down", nil, 1}}, 1}
|
||||||
|
gOpts.keys["t"] = &callExpr{"tag-toggle", nil, 1}
|
||||||
gOpts.keys["v"] = &callExpr{"invert", nil, 1}
|
gOpts.keys["v"] = &callExpr{"invert", nil, 1}
|
||||||
gOpts.keys["u"] = &callExpr{"unselect", nil, 1}
|
gOpts.keys["u"] = &callExpr{"unselect", nil, 1}
|
||||||
gOpts.keys["y"] = &callExpr{"copy", nil, 1}
|
gOpts.keys["y"] = &callExpr{"copy", nil, 1}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// +build !windows
|
//go:build !windows
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
@@ -11,7 +11,8 @@ import (
|
|||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
|
||||||
|
"golang.org/x/sys/unix"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -31,8 +32,11 @@ var (
|
|||||||
var (
|
var (
|
||||||
gUser *user.User
|
gUser *user.User
|
||||||
gConfigPaths []string
|
gConfigPaths []string
|
||||||
|
gColorsPaths []string
|
||||||
|
gIconsPaths []string
|
||||||
gFilesPath string
|
gFilesPath string
|
||||||
gMarksPath string
|
gMarksPath string
|
||||||
|
gTagsPath string
|
||||||
gHistoryPath string
|
gHistoryPath string
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -79,6 +83,16 @@ func init() {
|
|||||||
filepath.Join(config, "lf", "lfrc"),
|
filepath.Join(config, "lf", "lfrc"),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gColorsPaths = []string{
|
||||||
|
filepath.Join("/etc", "lf", "colors"),
|
||||||
|
filepath.Join(config, "lf", "colors"),
|
||||||
|
}
|
||||||
|
|
||||||
|
gIconsPaths = []string{
|
||||||
|
filepath.Join("/etc", "lf", "icons"),
|
||||||
|
filepath.Join(config, "lf", "icons"),
|
||||||
|
}
|
||||||
|
|
||||||
data := os.Getenv("XDG_DATA_HOME")
|
data := os.Getenv("XDG_DATA_HOME")
|
||||||
if data == "" {
|
if data == "" {
|
||||||
data = filepath.Join(gUser.HomeDir, ".local", "share")
|
data = filepath.Join(gUser.HomeDir, ".local", "share")
|
||||||
@@ -86,14 +100,20 @@ func init() {
|
|||||||
|
|
||||||
gFilesPath = filepath.Join(data, "lf", "files")
|
gFilesPath = filepath.Join(data, "lf", "files")
|
||||||
gMarksPath = filepath.Join(data, "lf", "marks")
|
gMarksPath = filepath.Join(data, "lf", "marks")
|
||||||
|
gTagsPath = filepath.Join(data, "lf", "tags")
|
||||||
gHistoryPath = filepath.Join(data, "lf", "history")
|
gHistoryPath = filepath.Join(data, "lf", "history")
|
||||||
|
|
||||||
gDefaultSocketPath = filepath.Join(os.TempDir(), fmt.Sprintf("lf.%s.sock", gUser.Username))
|
runtime := os.Getenv("XDG_RUNTIME_DIR")
|
||||||
|
if runtime == "" {
|
||||||
|
runtime = os.TempDir()
|
||||||
|
}
|
||||||
|
|
||||||
|
gDefaultSocketPath = filepath.Join(runtime, fmt.Sprintf("lf.%s.sock", gUser.Username))
|
||||||
}
|
}
|
||||||
|
|
||||||
func detachedCommand(name string, arg ...string) *exec.Cmd {
|
func detachedCommand(name string, arg ...string) *exec.Cmd {
|
||||||
cmd := exec.Command(name, arg...)
|
cmd := exec.Command(name, arg...)
|
||||||
cmd.SysProcAttr = &syscall.SysProcAttr{Setsid: true}
|
cmd.SysProcAttr = &unix.SysProcAttr{Setsid: true}
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,6 +129,22 @@ func shellCommand(s string, args []string) *exec.Cmd {
|
|||||||
return exec.Command(gOpts.shell, args...)
|
return exec.Command(gOpts.shell, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func shellSetPG(cmd *exec.Cmd) {
|
||||||
|
cmd.SysProcAttr = &unix.SysProcAttr{Setpgid: true}
|
||||||
|
}
|
||||||
|
|
||||||
|
func shellKill(cmd *exec.Cmd) error {
|
||||||
|
pgid, err := unix.Getpgid(cmd.Process.Pid)
|
||||||
|
if err == nil && cmd.Process.Pid == pgid {
|
||||||
|
// kill the process group
|
||||||
|
err = unix.Kill(-pgid, 15)
|
||||||
|
if err == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return cmd.Process.Kill()
|
||||||
|
}
|
||||||
|
|
||||||
func setDefaults() {
|
func setDefaults() {
|
||||||
gOpts.cmds["open"] = &execExpr{"&", `$OPENER "$f"`}
|
gOpts.cmds["open"] = &execExpr{"&", `$OPENER "$f"`}
|
||||||
gOpts.keys["e"] = &execExpr{"$", `$EDITOR "$f"`}
|
gOpts.keys["e"] = &execExpr{"$", `$EDITOR "$f"`}
|
||||||
@@ -119,6 +155,10 @@ func setDefaults() {
|
|||||||
gOpts.keys["<f-1>"] = &callExpr{"doc", nil, 1}
|
gOpts.keys["<f-1>"] = &callExpr{"doc", nil, 1}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func setUserUmask() {
|
||||||
|
unix.Umask(0077)
|
||||||
|
}
|
||||||
|
|
||||||
func isExecutable(f os.FileInfo) bool {
|
func isExecutable(f os.FileInfo) bool {
|
||||||
return f.Mode()&0111 != 0
|
return f.Mode()&0111 != 0
|
||||||
}
|
}
|
||||||
@@ -137,7 +177,7 @@ func isHidden(f os.FileInfo, path string, hiddenfiles []string) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func userName(f os.FileInfo) string {
|
func userName(f os.FileInfo) string {
|
||||||
if stat, ok := f.Sys().(*syscall.Stat_t); ok {
|
if stat, ok := f.Sys().(*unix.Stat_t); ok {
|
||||||
if u, err := user.LookupId(fmt.Sprint(stat.Uid)); err == nil {
|
if u, err := user.LookupId(fmt.Sprint(stat.Uid)); err == nil {
|
||||||
return fmt.Sprintf("%v ", u.Username)
|
return fmt.Sprintf("%v ", u.Username)
|
||||||
}
|
}
|
||||||
@@ -146,7 +186,7 @@ func userName(f os.FileInfo) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func groupName(f os.FileInfo) string {
|
func groupName(f os.FileInfo) string {
|
||||||
if stat, ok := f.Sys().(*syscall.Stat_t); ok {
|
if stat, ok := f.Sys().(*unix.Stat_t); ok {
|
||||||
if g, err := user.LookupGroupId(fmt.Sprint(stat.Gid)); err == nil {
|
if g, err := user.LookupGroupId(fmt.Sprint(stat.Gid)); err == nil {
|
||||||
return fmt.Sprintf("%v ", g.Name)
|
return fmt.Sprintf("%v ", g.Name)
|
||||||
}
|
}
|
||||||
@@ -155,29 +195,14 @@ func groupName(f os.FileInfo) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func linkCount(f os.FileInfo) string {
|
func linkCount(f os.FileInfo) string {
|
||||||
if stat, ok := f.Sys().(*syscall.Stat_t); ok {
|
if stat, ok := f.Sys().(*unix.Stat_t); ok {
|
||||||
return fmt.Sprintf("%v ", stat.Nlink)
|
return fmt.Sprintf("%v ", stat.Nlink)
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func matchPattern(pattern, name, path string) bool {
|
|
||||||
s := name
|
|
||||||
|
|
||||||
pattern = replaceTilde(pattern)
|
|
||||||
|
|
||||||
if filepath.IsAbs(pattern) {
|
|
||||||
s = filepath.Join(path, name)
|
|
||||||
}
|
|
||||||
|
|
||||||
// pattern errors are checked when 'hiddenfiles' option is set
|
|
||||||
matched, _ := filepath.Match(pattern, s)
|
|
||||||
|
|
||||||
return matched
|
|
||||||
}
|
|
||||||
|
|
||||||
func errCrossDevice(err error) bool {
|
func errCrossDevice(err error) bool {
|
||||||
return err.(*os.LinkError).Err.(syscall.Errno) == syscall.EXDEV
|
return err.(*os.LinkError).Err.(unix.Errno) == unix.EXDEV
|
||||||
}
|
}
|
||||||
|
|
||||||
func exportFiles(f string, fs []string, pwd string) {
|
func exportFiles(f string, fs []string, pwd string) {
|
||||||
|
|||||||
+33
-7
@@ -8,7 +8,8 @@ import (
|
|||||||
"os/user"
|
"os/user"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
|
||||||
|
"golang.org/x/sys/windows"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -30,7 +31,10 @@ var (
|
|||||||
var (
|
var (
|
||||||
gUser *user.User
|
gUser *user.User
|
||||||
gConfigPaths []string
|
gConfigPaths []string
|
||||||
|
gColorsPaths []string
|
||||||
|
gIconsPaths []string
|
||||||
gFilesPath string
|
gFilesPath string
|
||||||
|
gTagsPath string
|
||||||
gMarksPath string
|
gMarksPath string
|
||||||
gHistoryPath string
|
gHistoryPath string
|
||||||
)
|
)
|
||||||
@@ -68,14 +72,25 @@ func init() {
|
|||||||
filepath.Join(data, "lf", "lfrc"),
|
filepath.Join(data, "lf", "lfrc"),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gColorsPaths = []string{
|
||||||
|
filepath.Join(os.Getenv("ProgramData"), "lf", "colors"),
|
||||||
|
filepath.Join(data, "lf", "colors"),
|
||||||
|
}
|
||||||
|
|
||||||
|
gIconsPaths = []string{
|
||||||
|
filepath.Join(os.Getenv("ProgramData"), "lf", "icons"),
|
||||||
|
filepath.Join(data, "lf", "icons"),
|
||||||
|
}
|
||||||
|
|
||||||
gFilesPath = filepath.Join(data, "lf", "files")
|
gFilesPath = filepath.Join(data, "lf", "files")
|
||||||
gMarksPath = filepath.Join(data, "lf", "marks")
|
gMarksPath = filepath.Join(data, "lf", "marks")
|
||||||
|
gTagsPath = filepath.Join(data, "lf", "tags")
|
||||||
gHistoryPath = filepath.Join(data, "lf", "history")
|
gHistoryPath = filepath.Join(data, "lf", "history")
|
||||||
}
|
}
|
||||||
|
|
||||||
func detachedCommand(name string, arg ...string) *exec.Cmd {
|
func detachedCommand(name string, arg ...string) *exec.Cmd {
|
||||||
cmd := exec.Command(name, arg...)
|
cmd := exec.Command(name, arg...)
|
||||||
cmd.SysProcAttr = &syscall.SysProcAttr{CreationFlags: 8}
|
cmd.SysProcAttr = &windows.SysProcAttr{CreationFlags: 8}
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,6 +102,13 @@ func shellCommand(s string, args []string) *exec.Cmd {
|
|||||||
return exec.Command(gOpts.shell, args...)
|
return exec.Command(gOpts.shell, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func shellSetPG(cmd *exec.Cmd) {
|
||||||
|
}
|
||||||
|
|
||||||
|
func shellKill(cmd *exec.Cmd) error {
|
||||||
|
return cmd.Process.Kill()
|
||||||
|
}
|
||||||
|
|
||||||
func setDefaults() {
|
func setDefaults() {
|
||||||
gOpts.cmds["open"] = &execExpr{"&", "%OPENER% %f%"}
|
gOpts.cmds["open"] = &execExpr{"&", "%OPENER% %f%"}
|
||||||
gOpts.keys["e"] = &execExpr{"$", "%EDITOR% %f%"}
|
gOpts.keys["e"] = &execExpr{"$", "%EDITOR% %f%"}
|
||||||
@@ -97,6 +119,8 @@ func setDefaults() {
|
|||||||
gOpts.keys["<f-1>"] = &callExpr{"doc", nil, 1}
|
gOpts.keys["<f-1>"] = &callExpr{"doc", nil, 1}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func setUserUmask() {}
|
||||||
|
|
||||||
func isExecutable(f os.FileInfo) bool {
|
func isExecutable(f os.FileInfo) bool {
|
||||||
exts := strings.Split(envPathExt, string(filepath.ListSeparator))
|
exts := strings.Split(envPathExt, string(filepath.ListSeparator))
|
||||||
for _, e := range exts {
|
for _, e := range exts {
|
||||||
@@ -109,15 +133,15 @@ func isExecutable(f os.FileInfo) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func isHidden(f os.FileInfo, path string, hiddenfiles []string) bool {
|
func isHidden(f os.FileInfo, path string, hiddenfiles []string) bool {
|
||||||
ptr, err := syscall.UTF16PtrFromString(filepath.Join(path, f.Name()))
|
ptr, err := windows.UTF16PtrFromString(filepath.Join(path, f.Name()))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
attrs, err := syscall.GetFileAttributes(ptr)
|
attrs, err := windows.GetFileAttributes(ptr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return attrs&syscall.FILE_ATTRIBUTE_HIDDEN != 0
|
return attrs&windows.FILE_ATTRIBUTE_HIDDEN != 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func userName(f os.FileInfo) string {
|
func userName(f os.FileInfo) string {
|
||||||
@@ -133,7 +157,7 @@ func linkCount(f os.FileInfo) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func errCrossDevice(err error) bool {
|
func errCrossDevice(err error) bool {
|
||||||
return err.(*os.LinkError).Err.(syscall.Errno) == 17
|
return err.(*os.LinkError).Err.(windows.Errno) == 17
|
||||||
}
|
}
|
||||||
|
|
||||||
func exportFiles(f string, fs []string, pwd string) {
|
func exportFiles(f string, fs []string, pwd string) {
|
||||||
@@ -145,9 +169,11 @@ func exportFiles(f string, fs []string, pwd string) {
|
|||||||
}
|
}
|
||||||
envFiles := strings.Join(quotedFiles, gOpts.filesep)
|
envFiles := strings.Join(quotedFiles, gOpts.filesep)
|
||||||
|
|
||||||
|
envPWD := fmt.Sprintf(`"%s"`, pwd)
|
||||||
|
|
||||||
os.Setenv("f", envFile)
|
os.Setenv("f", envFile)
|
||||||
os.Setenv("fs", envFiles)
|
os.Setenv("fs", envFiles)
|
||||||
os.Setenv("PWD", pwd)
|
os.Setenv("PWD", envPWD)
|
||||||
|
|
||||||
if len(fs) == 0 {
|
if len(fs) == 0 {
|
||||||
os.Setenv("fx", envFile)
|
os.Setenv("fx", envFile)
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ package main
|
|||||||
//
|
//
|
||||||
// MapExpr = 'map' <keys> Expr
|
// MapExpr = 'map' <keys> Expr
|
||||||
//
|
//
|
||||||
// CMapExpr = 'cmap' <key> <cmd> ';'
|
// CMapExpr = 'cmap' <key> Expr
|
||||||
//
|
//
|
||||||
// CmdExpr = 'cmd' <name> Expr
|
// CmdExpr = 'cmd' <name> Expr
|
||||||
//
|
//
|
||||||
@@ -59,10 +59,10 @@ func (e *mapExpr) String() string { return fmt.Sprintf("map %s %s", e.keys, e.ex
|
|||||||
|
|
||||||
type cmapExpr struct {
|
type cmapExpr struct {
|
||||||
key string
|
key string
|
||||||
cmd string
|
expr expr
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *cmapExpr) String() string { return fmt.Sprintf("cmap %s %s", e.key, e.cmd) }
|
func (e *cmapExpr) String() string { return fmt.Sprintf("cmap %s %s", e.key, e.expr) }
|
||||||
|
|
||||||
type cmdExpr struct {
|
type cmdExpr struct {
|
||||||
name string
|
name string
|
||||||
@@ -191,23 +191,19 @@ func (p *parser) parseExpr() expr {
|
|||||||
|
|
||||||
result = &mapExpr{keys, expr}
|
result = &mapExpr{keys, expr}
|
||||||
case "cmap":
|
case "cmap":
|
||||||
var cmd string
|
var expr expr
|
||||||
|
|
||||||
s.scan()
|
s.scan()
|
||||||
key := s.tok
|
key := s.tok
|
||||||
|
|
||||||
s.scan()
|
s.scan()
|
||||||
if s.typ != tokenSemicolon {
|
if s.typ != tokenSemicolon {
|
||||||
if s.typ != tokenIdent {
|
expr = p.parseExpr()
|
||||||
p.err = fmt.Errorf("expected command: %s", s.tok)
|
} else {
|
||||||
}
|
|
||||||
cmd = s.tok
|
|
||||||
s.scan()
|
s.scan()
|
||||||
}
|
}
|
||||||
|
|
||||||
s.scan()
|
result = &cmapExpr{key, expr}
|
||||||
|
|
||||||
result = &cmapExpr{key, cmd}
|
|
||||||
case "cmd":
|
case "cmd":
|
||||||
var expr expr
|
var expr expr
|
||||||
|
|
||||||
|
|||||||
@@ -16,15 +16,21 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func serve() {
|
func serve() {
|
||||||
f, err := os.Create(gServerLogPath)
|
if gLogPath != "" {
|
||||||
|
f, err := os.OpenFile(gLogPath, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0600)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
log.SetOutput(f)
|
log.SetOutput(f)
|
||||||
|
}
|
||||||
|
|
||||||
log.Print("hi!")
|
log.Print("hi!")
|
||||||
|
|
||||||
|
if gSocketProt == "unix" {
|
||||||
|
setUserUmask()
|
||||||
|
}
|
||||||
|
|
||||||
l, err := net.Listen(gSocketProt, gSocketPath)
|
l, err := net.Listen(gSocketProt, gSocketPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("listening socket: %s", err)
|
log.Printf("listening socket: %s", err)
|
||||||
@@ -103,8 +109,10 @@ Loop:
|
|||||||
fmt.Fprintln(c, rest)
|
fmt.Fprintln(c, rest)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if c, ok := gConnList[id]; ok {
|
if c2, ok := gConnList[id]; ok {
|
||||||
fmt.Fprintln(c, rest2)
|
fmt.Fprintln(c2, rest2)
|
||||||
|
} else {
|
||||||
|
echoerr(c, "listen: send: no such client id is connected")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package main
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@@ -279,41 +278,31 @@ var gThisYear = time.Now().Year()
|
|||||||
|
|
||||||
func infotimefmt(t time.Time) string {
|
func infotimefmt(t time.Time) string {
|
||||||
if t.Year() == gThisYear {
|
if t.Year() == gThisYear {
|
||||||
return t.Format("Jan _2 15:04")
|
return t.Format(gOpts.infotimefmtnew)
|
||||||
}
|
}
|
||||||
return t.Format("Jan _2 2006")
|
return t.Format(gOpts.infotimefmtold)
|
||||||
}
|
}
|
||||||
|
|
||||||
func fileInfo(f *file, d *dir) string {
|
func fileInfo(f *file, d *dir) string {
|
||||||
var info string
|
var info string
|
||||||
|
|
||||||
path := filepath.Join(d.path, f.Name())
|
|
||||||
|
|
||||||
for _, s := range gOpts.info {
|
for _, s := range gOpts.info {
|
||||||
switch s {
|
switch s {
|
||||||
case "size":
|
case "size":
|
||||||
if !(gOpts.dircounts && f.IsDir()) {
|
if !(f.IsDir() && gOpts.dircounts) {
|
||||||
info = fmt.Sprintf("%s %4s", info, humanize(f.Size()))
|
var sz string
|
||||||
|
if f.IsDir() && f.dirSize < 0 {
|
||||||
|
sz = "-"
|
||||||
|
} else {
|
||||||
|
sz = humanize(f.TotalSize())
|
||||||
|
}
|
||||||
|
info = fmt.Sprintf("%s %4s", info, sz)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if f.dirCount == -1 {
|
|
||||||
d, err := os.Open(path)
|
|
||||||
if err != nil {
|
|
||||||
f.dirCount = -2
|
|
||||||
}
|
|
||||||
|
|
||||||
names, err := d.Readdirnames(1000)
|
|
||||||
d.Close()
|
|
||||||
|
|
||||||
if names == nil && err != io.EOF {
|
|
||||||
f.dirCount = -2
|
|
||||||
} else {
|
|
||||||
f.dirCount = len(names)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
|
case f.dirCount < -1:
|
||||||
|
info = fmt.Sprintf("%s !", info)
|
||||||
case f.dirCount < 0:
|
case f.dirCount < 0:
|
||||||
info = fmt.Sprintf("%s ?", info)
|
info = fmt.Sprintf("%s ?", info)
|
||||||
case f.dirCount < 1000:
|
case f.dirCount < 1000:
|
||||||
@@ -322,11 +311,11 @@ func fileInfo(f *file, d *dir) string {
|
|||||||
info = fmt.Sprintf("%s 999+", info)
|
info = fmt.Sprintf("%s 999+", info)
|
||||||
}
|
}
|
||||||
case "time":
|
case "time":
|
||||||
info = fmt.Sprintf("%s %12s", info, infotimefmt(f.ModTime()))
|
info = fmt.Sprintf("%s %*s", info, max(len(gOpts.infotimefmtnew), len(gOpts.infotimefmtold)), infotimefmt(f.ModTime()))
|
||||||
case "atime":
|
case "atime":
|
||||||
info = fmt.Sprintf("%s %12s", info, infotimefmt(f.accessTime))
|
info = fmt.Sprintf("%s %*s", info, max(len(gOpts.infotimefmtnew), len(gOpts.infotimefmtold)), infotimefmt(f.accessTime))
|
||||||
case "ctime":
|
case "ctime":
|
||||||
info = fmt.Sprintf("%s %12s", info, infotimefmt(f.changeTime))
|
info = fmt.Sprintf("%s %*s", info, max(len(gOpts.infotimefmtnew), len(gOpts.infotimefmtold)), infotimefmt(f.changeTime))
|
||||||
default:
|
default:
|
||||||
log.Printf("unknown info type: %s", s)
|
log.Printf("unknown info type: %s", s)
|
||||||
}
|
}
|
||||||
@@ -335,7 +324,7 @@ func fileInfo(f *file, d *dir) string {
|
|||||||
return info
|
return info
|
||||||
}
|
}
|
||||||
|
|
||||||
func (win *win) printDir(screen tcell.Screen, dir *dir, selections map[string]int, saves map[string]bool, colors styleMap, icons iconMap) {
|
func (win *win) printDir(screen tcell.Screen, dir *dir, selections map[string]int, saves map[string]bool, tags map[string]string, colors styleMap, icons iconMap) {
|
||||||
if win.w < 5 || dir == nil {
|
if win.w < 5 || dir == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -460,11 +449,21 @@ func (win *win) printDir(screen tcell.Screen, dir *dir, selections map[string]in
|
|||||||
s = append(s, ' ')
|
s = append(s, ' ')
|
||||||
|
|
||||||
win.print(screen, lnwidth+1, i, st, string(s))
|
win.print(screen, lnwidth+1, i, st, string(s))
|
||||||
|
|
||||||
|
tag, ok := tags[path]
|
||||||
|
if ok {
|
||||||
|
if i == dir.pos {
|
||||||
|
win.print(screen, lnwidth+1, i, st.Reverse(true), tag)
|
||||||
|
} else {
|
||||||
|
win.print(screen, lnwidth+1, i, tcell.StyleDefault, fmt.Sprintf(gOpts.tagfmt, tag))
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type ui struct {
|
type ui struct {
|
||||||
screen tcell.Screen
|
screen tcell.Screen
|
||||||
|
polling bool
|
||||||
wins []*win
|
wins []*win
|
||||||
promptWin *win
|
promptWin *win
|
||||||
msgWin *win
|
msgWin *win
|
||||||
@@ -538,6 +537,7 @@ func newUI(screen tcell.Screen) *ui {
|
|||||||
|
|
||||||
ui := &ui{
|
ui := &ui{
|
||||||
screen: screen,
|
screen: screen,
|
||||||
|
polling: true,
|
||||||
wins: getWins(screen),
|
wins: getWins(screen),
|
||||||
promptWin: newWin(wtot, 1, 0, 0),
|
promptWin: newWin(wtot, 1, 0, 0),
|
||||||
msgWin: newWin(wtot, 1, 0, htot-1),
|
msgWin: newWin(wtot, 1, 0, htot-1),
|
||||||
@@ -561,6 +561,7 @@ func (ui *ui) pollEvents() {
|
|||||||
for {
|
for {
|
||||||
ev = ui.screen.PollEvent()
|
ev = ui.screen.PollEvent()
|
||||||
if ev == nil {
|
if ev == nil {
|
||||||
|
ui.polling = false
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ui.tevChan <- ev
|
ui.tevChan <- ev
|
||||||
@@ -632,6 +633,10 @@ type reg struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ui *ui) loadFile(nav *nav, volatile bool) {
|
func (ui *ui) loadFile(nav *nav, volatile bool) {
|
||||||
|
if !nav.init {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
curr, err := nav.currFile()
|
curr, err := nav.currFile()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
@@ -653,6 +658,10 @@ func (ui *ui) loadFile(nav *nav, volatile bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ui *ui) loadFileInfo(nav *nav) {
|
func (ui *ui) loadFileInfo(nav *nav) {
|
||||||
|
if !nav.init {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
curr, err := nav.currFile()
|
curr, err := nav.currFile()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
@@ -676,7 +685,8 @@ func (ui *ui) loadFileInfo(nav *nav) {
|
|||||||
func (ui *ui) drawPromptLine(nav *nav) {
|
func (ui *ui) drawPromptLine(nav *nav) {
|
||||||
st := tcell.StyleDefault
|
st := tcell.StyleDefault
|
||||||
|
|
||||||
pwd := nav.currDir().path
|
dir := nav.currDir()
|
||||||
|
pwd := dir.path
|
||||||
|
|
||||||
if strings.HasPrefix(pwd, gUser.HomeDir) {
|
if strings.HasPrefix(pwd, gUser.HomeDir) {
|
||||||
pwd = filepath.Join("~", strings.TrimPrefix(pwd, gUser.HomeDir))
|
pwd = filepath.Join("~", strings.TrimPrefix(pwd, gUser.HomeDir))
|
||||||
@@ -717,6 +727,12 @@ func (ui *ui) drawPromptLine(nav *nav) {
|
|||||||
}
|
}
|
||||||
prompt = strings.Replace(prompt, "%d", pwd, -1)
|
prompt = strings.Replace(prompt, "%d", pwd, -1)
|
||||||
|
|
||||||
|
if len(dir.filter) != 0 {
|
||||||
|
prompt = strings.Replace(prompt, "%F", fmt.Sprint(dir.filter), -1)
|
||||||
|
} else {
|
||||||
|
prompt = strings.Replace(prompt, "%F", "", -1)
|
||||||
|
}
|
||||||
|
|
||||||
ui.promptWin.print(ui.screen, 0, 0, st, prompt)
|
ui.promptWin.print(ui.screen, 0, 0, st, prompt)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -755,6 +771,10 @@ func (ui *ui) drawStatLine(nav *nav) {
|
|||||||
selection += fmt.Sprintf(" \033[35;7m %d \033[0m", len(nav.selections))
|
selection += fmt.Sprintf(" \033[35;7m %d \033[0m", len(nav.selections))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(dir.filter) != 0 {
|
||||||
|
selection += " \033[34;7m F \033[0m"
|
||||||
|
}
|
||||||
|
|
||||||
var progress string
|
var progress string
|
||||||
|
|
||||||
if nav.copyTotal > 0 {
|
if nav.copyTotal > 0 {
|
||||||
@@ -828,7 +848,7 @@ func (ui *ui) draw(nav *nav) {
|
|||||||
|
|
||||||
doff := len(nav.dirs) - length
|
doff := len(nav.dirs) - length
|
||||||
for i := 0; i < length; i++ {
|
for i := 0; i < length; i++ {
|
||||||
ui.wins[woff+i].printDir(ui.screen, nav.dirs[doff+i], nav.selections, nav.saves, ui.styles, ui.icons)
|
ui.wins[woff+i].printDir(ui.screen, nav.dirs[doff+i], nav.selections, nav.saves, nav.tags, ui.styles, ui.icons)
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ui.cmdPrefix {
|
switch ui.cmdPrefix {
|
||||||
@@ -836,22 +856,24 @@ func (ui *ui) draw(nav *nav) {
|
|||||||
ui.drawStatLine(nav)
|
ui.drawStatLine(nav)
|
||||||
ui.screen.HideCursor()
|
ui.screen.HideCursor()
|
||||||
case ">":
|
case ">":
|
||||||
pos := min(runeSliceWidth(ui.cmdAccLeft), ui.msgWin.w-len(ui.cmdPrefix)-1)
|
prefix := ui.cmdPrefix[:min(ui.msgWin.w-1, len(ui.cmdPrefix))]
|
||||||
|
pos := min(runeSliceWidth(ui.cmdAccLeft), ui.msgWin.w-len(prefix)-1)
|
||||||
left := ui.cmdAccLeft[runeSliceWidth(ui.cmdAccLeft)-pos:]
|
left := ui.cmdAccLeft[runeSliceWidth(ui.cmdAccLeft)-pos:]
|
||||||
right := ui.cmdAccRight
|
right := ui.cmdAccRight
|
||||||
ui.msgWin.printLine(ui.screen, 0, 0, st, ui.cmdPrefix)
|
ui.msgWin.printLine(ui.screen, 0, 0, st, prefix)
|
||||||
ui.msgWin.print(ui.screen, len(ui.cmdPrefix), 0, st, ui.msg)
|
ui.msgWin.print(ui.screen, len(prefix), 0, st, ui.msg)
|
||||||
ui.msgWin.print(ui.screen, len(ui.cmdPrefix)+printLength(ui.msg), 0, st, string(left))
|
ui.msgWin.print(ui.screen, len(prefix)+printLength(ui.msg), 0, st, string(left))
|
||||||
ui.msgWin.print(ui.screen, len(ui.cmdPrefix)+printLength(ui.msg)+runeSliceWidth(left), 0, st, string(right))
|
ui.msgWin.print(ui.screen, len(prefix)+printLength(ui.msg)+runeSliceWidth(left), 0, st, string(right))
|
||||||
ui.screen.ShowCursor(ui.msgWin.x+len(ui.cmdPrefix)+printLength(ui.msg)+runeSliceWidth(left), ui.msgWin.y)
|
ui.screen.ShowCursor(ui.msgWin.x+len(prefix)+printLength(ui.msg)+runeSliceWidth(left), ui.msgWin.y)
|
||||||
default:
|
default:
|
||||||
pos := min(runeSliceWidth(ui.cmdAccLeft), ui.msgWin.w-len(ui.cmdPrefix)-1)
|
prefix := ui.cmdPrefix[:min(ui.msgWin.w-1, len(ui.cmdPrefix))]
|
||||||
|
pos := min(runeSliceWidth(ui.cmdAccLeft), ui.msgWin.w-len(prefix)-1)
|
||||||
left := ui.cmdAccLeft[runeSliceWidth(ui.cmdAccLeft)-pos:]
|
left := ui.cmdAccLeft[runeSliceWidth(ui.cmdAccLeft)-pos:]
|
||||||
right := ui.cmdAccRight
|
right := ui.cmdAccRight
|
||||||
ui.msgWin.printLine(ui.screen, 0, 0, st, ui.cmdPrefix)
|
ui.msgWin.printLine(ui.screen, 0, 0, st, prefix)
|
||||||
ui.msgWin.print(ui.screen, len(ui.cmdPrefix), 0, st, string(left))
|
ui.msgWin.print(ui.screen, len(prefix), 0, st, string(left))
|
||||||
ui.msgWin.print(ui.screen, len(ui.cmdPrefix)+runeSliceWidth(left), 0, st, string(right))
|
ui.msgWin.print(ui.screen, len(prefix)+runeSliceWidth(left), 0, st, string(right))
|
||||||
ui.screen.ShowCursor(ui.msgWin.x+len(ui.cmdPrefix)+runeSliceWidth(left), ui.msgWin.y)
|
ui.screen.ShowCursor(ui.msgWin.x+len(prefix)+runeSliceWidth(left), ui.msgWin.y)
|
||||||
}
|
}
|
||||||
|
|
||||||
if gOpts.preview {
|
if gOpts.preview {
|
||||||
@@ -860,7 +882,7 @@ func (ui *ui) draw(nav *nav) {
|
|||||||
preview := ui.wins[len(ui.wins)-1]
|
preview := ui.wins[len(ui.wins)-1]
|
||||||
|
|
||||||
if curr.IsDir() {
|
if curr.IsDir() {
|
||||||
preview.printDir(ui.screen, ui.dirPrev, nav.selections, nav.saves, ui.styles, ui.icons)
|
preview.printDir(ui.screen, ui.dirPrev, nav.selections, nav.saves, nav.tags, ui.styles, ui.icons)
|
||||||
} else if curr.Mode().IsRegular() {
|
} else if curr.Mode().IsRegular() {
|
||||||
preview.printReg(ui.screen, ui.regPrev)
|
preview.printReg(ui.screen, ui.regPrev)
|
||||||
}
|
}
|
||||||
@@ -1156,7 +1178,12 @@ func (ui *ui) suspend() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ui *ui) resume() error {
|
func (ui *ui) resume() error {
|
||||||
return ui.screen.Resume()
|
err := ui.screen.Resume()
|
||||||
|
if !ui.polling {
|
||||||
|
go ui.pollEvents()
|
||||||
|
ui.polling = true
|
||||||
|
}
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func anyKey() {
|
func anyKey() {
|
||||||
|
|||||||
Reference in new issue
Block a user