Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1b71c33afd | ||
|
|
f01fab6257 | ||
|
|
85aa3b9dc6 | ||
|
|
5566f82596 | ||
|
|
0edf0823b7 | ||
|
|
05a48ea315 | ||
|
|
ff0933ca03 | ||
|
|
6c46b217af | ||
|
|
bdd1747e43 | ||
|
|
ee5b3f4813 | ||
|
|
75eba115d2 | ||
|
|
8adbd2b9ef | ||
|
|
55b9189713 | ||
|
|
b763c30cc5 | ||
|
|
61489ad00b | ||
|
|
1ff3910c70 | ||
|
|
1966a30deb | ||
|
|
50e3a6856e | ||
|
|
9885c4be7a | ||
|
|
29aa77aa27 | ||
|
|
6e9f53f4bb | ||
|
|
099cccdcb5 | ||
|
|
4220868cc7 | ||
|
|
eaaf08e425 | ||
|
|
f885af55f2 | ||
|
|
599e42c12b | ||
|
|
5d439419ea | ||
|
|
5d02b557d3 | ||
|
|
7acb69c40a | ||
|
|
7cdb7495ea | ||
|
|
d6acf4a6ec | ||
|
|
06a30eda19 | ||
|
|
7bf895e301 | ||
|
|
1841bba3e6 | ||
|
|
6ca07b1bfc | ||
|
|
ec330c1bc5 | ||
|
|
d31cd98b58 | ||
|
|
0cd634e9a8 | ||
|
|
843afdfe4f | ||
|
|
1bd78220e2 | ||
|
|
202a998731 | ||
|
|
8739087fe1 | ||
|
|
628bf408b4 | ||
|
|
4601e74d66 | ||
|
|
c8f60623f3 | ||
|
|
fec767d11b | ||
|
|
0dcfb3d4fe | ||
|
|
0cfd34f30d | ||
|
|
229b7b1ade | ||
|
|
ca0068514a | ||
|
|
aebff483a7 | ||
|
|
5166eef0b3 | ||
|
|
73be81595e | ||
|
|
06bf58851b | ||
|
|
b7aaa23bd0 | ||
|
|
a9cb7156a3 | ||
|
|
91f40b1f02 | ||
|
|
1544d62206 | ||
|
|
8742f25706 | ||
|
|
ced1ccd0c3 | ||
|
|
7dfdcb51c0 | ||
|
|
2c3cd35a5d | ||
|
|
c071e37316 | ||
|
|
4c0efdcb41 | ||
|
|
1b93f2232e | ||
|
|
9ec336fcdb | ||
|
|
6422bd7492 | ||
|
|
60d6119858 | ||
|
|
3e403bb888 | ||
|
|
9d451ffd19 | ||
|
|
2aa50aecaf | ||
|
|
13d19d84f9 | ||
|
|
1163efb7aa | ||
|
|
c6cf0e61ba |
No files matched your search
@@ -0,0 +1,25 @@
|
|||||||
|
name: Go
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ master ]
|
||||||
|
pull_request:
|
||||||
|
branches: [ master ]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Set up Go
|
||||||
|
uses: actions/setup-go@v2
|
||||||
|
with:
|
||||||
|
go-version: 1.15
|
||||||
|
|
||||||
|
- 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.15
|
||||||
|
|
||||||
|
- 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
|
|
||||||
@@ -5,9 +5,8 @@
|
|||||||
| [#lf](https://webchat.freenode.net/?channels=lf) (on Freenode)
|
| [#lf](https://webchat.freenode.net/?channels=lf) (on Freenode)
|
||||||
| [#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://godoc.org/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.
|
||||||
|
|
||||||
@@ -62,7 +61,7 @@ After the installation `lf` command should start the application in the current
|
|||||||
|
|
||||||
Run `lf -help` to see command line options.
|
Run `lf -help` to see command line options.
|
||||||
|
|
||||||
Run `lf -doc` to see the [documentation](https://godoc.org/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 or editor.
|
||||||
An example configuration file can also be found in this directory.
|
An example configuration file can also be found in this directory.
|
||||||
|
|||||||
@@ -12,8 +12,6 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/gdamore/tcell/v2"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type cmdItem struct {
|
type cmdItem struct {
|
||||||
@@ -34,10 +32,7 @@ type app struct {
|
|||||||
cmdHistoryInd int
|
cmdHistoryInd int
|
||||||
}
|
}
|
||||||
|
|
||||||
func newApp(screen tcell.Screen) *app {
|
func newApp(ui *ui, nav *nav) *app {
|
||||||
ui := newUI(screen)
|
|
||||||
nav := newNav(ui.wins[0].h)
|
|
||||||
|
|
||||||
quitChan := make(chan struct{}, 1)
|
quitChan := make(chan struct{}, 1)
|
||||||
|
|
||||||
app := &app{
|
app := &app{
|
||||||
@@ -54,8 +49,7 @@ func newApp(screen tcell.Screen) *app {
|
|||||||
case os.Interrupt:
|
case os.Interrupt:
|
||||||
return
|
return
|
||||||
case syscall.SIGHUP, syscall.SIGQUIT, syscall.SIGTERM:
|
case syscall.SIGHUP, syscall.SIGQUIT, syscall.SIGTERM:
|
||||||
app.writeHistory()
|
app.quit()
|
||||||
os.Remove(gLogPath)
|
|
||||||
os.Exit(3)
|
os.Exit(3)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -64,6 +58,23 @@ func newApp(screen tcell.Screen) *app {
|
|||||||
return app
|
return app
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (app *app) quit() {
|
||||||
|
if err := app.writeHistory(); err != nil {
|
||||||
|
log.Printf("writing history file: %s", err)
|
||||||
|
}
|
||||||
|
if !gSingleMode {
|
||||||
|
if err := remote(fmt.Sprintf("drop %d", gClientID)); err != nil {
|
||||||
|
log.Printf("dropping connection: %s", err)
|
||||||
|
}
|
||||||
|
if gOpts.autoquit {
|
||||||
|
if err := remote("quit"); err != nil {
|
||||||
|
log.Printf("auto quitting server: %s", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
os.Remove(gLogPath)
|
||||||
|
}
|
||||||
|
|
||||||
func (app *app) readFile(path string) {
|
func (app *app) readFile(path string) {
|
||||||
log.Printf("reading file: %s", path)
|
log.Printf("reading file: %s", path)
|
||||||
|
|
||||||
@@ -85,6 +96,72 @@ func (app *app) readFile(path string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func loadFiles() (list []string, cp bool, err error) {
|
||||||
|
files, err := os.Open(gFilesPath)
|
||||||
|
if os.IsNotExist(err) {
|
||||||
|
err = nil
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
err = fmt.Errorf("opening file selections file: %s", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer files.Close()
|
||||||
|
|
||||||
|
s := bufio.NewScanner(files)
|
||||||
|
|
||||||
|
s.Scan()
|
||||||
|
|
||||||
|
switch s.Text() {
|
||||||
|
case "copy":
|
||||||
|
cp = true
|
||||||
|
case "move":
|
||||||
|
cp = false
|
||||||
|
default:
|
||||||
|
err = fmt.Errorf("unexpected option to copy file(s): %s", s.Text())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
for s.Scan() && s.Text() != "" {
|
||||||
|
list = append(list, s.Text())
|
||||||
|
}
|
||||||
|
|
||||||
|
if s.Err() != nil {
|
||||||
|
err = fmt.Errorf("scanning file list: %s", s.Err())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Printf("loading files: %v", list)
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("opening file selections file: %s", err)
|
||||||
|
}
|
||||||
|
defer files.Close()
|
||||||
|
|
||||||
|
log.Printf("saving files: %v", list)
|
||||||
|
|
||||||
|
if cp {
|
||||||
|
fmt.Fprintln(files, "copy")
|
||||||
|
} else {
|
||||||
|
fmt.Fprintln(files, "move")
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, f := range list {
|
||||||
|
fmt.Fprintln(files, f)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (app *app) readHistory() error {
|
func (app *app) readHistory() error {
|
||||||
f, err := os.Open(gHistoryPath)
|
f, err := os.Open(gHistoryPath)
|
||||||
if os.IsNotExist(err) {
|
if os.IsNotExist(err) {
|
||||||
@@ -160,7 +237,12 @@ func (app *app) writeHistory() error {
|
|||||||
// for evaluation. Similarly directories and regular files are also read in
|
// for evaluation. Similarly directories and regular files are also read in
|
||||||
// separate goroutines and sent here for update.
|
// separate goroutines and sent here for update.
|
||||||
func (app *app) loop() {
|
func (app *app) loop() {
|
||||||
serverChan := readExpr()
|
go app.nav.previewLoop(app.ui)
|
||||||
|
|
||||||
|
var serverChan <-chan expr
|
||||||
|
if !gSingleMode {
|
||||||
|
serverChan = readExpr()
|
||||||
|
}
|
||||||
|
|
||||||
app.ui.readExpr()
|
app.ui.readExpr()
|
||||||
|
|
||||||
@@ -177,11 +259,19 @@ func (app *app) loop() {
|
|||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if gConfigPath != "" {
|
||||||
|
if _, err := os.Stat(gConfigPath); !os.IsNotExist(err) {
|
||||||
|
app.readFile(gConfigPath)
|
||||||
|
} else {
|
||||||
|
log.Printf("config file does not exist: %s", err)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
for _, path := range gConfigPaths {
|
for _, path := range gConfigPaths {
|
||||||
if _, err := os.Stat(path); !os.IsNotExist(err) {
|
if _, err := os.Stat(path); !os.IsNotExist(err) {
|
||||||
app.readFile(path)
|
app.readFile(path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for _, cmd := range gCommands {
|
for _, cmd := range gCommands {
|
||||||
p := newParser(strings.NewReader(cmd))
|
p := newParser(strings.NewReader(cmd))
|
||||||
@@ -213,14 +303,12 @@ func (app *app) loop() {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
app.quit()
|
||||||
|
|
||||||
app.nav.previewChan <- ""
|
app.nav.previewChan <- ""
|
||||||
|
|
||||||
log.Print("bye!")
|
log.Print("bye!")
|
||||||
|
|
||||||
if err := app.writeHistory(); err != nil {
|
|
||||||
log.Printf("writing history file: %s", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if gLastDirPath != "" {
|
if gLastDirPath != "" {
|
||||||
f, err := os.Create(gLastDirPath)
|
f, err := os.Create(gLastDirPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -284,6 +372,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
|
||||||
@@ -291,6 +380,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 {
|
||||||
@@ -366,21 +456,7 @@ func (app *app) exportFiles() {
|
|||||||
|
|
||||||
currSelections := app.nav.currSelections()
|
currSelections := app.nav.currSelections()
|
||||||
|
|
||||||
exportFiles(currFile, currSelections)
|
exportFiles(currFile, currSelections, app.nav.currDir().path)
|
||||||
}
|
|
||||||
|
|
||||||
func waitKey() error {
|
|
||||||
cmd := pauseCommand()
|
|
||||||
|
|
||||||
cmd.Stdin = os.Stdin
|
|
||||||
cmd.Stdout = os.Stdout
|
|
||||||
cmd.Stderr = os.Stderr
|
|
||||||
|
|
||||||
if err := cmd.Run(); err != nil {
|
|
||||||
return fmt.Errorf("waiting key: %s", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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:
|
||||||
@@ -405,12 +481,23 @@ func (app *app) runShell(s string, args []string, prefix string) {
|
|||||||
cmd.Stderr = os.Stderr
|
cmd.Stderr = os.Stderr
|
||||||
|
|
||||||
app.nav.previewChan <- ""
|
app.nav.previewChan <- ""
|
||||||
app.ui.pause()
|
if err := app.ui.suspend(); err != nil {
|
||||||
defer app.ui.resume()
|
log.Printf("suspend: %s", err)
|
||||||
|
}
|
||||||
|
defer func() {
|
||||||
|
if err := app.ui.resume(); err != nil {
|
||||||
|
app.quit()
|
||||||
|
os.Exit(3)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}()
|
||||||
defer app.nav.renew()
|
defer app.nav.renew()
|
||||||
|
|
||||||
err = cmd.Run()
|
err = cmd.Run()
|
||||||
case "%":
|
case "%":
|
||||||
|
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)
|
||||||
@@ -433,15 +520,14 @@ func (app *app) runShell(s string, args []string, prefix string) {
|
|||||||
|
|
||||||
switch prefix {
|
switch prefix {
|
||||||
case "!":
|
case "!":
|
||||||
if err := waitKey(); err != nil {
|
anyKey()
|
||||||
app.ui.echoerrf("waiting key: %s", err)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
app.ui.loadFile(app.nav, true)
|
app.ui.loadFile(app.nav, true)
|
||||||
|
|
||||||
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 = ""
|
||||||
|
|||||||
@@ -21,19 +21,26 @@ func run() {
|
|||||||
} else if err = screen.Init(); err != nil {
|
} else if err = screen.Init(); err != nil {
|
||||||
log.Fatalf("initializing screen: %s", err)
|
log.Fatalf("initializing screen: %s", err)
|
||||||
}
|
}
|
||||||
|
if gOpts.mouse {
|
||||||
screen.EnableMouse()
|
screen.EnableMouse()
|
||||||
|
}
|
||||||
|
|
||||||
f, err := os.Create(gLogPath)
|
f, err := os.Create(gLogPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
defer os.Remove(gLogPath)
|
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
log.SetOutput(f)
|
log.SetOutput(f)
|
||||||
|
|
||||||
log.Print("hi!")
|
log.Print("hi!")
|
||||||
|
|
||||||
app := newApp(screen)
|
ui := newUI(screen)
|
||||||
|
nav := newNav(ui.wins[0].h)
|
||||||
|
app := newApp(ui, nav)
|
||||||
|
|
||||||
|
if err := nav.sync(); err != nil {
|
||||||
|
app.ui.echoerrf("sync: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
if err := app.nav.readMarks(); err != nil {
|
if err := app.nav.readMarks(); err != nil {
|
||||||
app.ui.echoerrf("reading marks file: %s", err)
|
app.ui.echoerrf("reading marks file: %s", err)
|
||||||
@@ -43,8 +50,8 @@ func run() {
|
|||||||
app.ui.echoerrf("reading history file: %s", err)
|
app.ui.echoerrf("reading history file: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
go app.nav.previewLoop(app.ui)
|
|
||||||
app.loop()
|
app.loop()
|
||||||
|
|
||||||
app.ui.screen.Fini()
|
app.ui.screen.Fini()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,69 +88,6 @@ func readExpr() <-chan expr {
|
|||||||
return ch
|
return ch
|
||||||
}
|
}
|
||||||
|
|
||||||
func saveFiles(list []string, cp bool) error {
|
|
||||||
c, err := net.Dial(gSocketProt, gSocketPath)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("dialing to save files: %s", err)
|
|
||||||
}
|
|
||||||
defer c.Close()
|
|
||||||
|
|
||||||
log.Printf("saving files: %v", list)
|
|
||||||
|
|
||||||
fmt.Fprintln(c, "save")
|
|
||||||
|
|
||||||
if cp {
|
|
||||||
fmt.Fprintln(c, "copy")
|
|
||||||
} else {
|
|
||||||
fmt.Fprintln(c, "move")
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, f := range list {
|
|
||||||
fmt.Fprintln(c, f)
|
|
||||||
}
|
|
||||||
fmt.Fprintln(c)
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func loadFiles() (list []string, cp bool, err error) {
|
|
||||||
c, e := net.Dial(gSocketProt, gSocketPath)
|
|
||||||
if e != nil {
|
|
||||||
err = fmt.Errorf("dialing to load files: %s", e)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
defer c.Close()
|
|
||||||
|
|
||||||
fmt.Fprintln(c, "load")
|
|
||||||
|
|
||||||
s := bufio.NewScanner(c)
|
|
||||||
|
|
||||||
s.Scan()
|
|
||||||
|
|
||||||
switch s.Text() {
|
|
||||||
case "copy":
|
|
||||||
cp = true
|
|
||||||
case "move":
|
|
||||||
cp = false
|
|
||||||
default:
|
|
||||||
err = fmt.Errorf("unexpected option to copy file(s): %s", s.Text())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
for s.Scan() && s.Text() != "" {
|
|
||||||
list = append(list, s.Text())
|
|
||||||
}
|
|
||||||
|
|
||||||
if s.Err() != nil {
|
|
||||||
err = fmt.Errorf("scanning file list: %s", s.Err())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
log.Printf("loading files: %v", list)
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func remote(cmd string) error {
|
func remote(cmd string) error {
|
||||||
c, err := net.Dial(gSocketProt, gSocketPath)
|
c, err := net.Dial(gSocketProt, gSocketPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -118,6 +118,8 @@ func applyAnsiCodes(s string, st tcell.Style) tcell.Style {
|
|||||||
st = st.StrikeThrough(true)
|
st = st.StrikeThrough(true)
|
||||||
case n >= 30 && n <= 37:
|
case n >= 30 && n <= 37:
|
||||||
st = st.Foreground(tcell.PaletteColor(n - 30))
|
st = st.Foreground(tcell.PaletteColor(n - 30))
|
||||||
|
case n >= 90 && n <= 97:
|
||||||
|
st = st.Foreground(tcell.PaletteColor(n - 82))
|
||||||
case n == 38:
|
case n == 38:
|
||||||
if i+3 <= len(nums) && nums[i+1] == 5 {
|
if i+3 <= len(nums) && nums[i+1] == 5 {
|
||||||
st = st.Foreground(tcell.PaletteColor(nums[i+2]))
|
st = st.Foreground(tcell.PaletteColor(nums[i+2]))
|
||||||
@@ -133,6 +135,8 @@ func applyAnsiCodes(s string, st tcell.Style) tcell.Style {
|
|||||||
}
|
}
|
||||||
case n >= 40 && n <= 47:
|
case n >= 40 && n <= 47:
|
||||||
st = st.Background(tcell.PaletteColor(n - 40))
|
st = st.Background(tcell.PaletteColor(n - 40))
|
||||||
|
case n >= 100 && n <= 107:
|
||||||
|
st = st.Background(tcell.PaletteColor(n - 92))
|
||||||
case n == 48:
|
case n == 48:
|
||||||
if i+3 <= len(nums) && nums[i+1] == 5 {
|
if i+3 <= len(nums) && nums[i+1] == 5 {
|
||||||
st = st.Background(tcell.PaletteColor(nums[i+2]))
|
st = st.Background(tcell.PaletteColor(nums[i+2]))
|
||||||
|
|||||||
+27
-2
@@ -48,6 +48,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",
|
||||||
@@ -70,12 +72,21 @@ var (
|
|||||||
"anchorfind",
|
"anchorfind",
|
||||||
"noanchorfind",
|
"noanchorfind",
|
||||||
"anchorfind!",
|
"anchorfind!",
|
||||||
|
"autoquit",
|
||||||
|
"noautoquit",
|
||||||
|
"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!",
|
||||||
@@ -97,6 +108,12 @@ var (
|
|||||||
"incsearch",
|
"incsearch",
|
||||||
"noincsearch",
|
"noincsearch",
|
||||||
"incsearch!",
|
"incsearch!",
|
||||||
|
"incfilter",
|
||||||
|
"noincfilter",
|
||||||
|
"incfilter!",
|
||||||
|
"mouse",
|
||||||
|
"nomouse",
|
||||||
|
"mouse!",
|
||||||
"number",
|
"number",
|
||||||
"nonumber",
|
"nonumber",
|
||||||
"number!",
|
"number!",
|
||||||
@@ -115,6 +132,7 @@ var (
|
|||||||
"smartdia",
|
"smartdia",
|
||||||
"nosmartdia",
|
"nosmartdia",
|
||||||
"smartdia!",
|
"smartdia!",
|
||||||
|
"waitmsg",
|
||||||
"wrapscan",
|
"wrapscan",
|
||||||
"nowrapscan",
|
"nowrapscan",
|
||||||
"wrapscan!",
|
"wrapscan!",
|
||||||
@@ -135,6 +153,7 @@ var (
|
|||||||
"promptfmt",
|
"promptfmt",
|
||||||
"ratios",
|
"ratios",
|
||||||
"shell",
|
"shell",
|
||||||
|
"shellflag",
|
||||||
"shellopts",
|
"shellopts",
|
||||||
"sortby",
|
"sortby",
|
||||||
"timefmt",
|
"timefmt",
|
||||||
@@ -243,18 +262,24 @@ func matchFile(s string) (matches []string, longest string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, f := range files {
|
for _, f := range files {
|
||||||
f, err := os.Stat(filepath.Join(dir, f.Name()))
|
name := filepath.Join(dir, f.Name())
|
||||||
|
f, err := os.Stat(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
fl, err := os.Lstat(name)
|
||||||
|
if err == nil && fl.Mode()&os.ModeSymlink != 0 {
|
||||||
|
continue
|
||||||
|
} else {
|
||||||
log.Printf("getting file information: %s", err)
|
log.Printf("getting file information: %s", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_, last := filepath.Split(s)
|
_, last := filepath.Split(s)
|
||||||
if !strings.HasPrefix(escape(f.Name()), last) {
|
if !strings.HasPrefix(escape(f.Name()), last) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
name := f.Name()
|
name = f.Name()
|
||||||
if isRoot(s) || filepath.Base(s) != s {
|
if isRoot(s) || filepath.Base(s) != s {
|
||||||
name = filepath.Join(filepath.Dir(unescape(s)), f.Name())
|
name = filepath.Join(filepath.Dir(unescape(s)), f.Name())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ func copySize(srcs []string) (int64, error) {
|
|||||||
var total int64
|
var total int64
|
||||||
|
|
||||||
for _, src := range srcs {
|
for _, src := range srcs {
|
||||||
_, err := os.Stat(src)
|
_, err := os.Lstat(src)
|
||||||
if os.IsNotExist(err) {
|
if os.IsNotExist(err) {
|
||||||
return total, fmt.Errorf("src does not exist: %q", src)
|
return total, fmt.Errorf("src does not exist: %q", src)
|
||||||
}
|
}
|
||||||
@@ -112,6 +112,15 @@ func copyAll(srcs []string, dstDir string) (nums chan int64, errs chan error) {
|
|||||||
errs <- fmt.Errorf("mkdir: %s", err)
|
errs <- fmt.Errorf("mkdir: %s", err)
|
||||||
}
|
}
|
||||||
nums <- info.Size()
|
nums <- info.Size()
|
||||||
|
} else if info.Mode()&os.ModeSymlink != 0 { /* Symlink */
|
||||||
|
if rlink, err := os.Readlink(path); err != nil {
|
||||||
|
errs <- fmt.Errorf("symlink: %s", err)
|
||||||
|
} else {
|
||||||
|
if err := os.Symlink(rlink, newPath); err != nil {
|
||||||
|
errs <- fmt.Errorf("symlink: %s", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
nums <- info.Size()
|
||||||
} else {
|
} else {
|
||||||
if err := copyFile(path, newPath, info, nums); err != nil {
|
if err := copyFile(path, newPath, info, nums); err != nil {
|
||||||
errs <- fmt.Errorf("copy: %s", err)
|
errs <- fmt.Errorf("copy: %s", err)
|
||||||
|
|||||||
@@ -6,9 +6,8 @@ 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
|
This documentation can either be read from terminal using 'lf -doc' or online at https://godoc.org/github.com/gokcehan/lf.
|
||||||
at https://godoc.org/github.com/gokcehan/lf. You can also use 'doc' command
|
You can also use 'doc' command (default '<f-1>') inside lf to view the documentation in a pager.
|
||||||
(default '<f-1>') inside lf to view the documentation in a pager.
|
|
||||||
|
|
||||||
You can run 'lf -help' to see descriptions of command line options.
|
You can run 'lf -help' to see descriptions of command line options.
|
||||||
|
|
||||||
@@ -63,6 +62,8 @@ 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 `"`)
|
||||||
@@ -99,8 +100,11 @@ The following command line commands are provided by lf:
|
|||||||
The following options can be used to customize the behavior of lf:
|
The following options can be used to customize the behavior of lf:
|
||||||
|
|
||||||
anchorfind bool (default on)
|
anchorfind bool (default on)
|
||||||
|
autoquit bool (default off)
|
||||||
|
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,8 +116,10 @@ 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 '')
|
||||||
|
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)
|
||||||
@@ -125,6 +131,7 @@ The following options can be used to customize the behavior of lf:
|
|||||||
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)
|
||||||
shellopts []string (default '')
|
shellopts []string (default '')
|
||||||
smartcase bool (default on)
|
smartcase bool (default on)
|
||||||
smartdia bool (default off)
|
smartdia bool (default off)
|
||||||
@@ -132,6 +139,7 @@ The following options can be used to customize the behavior of lf:
|
|||||||
tabstop int (default 8)
|
tabstop int (default 8)
|
||||||
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')
|
||||||
wrapscan bool (default on)
|
wrapscan bool (default on)
|
||||||
wrapscroll bool (default off)
|
wrapscroll bool (default off)
|
||||||
|
|
||||||
@@ -141,6 +149,8 @@ The following environment variables are exported for shell commands:
|
|||||||
fs
|
fs
|
||||||
fx
|
fx
|
||||||
id
|
id
|
||||||
|
PWD
|
||||||
|
OLDPWD
|
||||||
LF_LEVEL
|
LF_LEVEL
|
||||||
OPENER
|
OPENER
|
||||||
EDITOR
|
EDITOR
|
||||||
@@ -180,6 +190,11 @@ Configuration files should be located at:
|
|||||||
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
|
||||||
|
|
||||||
|
Selection file should be located at:
|
||||||
|
|
||||||
|
unix ~/.local/share/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
|
||||||
@@ -358,7 +373,7 @@ Read a shell command to execute and wait for a key press in the end.
|
|||||||
|
|
||||||
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')
|
||||||
@@ -378,6 +393,15 @@ Read a pattern to search for a file name match in the forward/backward direction
|
|||||||
|
|
||||||
(See also 'globsearch', 'incsearch', 'wrapscan', 'ignorecase', 'smartcase', 'ignoredia', and 'smartdia' options and 'Searching Files' section)
|
(See also 'globsearch', 'incsearch', 'wrapscan', 'ignorecase', 'smartcase', 'ignoredia', and 'smartdia' options and 'Searching Files' section)
|
||||||
|
|
||||||
|
filter (modal)
|
||||||
|
setfilter
|
||||||
|
|
||||||
|
Read a pattern to filter out and only view files matching the pattern.
|
||||||
|
setfilter does the same but uses an argument to set the filter immediatly.
|
||||||
|
You can supply an argument to filter, in order to use that as the starting prompt.
|
||||||
|
|
||||||
|
(See also 'globsearch', 'incfilter', 'ignorecase', 'smartcase', 'ignoredia', and 'smartdia' options)
|
||||||
|
|
||||||
mark-save (modal) (default 'm')
|
mark-save (modal) (default 'm')
|
||||||
|
|
||||||
Save the current directory as a bookmark assigned to the given key.
|
Save the current directory as a bookmark assigned to the given key.
|
||||||
@@ -485,6 +509,14 @@ Character ':' is used as the separator for list options '[]int' and '[]string'.
|
|||||||
|
|
||||||
When this option is enabled, find command starts matching patterns from the beginning of file names, otherwise, it can match at an arbitrary position.
|
When this option is enabled, find command starts matching patterns from the beginning of file names, otherwise, it can match at an arbitrary position.
|
||||||
|
|
||||||
|
autoquit bool (default off)
|
||||||
|
|
||||||
|
Automatically quit server when there are no clients left connected.
|
||||||
|
|
||||||
|
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.
|
||||||
@@ -498,6 +530,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.
|
||||||
@@ -563,12 +599,20 @@ 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.
|
||||||
|
|
||||||
|
mouse bool (default off)
|
||||||
|
|
||||||
|
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.
|
||||||
@@ -607,7 +651,7 @@ 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.
|
||||||
|
|
||||||
@@ -635,9 +679,11 @@ A smaller offset can be used when the current file is close to the beginning or
|
|||||||
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.
|
||||||
On unix, a POSIX compatible shell is required.
|
Shell commands are executed as 'shell shellopts shellflag command -- arguments'.
|
||||||
Shell commands are executed as 'shell shellopts -c command -- arguments'.
|
|
||||||
On windows, '/c' is used instead of '-c' which should work in 'cmd' and 'powershell'.
|
shellflag string (default '-c' for unix and '/c' for windows)
|
||||||
|
|
||||||
|
Command line flag used to pass shell commands.
|
||||||
|
|
||||||
shellopts []string (default '')
|
shellopts []string (default '')
|
||||||
|
|
||||||
@@ -670,6 +716,10 @@ Format string of the file modification time shown in the bottom line.
|
|||||||
|
|
||||||
Truncate character shown at the end when the file name does not fit to the pane.
|
Truncate character shown at the end when the file name does not fit to the pane.
|
||||||
|
|
||||||
|
waitmsg string (default 'Press any key to continue')
|
||||||
|
|
||||||
|
String shown after commands of shell-wait type.
|
||||||
|
|
||||||
wrapscan bool (default on)
|
wrapscan bool (default on)
|
||||||
|
|
||||||
Searching can wrap around the file list.
|
Searching can wrap around the file list.
|
||||||
@@ -699,6 +749,14 @@ Selected file(s) (i.e. 'fs') if there are any selected files, otherwise current
|
|||||||
|
|
||||||
Id of the running client.
|
Id of the running client.
|
||||||
|
|
||||||
|
PWD
|
||||||
|
|
||||||
|
Present working directory.
|
||||||
|
|
||||||
|
OLDPWD
|
||||||
|
|
||||||
|
Initial working directory.
|
||||||
|
|
||||||
LF_LEVEL
|
LF_LEVEL
|
||||||
|
|
||||||
The value of this variable is set to the current nesting level when you run lf from a shell spawned inside lf.
|
The value of this variable is set to the current nesting level when you run lf from a shell spawned inside lf.
|
||||||
@@ -759,7 +817,7 @@ Command 'map' is used to bind a key to a command which can be builtin command, c
|
|||||||
map gh cd ~ # builtin command
|
map gh cd ~ # builtin command
|
||||||
map D trash # custom command
|
map D trash # custom command
|
||||||
map i $less $f # shell command
|
map i $less $f # shell command
|
||||||
map U !du -sh # waiting shell command
|
map U !du -csh * # waiting shell command
|
||||||
|
|
||||||
Command 'cmap' is used to bind a key to a command line command which can only be one of the builtin commands:
|
Command 'cmap' is used to bind a key to a command line command which can only be one of the builtin commands:
|
||||||
|
|
||||||
@@ -974,10 +1032,11 @@ This is the recommended way of using remote commands since it is shorter and imm
|
|||||||
In this command 'send' is used to send the rest of the string as a command to all connected clients.
|
In this command 'send' is used to send the rest of the string as a command to all connected clients.
|
||||||
You can optionally give it an id number to send a command to a single client:
|
You can optionally give it an id number to send a command to a single client:
|
||||||
|
|
||||||
lf -remote 'send 1000 echo hello world'
|
lf -remote 'send 1234 echo hello world'
|
||||||
|
|
||||||
All clients have a unique id number but you may not be aware of the id number when you are writing a command.
|
All clients have a unique id number but you may not be aware of the id number when you are writing a command.
|
||||||
For this purpose, an '$id' variable is exported to the environment for shell commands.
|
For this purpose, an '$id' variable is exported to the environment for shell commands.
|
||||||
|
The value of this variable is set to the process id of the client.
|
||||||
You can use it to send a remote command from a client to the server which in return sends a command back to itself.
|
You can use it to send a remote command from a client to the server which in return sends a command back to itself.
|
||||||
So now you can display a message in the current client by calling the following in a shell command:
|
So now you can display a message in the current client by calling the following in a shell command:
|
||||||
|
|
||||||
@@ -997,27 +1056,10 @@ For example, you can configure the number of columns in the ui with respect to t
|
|||||||
fi
|
fi
|
||||||
}}
|
}}
|
||||||
|
|
||||||
Besides 'send' command, there are also two commands to get or set the current file selection.
|
Besides 'send' command, there is a 'quit' command to quit the server when there are no connected clients left, and a 'quit!' command to force quit the server by closing client connections first:
|
||||||
Two possible modes 'copy' and 'move' specify whether selected files are to be copied or moved.
|
|
||||||
File names are separated by newline character.
|
|
||||||
Setting the file selection is done with 'save' command:
|
|
||||||
|
|
||||||
lf -remote "$(printf 'save\ncopy\nfoo.txt\nbar.txt\nbaz.txt\n')"
|
|
||||||
|
|
||||||
Getting the file selection is similarly done with 'load' command:
|
|
||||||
|
|
||||||
load=$(lf -remote 'load')
|
|
||||||
mode=$(echo "$load" | sed -n '1p')
|
|
||||||
list=$(echo "$load" | sed '1d')
|
|
||||||
if [ $mode = 'copy' ]; then
|
|
||||||
# do something with $list
|
|
||||||
elif [ $mode = 'move' ]; then
|
|
||||||
# do something else with $list
|
|
||||||
fi
|
|
||||||
|
|
||||||
There is a 'quit' command to close client connections and quit the server:
|
|
||||||
|
|
||||||
lf -remote 'quit'
|
lf -remote 'quit'
|
||||||
|
lf -remote 'quit!'
|
||||||
|
|
||||||
Lastly, there is a 'conn' command to connect the server as a client.
|
Lastly, there is a 'conn' command to connect the server as a client.
|
||||||
This should not be needed for users.
|
This should not be needed for users.
|
||||||
@@ -1028,14 +1070,14 @@ lf uses its own builtin copy and move operations by default.
|
|||||||
These are implemented as asynchronous operations and progress is shown in the bottom ruler.
|
These are implemented as asynchronous operations and progress is shown in the bottom ruler.
|
||||||
These commands do not overwrite existing files or directories with the same name.
|
These commands do not overwrite existing files or directories with the same name.
|
||||||
Instead, a suffix that is compatible with '--backup=numbered' option in GNU cp is added to the new files or directories.
|
Instead, a suffix that is compatible with '--backup=numbered' option in GNU cp is added to the new files or directories.
|
||||||
Only file modes are preserved and all other attributes are ignored including ownership, timestamps, context, links, and xattr.
|
Only file modes are preserved and all other attributes are ignored including ownership, timestamps, context, and xattr.
|
||||||
Special files such as character and block devices, named pipes, and sockets are skipped and links are followed.
|
Special files such as character and block devices, named pipes, and sockets are skipped and links are not followed.
|
||||||
Moving is performed using the rename operation of the underlying OS.
|
Moving is performed using the rename operation of the underlying OS.
|
||||||
For cross-device moving, lf falls back to copying and then deletes the original files if there are no errors.
|
For cross-device moving, lf falls back to copying and then deletes the original files if there are no errors.
|
||||||
Operation errors are shown in the message line as well as the log file and they do not preemptively finish the corresponding file operation.
|
Operation errors are shown in the message line as well as the log file and they do not preemptively finish the corresponding file operation.
|
||||||
|
|
||||||
File operations can be performed on the current selected file or alternatively on multiple files by selecting them first.
|
File operations can be performed on the current selected file or alternatively on multiple files by selecting them first.
|
||||||
When you 'copy' a file, lf doesn't actually copy the file on the disk, but only records its name to memory.
|
When you 'copy' a file, lf doesn't actually copy the file on the disk, but only records its name to a file.
|
||||||
The actual file copying takes place when you 'paste'.
|
The actual file copying takes place when you 'paste'.
|
||||||
Similarly 'paste' after a 'cut' operation moves the file.
|
Similarly 'paste' after a 'cut' operation moves the file.
|
||||||
|
|
||||||
@@ -1044,7 +1086,7 @@ This is a special command that is called when it is defined instead of the built
|
|||||||
You can use the following example as a starting point:
|
You can use the following example as a starting point:
|
||||||
|
|
||||||
cmd paste %{{
|
cmd paste %{{
|
||||||
load=$(lf -remote 'load')
|
load=$(cat ~/.local/share/lf/files)
|
||||||
mode=$(echo "$load" | sed -n '1p')
|
mode=$(echo "$load" | sed -n '1p')
|
||||||
list=$(echo "$load" | sed '1d')
|
list=$(echo "$load" | sed '1d')
|
||||||
if [ $mode = 'copy' ]; then
|
if [ $mode = 'copy' ]; then
|
||||||
@@ -1052,7 +1094,7 @@ You can use the following example as a starting point:
|
|||||||
elif [ $mode = 'move' ]; then
|
elif [ $mode = 'move' ]; then
|
||||||
mv $list .
|
mv $list .
|
||||||
fi
|
fi
|
||||||
lf -remote 'send load'
|
rm ~/.local/share/lf/files
|
||||||
lf -remote 'send clear'
|
lf -remote 'send clear'
|
||||||
}}
|
}}
|
||||||
|
|
||||||
@@ -1111,6 +1153,7 @@ It is possible to use different command types:
|
|||||||
You may want to use either file extensions or mime types from 'file' command:
|
You may want to use either file extensions or mime types from 'file' command:
|
||||||
|
|
||||||
cmd open ${{
|
cmd open ${{
|
||||||
|
test -L $f && f=$(readlink -f $f)
|
||||||
case $(file --mime-type $f -b) in
|
case $(file --mime-type $f -b) in
|
||||||
text/*) vi $fx;;
|
text/*) vi $fx;;
|
||||||
*) for f in $fx; do xdg-open $f > /dev/null 2> /dev/null & done;;
|
*) for f in $fx; do xdg-open $f > /dev/null 2> /dev/null & done;;
|
||||||
@@ -1158,7 +1201,7 @@ Extensions can then be used to match cleanly within a conditional:
|
|||||||
*.rar) unrar l "$1";;
|
*.rar) unrar l "$1";;
|
||||||
*.7z) 7z l "$1";;
|
*.7z) 7z l "$1";;
|
||||||
*.pdf) pdftotext "$1" -;;
|
*.pdf) pdftotext "$1" -;;
|
||||||
*) highlight -O ansi "$1" || cat "$1";;
|
*) highlight -O ansi "$1";;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
Another important consideration for efficiency is the use of programs with short startup times for preview.
|
Another important consideration for efficiency is the use of programs with short startup times for preview.
|
||||||
@@ -1168,13 +1211,9 @@ This is especially relevant for big files.
|
|||||||
lf automatically closes the previewer script output pipe with a SIGPIPE when enough lines are read.
|
lf automatically closes the previewer script output pipe with a SIGPIPE when enough lines are read.
|
||||||
When everything else fails, you can make use of the height argument to only feed the first portion of the file to a program for preview.
|
When everything else fails, you can make use of the height argument to only feed the first portion of the file to a program for preview.
|
||||||
Note that some programs may not respond well to SIGPIPE to exit with a non-zero return code and avoid caching.
|
Note that some programs may not respond well to SIGPIPE to exit with a non-zero return code and avoid caching.
|
||||||
You may trap SIGPIPE in your preview script to avoid error propogation:
|
You may add a trailing '|| true' command to avoid such errors:
|
||||||
|
|
||||||
#!/bin/sh
|
highlight -O ansi "$1" || true
|
||||||
|
|
||||||
trap "" PIPE
|
|
||||||
|
|
||||||
...
|
|
||||||
|
|
||||||
You may also use an existing preview filter as you like.
|
You may also use an existing preview filter as you like.
|
||||||
Your system may already come with a preview filter named 'lesspipe'.
|
Your system may already come with a preview filter named 'lesspipe'.
|
||||||
@@ -1217,6 +1256,9 @@ You can add an extra call to make it run on startup as well:
|
|||||||
|
|
||||||
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.
|
||||||
|
It is generally a bad idea, to put movement commands (like 'up' / 'top' etc.) here.
|
||||||
|
|
||||||
Colors
|
Colors
|
||||||
|
|
||||||
lf tries to automatically adapt its colors to the environment.
|
lf tries to automatically adapt its colors to the environment.
|
||||||
|
|||||||
+93
-45
@@ -66,6 +66,8 @@ 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 '"')
|
||||||
@@ -102,8 +104,11 @@ The following command line commands are provided by lf:
|
|||||||
The following options can be used to customize the behavior of lf:
|
The following options can be used to customize the behavior of lf:
|
||||||
|
|
||||||
anchorfind bool (default on)
|
anchorfind bool (default on)
|
||||||
|
autoquit bool (default off)
|
||||||
|
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")
|
||||||
@@ -115,8 +120,10 @@ 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 '')
|
||||||
|
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)
|
||||||
@@ -128,6 +135,7 @@ The following options can be used to customize the behavior of lf:
|
|||||||
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)
|
||||||
shellopts []string (default '')
|
shellopts []string (default '')
|
||||||
smartcase bool (default on)
|
smartcase bool (default on)
|
||||||
smartdia bool (default off)
|
smartdia bool (default off)
|
||||||
@@ -135,6 +143,7 @@ The following options can be used to customize the behavior of lf:
|
|||||||
tabstop int (default 8)
|
tabstop int (default 8)
|
||||||
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')
|
||||||
wrapscan bool (default on)
|
wrapscan bool (default on)
|
||||||
wrapscroll bool (default off)
|
wrapscroll bool (default off)
|
||||||
|
|
||||||
@@ -144,6 +153,8 @@ The following environment variables are exported for shell commands:
|
|||||||
fs
|
fs
|
||||||
fx
|
fx
|
||||||
id
|
id
|
||||||
|
PWD
|
||||||
|
OLDPWD
|
||||||
LF_LEVEL
|
LF_LEVEL
|
||||||
OPENER
|
OPENER
|
||||||
EDITOR
|
EDITOR
|
||||||
@@ -184,6 +195,11 @@ Configuration files should be located at:
|
|||||||
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
|
||||||
|
|
||||||
|
Selection file should be located at:
|
||||||
|
|
||||||
|
unix ~/.local/share/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
|
||||||
@@ -373,7 +389,7 @@ Read a shell command to execute and wait for a key press in the end.
|
|||||||
|
|
||||||
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')
|
||||||
@@ -397,6 +413,17 @@ direction and jump to the next/previous match.
|
|||||||
(See also 'globsearch', 'incsearch', 'wrapscan', 'ignorecase', 'smartcase',
|
(See also 'globsearch', 'incsearch', 'wrapscan', 'ignorecase', 'smartcase',
|
||||||
'ignoredia', and 'smartdia' options and 'Searching Files' section)
|
'ignoredia', and 'smartdia' options and 'Searching Files' section)
|
||||||
|
|
||||||
|
filter (modal)
|
||||||
|
setfilter
|
||||||
|
|
||||||
|
Read a pattern to filter out and only view files matching the pattern.
|
||||||
|
setfilter does the same but uses an argument to set the filter immediatly.
|
||||||
|
You can supply an argument to filter, in order to use that as the starting
|
||||||
|
prompt.
|
||||||
|
|
||||||
|
(See also 'globsearch', 'incfilter', 'ignorecase', 'smartcase', 'ignoredia',
|
||||||
|
and 'smartdia' options)
|
||||||
|
|
||||||
mark-save (modal) (default 'm')
|
mark-save (modal) (default 'm')
|
||||||
|
|
||||||
Save the current directory as a bookmark assigned to the given key.
|
Save the current directory as a bookmark assigned to the given key.
|
||||||
@@ -510,6 +537,14 @@ Character ':' is used as the separator for list options '[]int' and
|
|||||||
When this option is enabled, find command starts matching patterns from the
|
When this option is enabled, find command starts matching patterns from the
|
||||||
beginning of file names, otherwise, it can match at an arbitrary position.
|
beginning of file names, otherwise, it can match at an arbitrary position.
|
||||||
|
|
||||||
|
autoquit bool (default off)
|
||||||
|
|
||||||
|
Automatically quit server when there are no clients left connected.
|
||||||
|
|
||||||
|
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
|
||||||
@@ -526,6 +561,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.
|
||||||
@@ -593,6 +632,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.
|
||||||
@@ -600,6 +643,10 @@ 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.
|
||||||
|
|
||||||
|
mouse bool (default off)
|
||||||
|
|
||||||
|
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
|
||||||
@@ -646,11 +693,11 @@ Preview clearing is disabled when the value of this option is left empty.
|
|||||||
|
|
||||||
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')
|
||||||
|
|
||||||
@@ -678,10 +725,12 @@ 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. On unix, a POSIX compatible
|
Shell executable to use for shell commands. Shell commands are executed as
|
||||||
shell is required. Shell commands are executed as 'shell shellopts -c
|
'shell shellopts shellflag command -- arguments'.
|
||||||
command -- arguments'. On windows, '/c' is used instead of '-c' which should
|
|
||||||
work in 'cmd' and 'powershell'.
|
shellflag string (default '-c' for unix and '/c' for windows)
|
||||||
|
|
||||||
|
Command line flag used to pass shell commands.
|
||||||
|
|
||||||
shellopts []string (default '')
|
shellopts []string (default '')
|
||||||
|
|
||||||
@@ -716,6 +765,10 @@ Format string of the file modification time shown in the bottom line.
|
|||||||
Truncate character shown at the end when the file name does not fit to the
|
Truncate character shown at the end when the file name does not fit to the
|
||||||
pane.
|
pane.
|
||||||
|
|
||||||
|
waitmsg string (default 'Press any key to continue')
|
||||||
|
|
||||||
|
String shown after commands of shell-wait type.
|
||||||
|
|
||||||
wrapscan bool (default on)
|
wrapscan bool (default on)
|
||||||
|
|
||||||
Searching can wrap around the file list.
|
Searching can wrap around the file list.
|
||||||
@@ -750,6 +803,14 @@ current file selection (i.e. 'f').
|
|||||||
|
|
||||||
Id of the running client.
|
Id of the running client.
|
||||||
|
|
||||||
|
PWD
|
||||||
|
|
||||||
|
Present working directory.
|
||||||
|
|
||||||
|
OLDPWD
|
||||||
|
|
||||||
|
Initial working directory.
|
||||||
|
|
||||||
LF_LEVEL
|
LF_LEVEL
|
||||||
|
|
||||||
The value of this variable is set to the current nesting level when you run
|
The value of this variable is set to the current nesting level when you run
|
||||||
@@ -823,7 +884,7 @@ command, custom command, or shell command:
|
|||||||
map gh cd ~ # builtin command
|
map gh cd ~ # builtin command
|
||||||
map D trash # custom command
|
map D trash # custom command
|
||||||
map i $less $f # shell command
|
map i $less $f # shell command
|
||||||
map U !du -sh # waiting shell command
|
map U !du -csh * # waiting shell command
|
||||||
|
|
||||||
Command 'cmap' is used to bind a key to a command line command which can
|
Command 'cmap' is used to bind a key to a command line command which can
|
||||||
only be one of the builtin commands:
|
only be one of the builtin commands:
|
||||||
@@ -1072,11 +1133,12 @@ In this command 'send' is used to send the rest of the string as a command
|
|||||||
to all connected clients. You can optionally give it an id number to send a
|
to all connected clients. You can optionally give it an id number to send a
|
||||||
command to a single client:
|
command to a single client:
|
||||||
|
|
||||||
lf -remote 'send 1000 echo hello world'
|
lf -remote 'send 1234 echo hello world'
|
||||||
|
|
||||||
All clients have a unique id number but you may not be aware of the id
|
All clients have a unique id number but you may not be aware of the id
|
||||||
number when you are writing a command. For this purpose, an '$id' variable
|
number when you are writing a command. For this purpose, an '$id' variable
|
||||||
is exported to the environment for shell commands. You can use it to send a
|
is exported to the environment for shell commands. The value of this
|
||||||
|
variable is set to the process id of the client. You can use it to send a
|
||||||
remote command from a client to the server which in return sends a command
|
remote command from a client to the server which in return sends a command
|
||||||
back to itself. So now you can display a message in the current client by
|
back to itself. So now you can display a message in the current client by
|
||||||
calling the following in a shell command:
|
calling the following in a shell command:
|
||||||
@@ -1098,27 +1160,12 @@ with respect to the terminal width as follows:
|
|||||||
fi
|
fi
|
||||||
}}
|
}}
|
||||||
|
|
||||||
Besides 'send' command, there are also two commands to get or set the
|
Besides 'send' command, there is a 'quit' command to quit the server when
|
||||||
current file selection. Two possible modes 'copy' and 'move' specify whether
|
there are no connected clients left, and a 'quit!' command to force quit the
|
||||||
selected files are to be copied or moved. File names are separated by
|
server by closing client connections first:
|
||||||
newline character. Setting the file selection is done with 'save' command:
|
|
||||||
|
|
||||||
lf -remote "$(printf 'save\ncopy\nfoo.txt\nbar.txt\nbaz.txt\n')"
|
|
||||||
|
|
||||||
Getting the file selection is similarly done with 'load' command:
|
|
||||||
|
|
||||||
load=$(lf -remote 'load')
|
|
||||||
mode=$(echo "$load" | sed -n '1p')
|
|
||||||
list=$(echo "$load" | sed '1d')
|
|
||||||
if [ $mode = 'copy' ]; then
|
|
||||||
# do something with $list
|
|
||||||
elif [ $mode = 'move' ]; then
|
|
||||||
# do something else with $list
|
|
||||||
fi
|
|
||||||
|
|
||||||
There is a 'quit' command to close client connections and quit the server:
|
|
||||||
|
|
||||||
lf -remote 'quit'
|
lf -remote 'quit'
|
||||||
|
lf -remote 'quit!'
|
||||||
|
|
||||||
Lastly, there is a 'conn' command to connect the server as a client. This
|
Lastly, there is a 'conn' command to connect the server as a client. This
|
||||||
should not be needed for users.
|
should not be needed for users.
|
||||||
@@ -1132,8 +1179,8 @@ ruler. These commands do not overwrite existing files or directories with
|
|||||||
the same name. Instead, a suffix that is compatible with '--backup=numbered'
|
the same name. Instead, a suffix that is compatible with '--backup=numbered'
|
||||||
option in GNU cp is added to the new files or directories. Only file modes
|
option in GNU cp is added to the new files or directories. Only file modes
|
||||||
are preserved and all other attributes are ignored including ownership,
|
are preserved and all other attributes are ignored including ownership,
|
||||||
timestamps, context, links, and xattr. Special files such as character and
|
timestamps, context, and xattr. Special files such as character and block
|
||||||
block devices, named pipes, and sockets are skipped and links are followed.
|
devices, named pipes, and sockets are skipped and links are not followed.
|
||||||
Moving is performed using the rename operation of the underlying OS. For
|
Moving is performed using the rename operation of the underlying OS. For
|
||||||
cross-device moving, lf falls back to copying and then deletes the original
|
cross-device moving, lf falls back to copying and then deletes the original
|
||||||
files if there are no errors. Operation errors are shown in the message line
|
files if there are no errors. Operation errors are shown in the message line
|
||||||
@@ -1143,7 +1190,7 @@ corresponding file operation.
|
|||||||
File operations can be performed on the current selected file or
|
File operations can be performed on the current selected file or
|
||||||
alternatively on multiple files by selecting them first. When you 'copy' a
|
alternatively on multiple files by selecting them first. When you 'copy' a
|
||||||
file, lf doesn't actually copy the file on the disk, but only records its
|
file, lf doesn't actually copy the file on the disk, but only records its
|
||||||
name to memory. The actual file copying takes place when you 'paste'.
|
name to a file. The actual file copying takes place when you 'paste'.
|
||||||
Similarly 'paste' after a 'cut' operation moves the file.
|
Similarly 'paste' after a 'cut' operation moves the file.
|
||||||
|
|
||||||
You can customize copy and move operations by defining a 'paste' command.
|
You can customize copy and move operations by defining a 'paste' command.
|
||||||
@@ -1152,7 +1199,7 @@ builtin implementation. You can use the following example as a starting
|
|||||||
point:
|
point:
|
||||||
|
|
||||||
cmd paste %{{
|
cmd paste %{{
|
||||||
load=$(lf -remote 'load')
|
load=$(cat ~/.local/share/lf/files)
|
||||||
mode=$(echo "$load" | sed -n '1p')
|
mode=$(echo "$load" | sed -n '1p')
|
||||||
list=$(echo "$load" | sed '1d')
|
list=$(echo "$load" | sed '1d')
|
||||||
if [ $mode = 'copy' ]; then
|
if [ $mode = 'copy' ]; then
|
||||||
@@ -1160,7 +1207,7 @@ point:
|
|||||||
elif [ $mode = 'move' ]; then
|
elif [ $mode = 'move' ]; then
|
||||||
mv $list .
|
mv $list .
|
||||||
fi
|
fi
|
||||||
lf -remote 'send load'
|
rm ~/.local/share/lf/files
|
||||||
lf -remote 'send clear'
|
lf -remote 'send clear'
|
||||||
}}
|
}}
|
||||||
|
|
||||||
@@ -1236,6 +1283,7 @@ You may want to use either file extensions or mime types from 'file'
|
|||||||
command:
|
command:
|
||||||
|
|
||||||
cmd open ${{
|
cmd open ${{
|
||||||
|
test -L $f && f=$(readlink -f $f)
|
||||||
case $(file --mime-type $f -b) in
|
case $(file --mime-type $f -b) in
|
||||||
text/*) vi $fx;;
|
text/*) vi $fx;;
|
||||||
*) for f in $fx; do xdg-open $f > /dev/null 2> /dev/null & done;;
|
*) for f in $fx; do xdg-open $f > /dev/null 2> /dev/null & done;;
|
||||||
@@ -1293,7 +1341,7 @@ match cleanly within a conditional:
|
|||||||
*.rar) unrar l "$1";;
|
*.rar) unrar l "$1";;
|
||||||
*.7z) 7z l "$1";;
|
*.7z) 7z l "$1";;
|
||||||
*.pdf) pdftotext "$1" -;;
|
*.pdf) pdftotext "$1" -;;
|
||||||
*) highlight -O ansi "$1" || cat "$1";;
|
*) highlight -O ansi "$1";;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
Another important consideration for efficiency is the use of programs with
|
Another important consideration for efficiency is the use of programs with
|
||||||
@@ -1306,14 +1354,10 @@ script output pipe with a SIGPIPE when enough lines are read. When
|
|||||||
everything else fails, you can make use of the height argument to only feed
|
everything else fails, you can make use of the height argument to only feed
|
||||||
the first portion of the file to a program for preview. Note that some
|
the first portion of the file to a program for preview. Note that some
|
||||||
programs may not respond well to SIGPIPE to exit with a non-zero return code
|
programs may not respond well to SIGPIPE to exit with a non-zero return code
|
||||||
and avoid caching. You may trap SIGPIPE in your preview script to avoid
|
and avoid caching. You may add a trailing '|| true' command to avoid such
|
||||||
error propogation:
|
errors:
|
||||||
|
|
||||||
#!/bin/sh
|
highlight -O ansi "$1" || true
|
||||||
|
|
||||||
trap "" PIPE
|
|
||||||
|
|
||||||
...
|
|
||||||
|
|
||||||
You may also use an existing preview filter as you like. Your system may
|
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
|
already come with a preview filter named 'lesspipe'. These filters may have
|
||||||
@@ -1363,6 +1407,10 @@ add an extra call to make it run on startup as well:
|
|||||||
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. It is generally a bad idea, to put
|
||||||
|
movement commands (like 'up' / 'top' etc.) here.
|
||||||
|
|
||||||
|
|
||||||
Colors
|
Colors
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
_lf () {
|
_lf () {
|
||||||
local -a opts=(
|
local -a opts=(
|
||||||
-command
|
-command
|
||||||
|
-config
|
||||||
-cpuprofile
|
-cpuprofile
|
||||||
-doc
|
-doc
|
||||||
-last-dir-path
|
-last-dir-path
|
||||||
@@ -16,6 +17,7 @@ _lf () {
|
|||||||
-remote
|
-remote
|
||||||
-selection-path
|
-selection-path
|
||||||
-server
|
-server
|
||||||
|
-single
|
||||||
-version
|
-version
|
||||||
-help
|
-help
|
||||||
)
|
)
|
||||||
|
|||||||
+1
-1
@@ -9,7 +9,7 @@
|
|||||||
# endif
|
# endif
|
||||||
#
|
#
|
||||||
|
|
||||||
set LF_ARGS = "-command -cpuprofile -doc -last-dir-path -memprofile -remote -selection-path -server -version -help "
|
set LF_ARGS = "-command -config -cpuprofile -doc -last-dir-path -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})/"
|
||||||
@@ -7,6 +7,7 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
complete -c lf -o command -r -d 'command to execute on client initialization'
|
complete -c lf -o command -r -d 'command to execute on client initialization'
|
||||||
|
complete -c lf -o config -r -d 'path to the config file (instead of the usual paths)'
|
||||||
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)'
|
||||||
@@ -14,5 +15,6 @@ 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)'
|
||||||
complete -c lf -o server -d 'start server (automatic)'
|
complete -c lf -o server -d 'start server (automatic)'
|
||||||
|
complete -c lf -o single -d 'start a client without server'
|
||||||
complete -c lf -o version -d 'show version'
|
complete -c lf -o version -d 'show version'
|
||||||
complete -c lf -o help -d 'show help'
|
complete -c lf -o help -d 'show help'
|
||||||
@@ -10,6 +10,7 @@ Register-ArgumentCompleter -Native -CommandName 'lf' -ScriptBlock {
|
|||||||
param($wordToComplete)
|
param($wordToComplete)
|
||||||
$completions = @(
|
$completions = @(
|
||||||
[CompletionResult]::new('-command ', '-command', [CompletionResultType]::ParameterName, 'command to execute on client initialization')
|
[CompletionResult]::new('-command ', '-command', [CompletionResultType]::ParameterName, 'command to execute on client initialization')
|
||||||
|
[CompletionResult]::new('-config ', '-config', [CompletionResultType]::ParameterName, 'path to the config file (instead of the usual paths)')
|
||||||
[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)')
|
||||||
@@ -17,7 +18,9 @@ Register-ArgumentCompleter -Native -CommandName 'lf' -ScriptBlock {
|
|||||||
[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)')
|
||||||
[CompletionResult]::new('-server', '-server', [CompletionResultType]::ParameterName, 'start server (automatic)')
|
[CompletionResult]::new('-server', '-server', [CompletionResultType]::ParameterName, 'start server (automatic)')
|
||||||
|
[CompletionResult]::new('-single', '-single', [CompletionResultType]::ParameterName, 'start a client without server')
|
||||||
[CompletionResult]::new('-version', '-version', [CompletionResultType]::ParameterName, 'show version')
|
[CompletionResult]::new('-version', '-version', [CompletionResultType]::ParameterName, 'show version')
|
||||||
|
[CompletionResult]::new('-help', '-help', [CompletionResultType]::ParameterName, 'show help')
|
||||||
)
|
)
|
||||||
|
|
||||||
if ($wordToComplete.StartsWith('-')) {
|
if ($wordToComplete.StartsWith('-')) {
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ local arguments
|
|||||||
|
|
||||||
arguments=(
|
arguments=(
|
||||||
'-command[command to execute on client initialization]'
|
'-command[command to execute on client initialization]'
|
||||||
|
'-config[path to the config file (instead of the usual paths)]'
|
||||||
'-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)]'
|
||||||
@@ -21,7 +22,9 @@ arguments=(
|
|||||||
'-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)]'
|
||||||
'-server[start server (automatic)]'
|
'-server[start server (automatic)]'
|
||||||
|
'-single[start a client without server]'
|
||||||
'-version[show version]'
|
'-version[show version]'
|
||||||
|
'-help[show help]'
|
||||||
'*:filename:_files'
|
'*:filename:_files'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
+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"
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -1,4 +1,4 @@
|
|||||||
# interpreter for shell commands (needs to be POSIX compatible)
|
# interpreter for shell commands
|
||||||
set shell sh
|
set shell sh
|
||||||
|
|
||||||
# set '-eu' options for shell commands
|
# set '-eu' options for shell commands
|
||||||
@@ -36,6 +36,7 @@ map O $mimeopen --ask $f
|
|||||||
# use either file extensions and/or mime types here. Below uses an editor for
|
# use either file extensions and/or mime types here. Below uses an editor for
|
||||||
# text files and a file opener for the rest.
|
# text files and a file opener for the rest.
|
||||||
cmd open ${{
|
cmd open ${{
|
||||||
|
test -L $f && f=$(readlink -f $f)
|
||||||
case $(file --mime-type $f -b) in
|
case $(file --mime-type $f -b) in
|
||||||
text/*) $EDITOR $fx;;
|
text/*) $EDITOR $fx;;
|
||||||
*) for f in $fx; do setsid $OPENER $f > /dev/null 2> /dev/null & done;;
|
*) for f in $fx; do setsid $OPENER $f > /dev/null 2> /dev/null & done;;
|
||||||
|
|||||||
+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}}},
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ cat << END >> $out
|
|||||||
lf \- terminal file manager
|
lf \- terminal file manager
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
.SY lf
|
.SY lf
|
||||||
|
.OP \-command command
|
||||||
|
.OP \-config path
|
||||||
.OP \-cpuprofile path
|
.OP \-cpuprofile path
|
||||||
.OP \-doc
|
.OP \-doc
|
||||||
.OP \-last-dir-path path
|
.OP \-last-dir-path path
|
||||||
@@ -30,7 +32,9 @@ lf \- terminal file manager
|
|||||||
.OP \-remote command
|
.OP \-remote command
|
||||||
.OP \-selection-path path
|
.OP \-selection-path path
|
||||||
.OP \-server
|
.OP \-server
|
||||||
|
.OP \-single
|
||||||
.OP \-version
|
.OP \-version
|
||||||
|
.OP \-help
|
||||||
.RI [ directory ]
|
.RI [ directory ]
|
||||||
.YS
|
.YS
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
|
|||||||
@@ -3,7 +3,8 @@ module github.com/gokcehan/lf
|
|||||||
go 1.12
|
go 1.12
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/gdamore/tcell/v2 v2.0.0
|
github.com/gdamore/tcell/v2 v2.3.1
|
||||||
github.com/mattn/go-runewidth v0.0.9
|
github.com/mattn/go-runewidth v0.0.10
|
||||||
|
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
|
||||||
)
|
)
|
||||||
@@ -1,14 +1,18 @@
|
|||||||
github.com/gdamore/encoding v1.0.0 h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdko=
|
github.com/gdamore/encoding v1.0.0 h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdko=
|
||||||
github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg=
|
github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg=
|
||||||
github.com/gdamore/tcell/v2 v2.0.0 h1:GRWG8aLfWAlekj9Q6W29bVvkHENc6hp79XOqG4AWDOs=
|
github.com/gdamore/tcell/v2 v2.3.1 h1:htEXmKMzurgcnNH3VqQA7GYlCpdl9LCSNpzFpZOKhJE=
|
||||||
github.com/gdamore/tcell/v2 v2.0.0/go.mod h1:vSVL/GV5mCSlPC6thFP5kfOFdM9MGZcalipmpTxTgQA=
|
github.com/gdamore/tcell/v2 v2.3.1/go.mod h1:cTTuF84Dlj/RqmaCIV5p4w8uG1zWdk0SF6oBpwHp4fU=
|
||||||
github.com/lucasb-eyer/go-colorful v1.0.3 h1:QIbQXiugsb+q10B+MI+7DI1oQLdmnep86tWFlaaUAac=
|
github.com/lucasb-eyer/go-colorful v1.0.3 h1:QIbQXiugsb+q10B+MI+7DI1oQLdmnep86tWFlaaUAac=
|
||||||
github.com/lucasb-eyer/go-colorful v1.0.3/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
|
github.com/lucasb-eyer/go-colorful v1.0.3/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
|
||||||
github.com/mattn/go-runewidth v0.0.7/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
|
github.com/mattn/go-runewidth v0.0.10 h1:CoZ3S2P7pvtP45xOtBw+/mDL2z0RKI576gSkzRRpdGg=
|
||||||
github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=
|
github.com/mattn/go-runewidth v0.0.10/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=
|
||||||
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
|
github.com/rivo/uniseg v0.1.0 h1:+2KBaVoUmb9XzDsrx/Ct0W/EYOSFf/nWTauy++DprtY=
|
||||||
golang.org/x/sys v0.0.0-20190626150813-e07cf5db2756 h1:9nuHUbU8dRnRRfj9KjWUVrJeoexdbeMjttk6Oh1rD10=
|
github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
||||||
golang.org/x/sys v0.0.0-20190626150813-e07cf5db2756/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
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/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/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||||
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
|
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
|
||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
gopkg.in/djherbis/times.v1 v1.2.0 h1:UCvDKl1L/fmBygl2Y7hubXCnY7t4Yj46ZrBFNUipFbM=
|
gopkg.in/djherbis/times.v1 v1.2.0 h1:UCvDKl1L/fmBygl2Y7hubXCnY7t4Yj46ZrBFNUipFbM=
|
||||||
|
|||||||
@@ -4,6 +4,8 @@
|
|||||||
lf \- terminal file manager
|
lf \- terminal file manager
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
.SY lf
|
.SY lf
|
||||||
|
.OP \-command command
|
||||||
|
.OP \-config path
|
||||||
.OP \-cpuprofile path
|
.OP \-cpuprofile path
|
||||||
.OP \-doc
|
.OP \-doc
|
||||||
.OP \-last-dir-path path
|
.OP \-last-dir-path path
|
||||||
@@ -11,7 +13,9 @@ lf \- terminal file manager
|
|||||||
.OP \-remote command
|
.OP \-remote command
|
||||||
.OP \-selection-path path
|
.OP \-selection-path path
|
||||||
.OP \-server
|
.OP \-server
|
||||||
|
.OP \-single
|
||||||
.OP \-version
|
.OP \-version
|
||||||
|
.OP \-help
|
||||||
.RI [ directory ]
|
.RI [ directory ]
|
||||||
.YS
|
.YS
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
@@ -73,6 +77,8 @@ 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 `"`)
|
||||||
@@ -113,8 +119,11 @@ The following options can be used to customize the behavior of lf:
|
|||||||
.PP
|
.PP
|
||||||
.EX
|
.EX
|
||||||
anchorfind bool (default on)
|
anchorfind bool (default on)
|
||||||
|
autoquit bool (default off)
|
||||||
|
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")
|
||||||
@@ -126,8 +135,10 @@ 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 '')
|
||||||
|
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)
|
||||||
@@ -139,6 +150,7 @@ The following options can be used to customize the behavior of lf:
|
|||||||
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)
|
||||||
shellopts []string (default '')
|
shellopts []string (default '')
|
||||||
smartcase bool (default on)
|
smartcase bool (default on)
|
||||||
smartdia bool (default off)
|
smartdia bool (default off)
|
||||||
@@ -146,6 +158,7 @@ The following options can be used to customize the behavior of lf:
|
|||||||
tabstop int (default 8)
|
tabstop int (default 8)
|
||||||
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')
|
||||||
wrapscan bool (default on)
|
wrapscan bool (default on)
|
||||||
wrapscroll bool (default off)
|
wrapscroll bool (default off)
|
||||||
.EE
|
.EE
|
||||||
@@ -157,6 +170,8 @@ The following environment variables are exported for shell commands:
|
|||||||
fs
|
fs
|
||||||
fx
|
fx
|
||||||
id
|
id
|
||||||
|
PWD
|
||||||
|
OLDPWD
|
||||||
LF_LEVEL
|
LF_LEVEL
|
||||||
OPENER
|
OPENER
|
||||||
EDITOR
|
EDITOR
|
||||||
@@ -201,6 +216,13 @@ Configuration files should be located at:
|
|||||||
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
|
.EE
|
||||||
.PP
|
.PP
|
||||||
|
Selection file should be located at:
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
unix ~/.local/share/lf/files
|
||||||
|
windows C:\eUsers\e<user>\eAppData\eLocal\elf\efiles
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
Marks file should be located at:
|
Marks file should be located at:
|
||||||
.PP
|
.PP
|
||||||
.EX
|
.EX
|
||||||
@@ -438,7 +460,7 @@ Read a shell command to execute and wait for a key press in the end.
|
|||||||
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')
|
||||||
@@ -462,6 +484,15 @@ Read a pattern to search for a file name match in the forward/backward direction
|
|||||||
.PP
|
.PP
|
||||||
(See also 'globsearch', 'incsearch', 'wrapscan', 'ignorecase', 'smartcase', 'ignoredia', and 'smartdia' options and 'Searching Files' section)
|
(See also 'globsearch', 'incsearch', 'wrapscan', 'ignorecase', 'smartcase', 'ignoredia', and 'smartdia' options and 'Searching Files' section)
|
||||||
.PP
|
.PP
|
||||||
|
.EX
|
||||||
|
filter (modal)
|
||||||
|
setfilter
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Read a pattern to filter out and only view files matching the pattern. setfilter does the same but uses an argument to set the filter immediatly. You can supply an argument to filter, in order to use that as the starting prompt.
|
||||||
|
.PP
|
||||||
|
(See also 'globsearch', 'incfilter', 'ignorecase', 'smartcase', 'ignoredia', and 'smartdia' options)
|
||||||
|
.PP
|
||||||
.EX
|
.EX
|
||||||
mark-save (modal) (default 'm')
|
mark-save (modal) (default 'm')
|
||||||
.EE
|
.EE
|
||||||
@@ -601,6 +632,18 @@ This section shows information about options to customize the behavior. Characte
|
|||||||
.PP
|
.PP
|
||||||
When this option is enabled, find command starts matching patterns from the beginning of file names, otherwise, it can match at an arbitrary position.
|
When this option is enabled, find command starts matching patterns from the beginning of file names, otherwise, it can match at an arbitrary position.
|
||||||
.PP
|
.PP
|
||||||
|
.EX
|
||||||
|
autoquit bool (default off)
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Automatically quit server when there are no clients left connected.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
dircache bool (default on)
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Cache directory contents.
|
||||||
|
.PP
|
||||||
.EX
|
.EX
|
||||||
dircounts bool (default off)
|
dircounts bool (default off)
|
||||||
.EE
|
.EE
|
||||||
@@ -613,6 +656,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
|
||||||
@@ -685,12 +734,24 @@ 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
|
||||||
|
mouse bool (default off)
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Send mouse events as input.
|
||||||
|
.PP
|
||||||
.EX
|
.EX
|
||||||
number bool (default off)
|
number bool (default off)
|
||||||
.EE
|
.EE
|
||||||
@@ -725,7 +786,7 @@ Set the path of a cleaner file. This file will be called if previewing is enable
|
|||||||
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')
|
||||||
@@ -755,7 +816,13 @@ Minimum number of offset lines shown at all times in the top and the bottom of t
|
|||||||
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. On unix, a POSIX compatible shell is required. Shell commands are executed as 'shell shellopts -c command -- arguments'. On windows, '/c' is used instead of '-c' which should work in 'cmd' and 'powershell'.
|
Shell executable to use for shell commands. Shell commands are executed as 'shell shellopts shellflag command -- arguments'.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
shellflag string (default '-c' for unix and '/c' for windows)
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Command line flag used to pass shell commands.
|
||||||
.PP
|
.PP
|
||||||
.EX
|
.EX
|
||||||
shellopts []string (default '')
|
shellopts []string (default '')
|
||||||
@@ -799,6 +866,12 @@ Format string of the file modification time shown in the bottom line.
|
|||||||
.PP
|
.PP
|
||||||
Truncate character shown at the end when the file name does not fit to the pane.
|
Truncate character shown at the end when the file name does not fit to the pane.
|
||||||
.PP
|
.PP
|
||||||
|
.EX
|
||||||
|
waitmsg string (default 'Press any key to continue')
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
String shown after commands of shell-wait type.
|
||||||
|
.PP
|
||||||
.EX
|
.EX
|
||||||
wrapscan bool (default on)
|
wrapscan bool (default on)
|
||||||
.EE
|
.EE
|
||||||
@@ -837,6 +910,18 @@ Selected file(s) (i.e. 'fs') if there are any selected files, otherwise current
|
|||||||
.PP
|
.PP
|
||||||
Id of the running client.
|
Id of the running client.
|
||||||
.PP
|
.PP
|
||||||
|
.EX
|
||||||
|
PWD
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Present working directory.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
OLDPWD
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Initial working directory.
|
||||||
|
.PP
|
||||||
.EX
|
.EX
|
||||||
LF_LEVEL
|
LF_LEVEL
|
||||||
.EE
|
.EE
|
||||||
@@ -905,7 +990,7 @@ Command 'map' is used to bind a key to a command which can be builtin command, c
|
|||||||
map gh cd ~ # builtin command
|
map gh cd ~ # builtin command
|
||||||
map D trash # custom command
|
map D trash # custom command
|
||||||
map i $less $f # shell command
|
map i $less $f # shell command
|
||||||
map U !du -sh # waiting shell command
|
map U !du -csh * # waiting shell command
|
||||||
.EE
|
.EE
|
||||||
.PP
|
.PP
|
||||||
Command 'cmap' is used to bind a key to a command line command which can only be one of the builtin commands:
|
Command 'cmap' is used to bind a key to a command line command which can only be one of the builtin commands:
|
||||||
@@ -1132,10 +1217,10 @@ Since such a client may not be available everywhere, lf comes bundled with a com
|
|||||||
In this command 'send' is used to send the rest of the string as a command to all connected clients. You can optionally give it an id number to send a command to a single client:
|
In this command 'send' is used to send the rest of the string as a command to all connected clients. You can optionally give it an id number to send a command to a single client:
|
||||||
.PP
|
.PP
|
||||||
.EX
|
.EX
|
||||||
lf -remote 'send 1000 echo hello world'
|
lf -remote 'send 1234 echo hello world'
|
||||||
.EE
|
.EE
|
||||||
.PP
|
.PP
|
||||||
All clients have a unique id number but you may not be aware of the id number when you are writing a command. For this purpose, an '$id' variable is exported to the environment for shell commands. You can use it to send a remote command from a client to the server which in return sends a command back to itself. So now you can display a message in the current client by calling the following in a shell command:
|
All clients have a unique id number but you may not be aware of the id number when you are writing a command. For this purpose, an '$id' variable is exported to the environment for shell commands. The value of this variable is set to the process id of the client. You can use it to send a remote command from a client to the server which in return sends a command back to itself. So now you can display a message in the current client by calling the following in a shell command:
|
||||||
.PP
|
.PP
|
||||||
.EX
|
.EX
|
||||||
lf -remote "send $id echo hello world"
|
lf -remote "send $id echo hello world"
|
||||||
@@ -1156,42 +1241,24 @@ Since lf does not have control flow syntax, remote commands are used for such ne
|
|||||||
}}
|
}}
|
||||||
.EE
|
.EE
|
||||||
.PP
|
.PP
|
||||||
Besides 'send' command, there are also two commands to get or set the current file selection. Two possible modes 'copy' and 'move' specify whether selected files are to be copied or moved. File names are separated by newline character. Setting the file selection is done with 'save' command:
|
Besides 'send' command, there is a 'quit' command to quit the server when there are no connected clients left, and a 'quit!' command to force quit the server by closing client connections first:
|
||||||
.PP
|
|
||||||
.EX
|
|
||||||
lf -remote "$(printf 'save\encopy\enfoo.txt\enbar.txt\enbaz.txt\en')"
|
|
||||||
.EE
|
|
||||||
.PP
|
|
||||||
Getting the file selection is similarly done with 'load' command:
|
|
||||||
.PP
|
|
||||||
.EX
|
|
||||||
load=$(lf -remote 'load')
|
|
||||||
mode=$(echo "$load" | sed -n '1p')
|
|
||||||
list=$(echo "$load" | sed '1d')
|
|
||||||
if [ $mode = 'copy' ]; then
|
|
||||||
# do something with $list
|
|
||||||
elif [ $mode = 'move' ]; then
|
|
||||||
# do something else with $list
|
|
||||||
fi
|
|
||||||
.EE
|
|
||||||
.PP
|
|
||||||
There is a 'quit' command to close client connections and quit the server:
|
|
||||||
.PP
|
.PP
|
||||||
.EX
|
.EX
|
||||||
lf -remote 'quit'
|
lf -remote 'quit'
|
||||||
|
lf -remote 'quit!'
|
||||||
.EE
|
.EE
|
||||||
.PP
|
.PP
|
||||||
Lastly, there is a 'conn' command to connect the server as a client. This should not be needed for users.
|
Lastly, there is a 'conn' command to connect the server as a client. This should not be needed for users.
|
||||||
.SH FILE OPERATIONS
|
.SH FILE OPERATIONS
|
||||||
lf uses its own builtin copy and move operations by default. These are implemented as asynchronous operations and progress is shown in the bottom ruler. These commands do not overwrite existing files or directories with the same name. Instead, a suffix that is compatible with '--backup=numbered' option in GNU cp is added to the new files or directories. Only file modes are preserved and all other attributes are ignored including ownership, timestamps, context, links, and xattr. Special files such as character and block devices, named pipes, and sockets are skipped and links are followed. Moving is performed using the rename operation of the underlying OS. For cross-device moving, lf falls back to copying and then deletes the original files if there are no errors. Operation errors are shown in the message line as well as the log file and they do not preemptively finish the corresponding file operation.
|
lf uses its own builtin copy and move operations by default. These are implemented as asynchronous operations and progress is shown in the bottom ruler. These commands do not overwrite existing files or directories with the same name. Instead, a suffix that is compatible with '--backup=numbered' option in GNU cp is added to the new files or directories. Only file modes are preserved and all other attributes are ignored including ownership, timestamps, context, and xattr. Special files such as character and block devices, named pipes, and sockets are skipped and links are not followed. Moving is performed using the rename operation of the underlying OS. For cross-device moving, lf falls back to copying and then deletes the original files if there are no errors. Operation errors are shown in the message line as well as the log file and they do not preemptively finish the corresponding file operation.
|
||||||
.PP
|
.PP
|
||||||
File operations can be performed on the current selected file or alternatively on multiple files by selecting them first. When you 'copy' a file, lf doesn't actually copy the file on the disk, but only records its name to memory. The actual file copying takes place when you 'paste'. Similarly 'paste' after a 'cut' operation moves the file.
|
File operations can be performed on the current selected file or alternatively on multiple files by selecting them first. When you 'copy' a file, lf doesn't actually copy the file on the disk, but only records its name to a file. The actual file copying takes place when you 'paste'. Similarly 'paste' after a 'cut' operation moves the file.
|
||||||
.PP
|
.PP
|
||||||
You can customize copy and move operations by defining a 'paste' command. This is a special command that is called when it is defined instead of the builtin implementation. You can use the following example as a starting point:
|
You can customize copy and move operations by defining a 'paste' command. This is a special command that is called when it is defined instead of the builtin implementation. You can use the following example as a starting point:
|
||||||
.PP
|
.PP
|
||||||
.EX
|
.EX
|
||||||
cmd paste %{{
|
cmd paste %{{
|
||||||
load=$(lf -remote 'load')
|
load=$(cat ~/.local/share/lf/files)
|
||||||
mode=$(echo "$load" | sed -n '1p')
|
mode=$(echo "$load" | sed -n '1p')
|
||||||
list=$(echo "$load" | sed '1d')
|
list=$(echo "$load" | sed '1d')
|
||||||
if [ $mode = 'copy' ]; then
|
if [ $mode = 'copy' ]; then
|
||||||
@@ -1199,7 +1266,7 @@ You can customize copy and move operations by defining a 'paste' command. This i
|
|||||||
elif [ $mode = 'move' ]; then
|
elif [ $mode = 'move' ]; then
|
||||||
mv $list .
|
mv $list .
|
||||||
fi
|
fi
|
||||||
lf -remote 'send load'
|
rm ~/.local/share/lf/files
|
||||||
lf -remote 'send clear'
|
lf -remote 'send clear'
|
||||||
}}
|
}}
|
||||||
.EE
|
.EE
|
||||||
@@ -1239,6 +1306,7 @@ You may want to use either file extensions or mime types from 'file' command:
|
|||||||
.PP
|
.PP
|
||||||
.EX
|
.EX
|
||||||
cmd open ${{
|
cmd open ${{
|
||||||
|
test -L $f && f=$(readlink -f $f)
|
||||||
case $(file --mime-type $f -b) in
|
case $(file --mime-type $f -b) in
|
||||||
text/*) vi $fx;;
|
text/*) vi $fx;;
|
||||||
*) for f in $fx; do xdg-open $f > /dev/null 2> /dev/null & done;;
|
*) for f in $fx; do xdg-open $f > /dev/null 2> /dev/null & done;;
|
||||||
@@ -1285,22 +1353,14 @@ Since this script is called for each file selection change it needs to be as eff
|
|||||||
*.rar) unrar l "$1";;
|
*.rar) unrar l "$1";;
|
||||||
*.7z) 7z l "$1";;
|
*.7z) 7z l "$1";;
|
||||||
*.pdf) pdftotext "$1" -;;
|
*.pdf) pdftotext "$1" -;;
|
||||||
*) highlight -O ansi "$1" || cat "$1";;
|
*) highlight -O ansi "$1";;
|
||||||
esac
|
esac
|
||||||
.EE
|
.EE
|
||||||
.PP
|
.PP
|
||||||
Another important consideration for efficiency is the use of programs with short startup times for preview. For this reason, 'highlight' is recommended over 'pygmentize' for syntax highlighting. Besides, it is also important that the application is processing the file on the fly rather than first reading it to the memory and then do the processing afterwards. This is especially relevant for big files. lf automatically closes the previewer script output pipe with a SIGPIPE when enough lines are read. When everything else fails, you can make use of the height argument to only feed the first portion of the file to a program for preview. Note that some programs may not respond well to SIGPIPE to exit with a non-zero return code and avoid caching. You may trap SIGPIPE in your preview script to avoid error propogation:
|
Another important consideration for efficiency is the use of programs with short startup times for preview. For this reason, 'highlight' is recommended over 'pygmentize' for syntax highlighting. Besides, it is also important that the application is processing the file on the fly rather than first reading it to the memory and then do the processing afterwards. This is especially relevant for big files. lf automatically closes the previewer script output pipe with a SIGPIPE when enough lines are read. When everything else fails, you can make use of the height argument to only feed the first portion of the file to a program for preview. Note that some programs may not respond well to SIGPIPE to exit with a non-zero return code and avoid caching. You may add a trailing '|| true' command to avoid such errors:
|
||||||
.PP
|
.PP
|
||||||
.EX
|
.EX
|
||||||
#!/bin/sh
|
highlight -O ansi "$1" || true
|
||||||
.EE
|
|
||||||
.PP
|
|
||||||
.EX
|
|
||||||
trap "" PIPE
|
|
||||||
.EE
|
|
||||||
.PP
|
|
||||||
.EX
|
|
||||||
...
|
|
||||||
.EE
|
.EE
|
||||||
.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.
|
||||||
@@ -1339,6 +1399,8 @@ This command runs whenever you change directory but not on startup. You can add
|
|||||||
.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. It is generally a bad idea, to put movement commands (like 'up' / 'top' etc.) here.
|
||||||
.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
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ var (
|
|||||||
type arrayFlag []string
|
type arrayFlag []string
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
gSingleMode bool
|
||||||
gClientID int
|
gClientID int
|
||||||
gHostname string
|
gHostname string
|
||||||
gLastDirPath string
|
gLastDirPath string
|
||||||
@@ -31,6 +32,7 @@ var (
|
|||||||
gLogPath string
|
gLogPath string
|
||||||
gServerLogPath string
|
gServerLogPath string
|
||||||
gSelect string
|
gSelect string
|
||||||
|
gConfigPath string
|
||||||
gCommands arrayFlag
|
gCommands arrayFlag
|
||||||
gVersion string
|
gVersion string
|
||||||
)
|
)
|
||||||
@@ -64,6 +66,12 @@ func exportEnvVars() {
|
|||||||
os.Setenv("PAGER", envPager)
|
os.Setenv("PAGER", envPager)
|
||||||
os.Setenv("SHELL", envShell)
|
os.Setenv("SHELL", envShell)
|
||||||
|
|
||||||
|
dir, err := os.Getwd()
|
||||||
|
if err != nil {
|
||||||
|
fmt.Fprintf(os.Stderr, "%s\n", err)
|
||||||
|
}
|
||||||
|
os.Setenv("OLDPWD", dir)
|
||||||
|
|
||||||
level, err := strconv.Atoi(envLevel)
|
level, err := strconv.Atoi(envLevel)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("reading lf level: %s", err)
|
log.Printf("reading lf level: %s", err)
|
||||||
@@ -187,16 +195,21 @@ func main() {
|
|||||||
false,
|
false,
|
||||||
"show version")
|
"show version")
|
||||||
|
|
||||||
remoteCmd := flag.String(
|
|
||||||
"remote",
|
|
||||||
"",
|
|
||||||
"send remote command to server")
|
|
||||||
|
|
||||||
serverMode := flag.Bool(
|
serverMode := flag.Bool(
|
||||||
"server",
|
"server",
|
||||||
false,
|
false,
|
||||||
"start server (automatic)")
|
"start server (automatic)")
|
||||||
|
|
||||||
|
singleMode := flag.Bool(
|
||||||
|
"single",
|
||||||
|
false,
|
||||||
|
"start a client without server")
|
||||||
|
|
||||||
|
remoteCmd := flag.String(
|
||||||
|
"remote",
|
||||||
|
"",
|
||||||
|
"send remote command to server")
|
||||||
|
|
||||||
cpuprofile := flag.String(
|
cpuprofile := flag.String(
|
||||||
"cpuprofile",
|
"cpuprofile",
|
||||||
"",
|
"",
|
||||||
@@ -217,6 +230,11 @@ func main() {
|
|||||||
"",
|
"",
|
||||||
"path to the file to write selected files on open (to use as open file dialog)")
|
"path to the file to write selected files on open (to use as open file dialog)")
|
||||||
|
|
||||||
|
flag.StringVar(&gConfigPath,
|
||||||
|
"config",
|
||||||
|
"",
|
||||||
|
"path to the config file (instead of the usual paths)")
|
||||||
|
|
||||||
flag.Var(&gCommands,
|
flag.Var(&gCommands,
|
||||||
"command",
|
"command",
|
||||||
"command to execute on client initialization")
|
"command to execute on client initialization")
|
||||||
@@ -251,7 +269,11 @@ func main() {
|
|||||||
gServerLogPath = filepath.Join(os.TempDir(), fmt.Sprintf("lf.%s.server.log", gUser.Username))
|
gServerLogPath = filepath.Join(os.TempDir(), fmt.Sprintf("lf.%s.server.log", gUser.Username))
|
||||||
serve()
|
serve()
|
||||||
default:
|
default:
|
||||||
|
gSingleMode = *singleMode
|
||||||
|
|
||||||
|
if !gSingleMode {
|
||||||
checkServer()
|
checkServer()
|
||||||
|
}
|
||||||
|
|
||||||
gClientID = os.Getpid()
|
gClientID = os.Getpid()
|
||||||
gLogPath = filepath.Join(os.TempDir(), fmt.Sprintf("lf.%s.%d.log", gUser.Username, gClientID))
|
gLogPath = filepath.Join(os.TempDir(), fmt.Sprintf("lf.%s.%d.log", gUser.Username, gClientID))
|
||||||
|
|||||||
@@ -113,7 +113,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 +152,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
|
||||||
@@ -219,6 +222,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,17 +255,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 ""
|
||||||
}
|
}
|
||||||
|
|
||||||
return dir.files[dir.ind].Name()
|
return dir.files[dir.ind].Name()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -303,12 +350,11 @@ type nav struct {
|
|||||||
searchBack bool
|
searchBack bool
|
||||||
searchInd int
|
searchInd int
|
||||||
searchPos int
|
searchPos int
|
||||||
|
prevFilter []string
|
||||||
volatilePreview bool
|
volatilePreview bool
|
||||||
}
|
}
|
||||||
|
|
||||||
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(),
|
||||||
@@ -318,7 +364,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()
|
||||||
@@ -328,9 +373,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
|
||||||
|
} else {
|
||||||
|
return nav.loadDirInternal(path)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (nav *nav) checkDir(dir *dir) {
|
func (nav *nav) checkDir(dir *dir) {
|
||||||
@@ -354,10 +411,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:
|
||||||
@@ -597,6 +656,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()
|
||||||
|
|
||||||
@@ -797,11 +877,16 @@ loop:
|
|||||||
|
|
||||||
nav.copyTotalChan <- -total
|
nav.copyTotalChan <- -total
|
||||||
|
|
||||||
|
if gSingleMode {
|
||||||
|
nav.renew()
|
||||||
|
ui.loadFile(nav, true)
|
||||||
|
} else {
|
||||||
if err := remote("send load"); err != nil {
|
if err := remote("send load"); err != nil {
|
||||||
errCount++
|
errCount++
|
||||||
echo.args[0] = fmt.Sprintf("[%d] %s", errCount, err)
|
echo.args[0] = fmt.Sprintf("[%d] %s", errCount, err)
|
||||||
ui.exprChan <- echo
|
ui.exprChan <- echo
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if errCount == 0 {
|
if errCount == 0 {
|
||||||
ui.exprChan <- &callExpr{"echo", []string{"\033[0;32mCopied successfully\033[0m"}, 1}
|
ui.exprChan <- &callExpr{"echo", []string{"\033[0;32mCopied successfully\033[0m"}, 1}
|
||||||
@@ -824,7 +909,7 @@ func (nav *nav) moveAsync(ui *ui, srcs []string, dstDir string) {
|
|||||||
for _, src := range srcs {
|
for _, src := range srcs {
|
||||||
nav.moveCountChan <- 1
|
nav.moveCountChan <- 1
|
||||||
|
|
||||||
srcStat, err := os.Stat(src)
|
srcStat, err := os.Lstat(src)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errCount++
|
errCount++
|
||||||
echo.args[0] = fmt.Sprintf("[%d] %s", errCount, err)
|
echo.args[0] = fmt.Sprintf("[%d] %s", errCount, err)
|
||||||
@@ -897,11 +982,16 @@ func (nav *nav) moveAsync(ui *ui, srcs []string, dstDir string) {
|
|||||||
|
|
||||||
nav.moveTotalChan <- -len(srcs)
|
nav.moveTotalChan <- -len(srcs)
|
||||||
|
|
||||||
|
if gSingleMode {
|
||||||
|
nav.renew()
|
||||||
|
ui.loadFile(nav, true)
|
||||||
|
} else {
|
||||||
if err := remote("send load"); err != nil {
|
if err := remote("send load"); err != nil {
|
||||||
errCount++
|
errCount++
|
||||||
echo.args[0] = fmt.Sprintf("[%d] %s", errCount, err)
|
echo.args[0] = fmt.Sprintf("[%d] %s", errCount, err)
|
||||||
ui.exprChan <- echo
|
ui.exprChan <- echo
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if errCount == 0 {
|
if errCount == 0 {
|
||||||
ui.exprChan <- &callExpr{"echo", []string{"\033[0;32mMoved successfully\033[0m"}, 1}
|
ui.exprChan <- &callExpr{"echo", []string{"\033[0;32mMoved successfully\033[0m"}, 1}
|
||||||
@@ -930,9 +1020,15 @@ func (nav *nav) paste(ui *ui) error {
|
|||||||
return fmt.Errorf("clearing copy/cut buffer: %s", err)
|
return fmt.Errorf("clearing copy/cut buffer: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if gSingleMode {
|
||||||
|
if err := nav.sync(); err != nil {
|
||||||
|
return fmt.Errorf("paste: %s", err)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
if err := remote("send sync"); err != nil {
|
if err := remote("send sync"); err != nil {
|
||||||
return fmt.Errorf("paste: %s", err)
|
return fmt.Errorf("paste: %s", err)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -961,11 +1057,16 @@ func (nav *nav) del(ui *ui) error {
|
|||||||
|
|
||||||
nav.deleteTotalChan <- -len(list)
|
nav.deleteTotalChan <- -len(list)
|
||||||
|
|
||||||
|
if gSingleMode {
|
||||||
|
nav.renew()
|
||||||
|
ui.loadFile(nav, true)
|
||||||
|
} else {
|
||||||
if err := remote("send load"); err != nil {
|
if err := remote("send load"); err != nil {
|
||||||
errCount++
|
errCount++
|
||||||
echo.args[0] = fmt.Sprintf("[%d] %s", errCount, err)
|
echo.args[0] = fmt.Sprintf("[%d] %s", errCount, err)
|
||||||
ui.exprChan <- echo
|
ui.exprChan <- echo
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@@ -1006,7 +1107,13 @@ func (nav *nav) sync() error {
|
|||||||
nav.saves[f] = cp
|
nav.saves[f] = cp
|
||||||
}
|
}
|
||||||
|
|
||||||
return nav.readMarks()
|
path, ok := nav.marks["'"]
|
||||||
|
err = nav.readMarks()
|
||||||
|
if ok {
|
||||||
|
nav.marks["'"] = path
|
||||||
|
}
|
||||||
|
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (nav *nav) cd(wd string) error {
|
func (nav *nav) cd(wd string) error {
|
||||||
@@ -1123,42 +1230,38 @@ func (nav *nav) findSingle() int {
|
|||||||
return count
|
return count
|
||||||
}
|
}
|
||||||
|
|
||||||
func (nav *nav) findNext() bool {
|
func (nav *nav) findNext() (bool, bool) {
|
||||||
dir := nav.currDir()
|
dir := nav.currDir()
|
||||||
for i := dir.ind + 1; i < len(dir.files); i++ {
|
for i := dir.ind + 1; i < len(dir.files); i++ {
|
||||||
if findMatch(dir.files[i].Name(), nav.find) {
|
if findMatch(dir.files[i].Name(), nav.find) {
|
||||||
nav.down(i - dir.ind)
|
return nav.down(i - dir.ind), true
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if gOpts.wrapscan {
|
if gOpts.wrapscan {
|
||||||
for i := 0; i < dir.ind; i++ {
|
for i := 0; i < dir.ind; i++ {
|
||||||
if findMatch(dir.files[i].Name(), nav.find) {
|
if findMatch(dir.files[i].Name(), nav.find) {
|
||||||
nav.up(dir.ind - i)
|
return nav.up(dir.ind - i), true
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false
|
return false, false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (nav *nav) findPrev() bool {
|
func (nav *nav) findPrev() (bool, bool) {
|
||||||
dir := nav.currDir()
|
dir := nav.currDir()
|
||||||
for i := dir.ind - 1; i >= 0; i-- {
|
for i := dir.ind - 1; i >= 0; i-- {
|
||||||
if findMatch(dir.files[i].Name(), nav.find) {
|
if findMatch(dir.files[i].Name(), nav.find) {
|
||||||
nav.up(dir.ind - i)
|
return nav.up(dir.ind - i), true
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if gOpts.wrapscan {
|
if gOpts.wrapscan {
|
||||||
for i := len(dir.files) - 1; i > dir.ind; i-- {
|
for i := len(dir.files) - 1; i > dir.ind; i-- {
|
||||||
if findMatch(dir.files[i].Name(), nav.find) {
|
if findMatch(dir.files[i].Name(), nav.find) {
|
||||||
nav.down(i - dir.ind)
|
return nav.down(i - dir.ind), true
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false
|
return false, false
|
||||||
}
|
}
|
||||||
|
|
||||||
func searchMatch(name, pattern string) (matched bool, err error) {
|
func searchMatch(name, pattern string) (matched bool, err error) {
|
||||||
@@ -1182,58 +1285,62 @@ func searchMatch(name, pattern string) (matched bool, err error) {
|
|||||||
return strings.Contains(name, pattern), nil
|
return strings.Contains(name, pattern), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (nav *nav) searchNext() error {
|
func (nav *nav) searchNext() (bool, error) {
|
||||||
dir := nav.currDir()
|
dir := nav.currDir()
|
||||||
for i := dir.ind + 1; i < len(dir.files); i++ {
|
for i := dir.ind + 1; i < len(dir.files); i++ {
|
||||||
matched, err := searchMatch(dir.files[i].Name(), nav.search)
|
if matched, err := searchMatch(dir.files[i].Name(), nav.search); err != nil {
|
||||||
if err != nil {
|
return false, err
|
||||||
return err
|
} else if matched {
|
||||||
}
|
return nav.down(i - dir.ind), nil
|
||||||
if matched {
|
|
||||||
nav.down(i - dir.ind)
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if gOpts.wrapscan {
|
if gOpts.wrapscan {
|
||||||
for i := 0; i < dir.ind; i++ {
|
for i := 0; i < dir.ind; i++ {
|
||||||
matched, err := searchMatch(dir.files[i].Name(), nav.search)
|
if matched, err := searchMatch(dir.files[i].Name(), nav.search); err != nil {
|
||||||
if err != nil {
|
return false, err
|
||||||
return err
|
} else if matched {
|
||||||
}
|
return nav.up(dir.ind - i), nil
|
||||||
if matched {
|
|
||||||
nav.up(dir.ind - i)
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return false, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (nav *nav) searchPrev() error {
|
func (nav *nav) searchPrev() (bool, error) {
|
||||||
dir := nav.currDir()
|
dir := nav.currDir()
|
||||||
for i := dir.ind - 1; i >= 0; i-- {
|
for i := dir.ind - 1; i >= 0; i-- {
|
||||||
matched, err := searchMatch(dir.files[i].Name(), nav.search)
|
if matched, err := searchMatch(dir.files[i].Name(), nav.search); err != nil {
|
||||||
if err != nil {
|
return false, err
|
||||||
return err
|
} else if matched {
|
||||||
}
|
return nav.up(dir.ind - i), nil
|
||||||
if matched {
|
|
||||||
nav.up(dir.ind - i)
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if gOpts.wrapscan {
|
if gOpts.wrapscan {
|
||||||
for i := len(dir.files) - 1; i > dir.ind; i-- {
|
for i := len(dir.files) - 1; i > dir.ind; i-- {
|
||||||
matched, err := searchMatch(dir.files[i].Name(), nav.search)
|
if matched, err := searchMatch(dir.files[i].Name(), nav.search); err != nil {
|
||||||
|
return false, err
|
||||||
|
} else if matched {
|
||||||
|
return nav.down(i - dir.ind), 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 {
|
if err != nil {
|
||||||
return err
|
log.Printf("Filter Error: %s", err)
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
if matched {
|
if strings.HasPrefix(pattern, "!") && matched {
|
||||||
nav.down(i - dir.ind)
|
return true
|
||||||
return nil
|
} else if !strings.HasPrefix(pattern, "!") && !matched {
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
return false
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (nav *nav) removeMark(mark string) error {
|
func (nav *nav) removeMark(mark string) error {
|
||||||
@@ -1307,6 +1414,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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,18 +29,24 @@ type sortType struct {
|
|||||||
|
|
||||||
var gOpts struct {
|
var gOpts struct {
|
||||||
anchorfind bool
|
anchorfind 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
|
||||||
number bool
|
number bool
|
||||||
preview bool
|
preview bool
|
||||||
relativenumber bool
|
relativenumber bool
|
||||||
smartcase bool
|
smartcase bool
|
||||||
smartdia bool
|
smartdia bool
|
||||||
|
waitmsg string
|
||||||
wrapscan bool
|
wrapscan bool
|
||||||
wrapscroll bool
|
wrapscroll bool
|
||||||
findlen int
|
findlen int
|
||||||
@@ -54,6 +60,7 @@ var gOpts struct {
|
|||||||
cleaner string
|
cleaner string
|
||||||
promptfmt string
|
promptfmt string
|
||||||
shell string
|
shell string
|
||||||
|
shellflag string
|
||||||
timefmt string
|
timefmt string
|
||||||
truncatechar string
|
truncatechar string
|
||||||
ratios []int
|
ratios []int
|
||||||
@@ -68,18 +75,24 @@ var gOpts struct {
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
gOpts.anchorfind = true
|
gOpts.anchorfind = true
|
||||||
|
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.number = false
|
gOpts.number = false
|
||||||
gOpts.preview = true
|
gOpts.preview = true
|
||||||
gOpts.relativenumber = false
|
gOpts.relativenumber = false
|
||||||
gOpts.smartcase = true
|
gOpts.smartcase = true
|
||||||
gOpts.smartdia = false
|
gOpts.smartdia = false
|
||||||
|
gOpts.waitmsg = "Press any key to continue"
|
||||||
gOpts.wrapscan = true
|
gOpts.wrapscan = true
|
||||||
gOpts.wrapscroll = false
|
gOpts.wrapscroll = false
|
||||||
gOpts.findlen = 1
|
gOpts.findlen = 1
|
||||||
@@ -93,6 +106,7 @@ func init() {
|
|||||||
gOpts.cleaner = ""
|
gOpts.cleaner = ""
|
||||||
gOpts.promptfmt = "\033[32;1m%u@%h\033[0m:\033[34;1m%d\033[0m\033[1m%f\033[0m"
|
gOpts.promptfmt = "\033[32;1m%u@%h\033[0m:\033[34;1m%d\033[0m\033[1m%f\033[0m"
|
||||||
gOpts.shell = gDefaultShell
|
gOpts.shell = gDefaultShell
|
||||||
|
gOpts.shellflag = gDefaultShellFlag
|
||||||
gOpts.timefmt = time.ANSIC
|
gOpts.timefmt = time.ANSIC
|
||||||
gOpts.truncatechar = "~"
|
gOpts.truncatechar = "~"
|
||||||
gOpts.ratios = []int{1, 2, 3}
|
gOpts.ratios = []int{1, 2, 3}
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ var (
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
gDefaultShell = "sh"
|
gDefaultShell = "sh"
|
||||||
|
gDefaultShellFlag = "-c"
|
||||||
gDefaultSocketProt = "unix"
|
gDefaultSocketProt = "unix"
|
||||||
gDefaultSocketPath string
|
gDefaultSocketPath string
|
||||||
)
|
)
|
||||||
@@ -30,6 +31,7 @@ var (
|
|||||||
var (
|
var (
|
||||||
gUser *user.User
|
gUser *user.User
|
||||||
gConfigPaths []string
|
gConfigPaths []string
|
||||||
|
gFilesPath string
|
||||||
gMarksPath string
|
gMarksPath string
|
||||||
gHistoryPath string
|
gHistoryPath string
|
||||||
)
|
)
|
||||||
@@ -82,6 +84,7 @@ func init() {
|
|||||||
data = filepath.Join(gUser.HomeDir, ".local", "share")
|
data = filepath.Join(gUser.HomeDir, ".local", "share")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gFilesPath = filepath.Join(data, "lf", "files")
|
||||||
gMarksPath = filepath.Join(data, "lf", "marks")
|
gMarksPath = filepath.Join(data, "lf", "marks")
|
||||||
gHistoryPath = filepath.Join(data, "lf", "history")
|
gHistoryPath = filepath.Join(data, "lf", "history")
|
||||||
|
|
||||||
@@ -94,24 +97,12 @@ func detachedCommand(name string, arg ...string) *exec.Cmd {
|
|||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
func pauseCommand() *exec.Cmd {
|
|
||||||
cmd := `echo
|
|
||||||
echo -n 'Press any key to continue'
|
|
||||||
old=$(stty -g)
|
|
||||||
stty raw -echo
|
|
||||||
eval "ignore=\$(dd bs=1 count=1 2> /dev/null)"
|
|
||||||
stty $old
|
|
||||||
echo`
|
|
||||||
|
|
||||||
return exec.Command(gOpts.shell, "-c", cmd)
|
|
||||||
}
|
|
||||||
|
|
||||||
func shellCommand(s string, args []string) *exec.Cmd {
|
func shellCommand(s string, args []string) *exec.Cmd {
|
||||||
if len(gOpts.ifs) != 0 {
|
if len(gOpts.ifs) != 0 {
|
||||||
s = fmt.Sprintf("IFS='%s'; %s", gOpts.ifs, s)
|
s = fmt.Sprintf("IFS='%s'; %s", gOpts.ifs, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
args = append([]string{"-c", s, "--"}, args...)
|
args = append([]string{gOpts.shellflag, s, "--"}, args...)
|
||||||
|
|
||||||
args = append(gOpts.shellopts, args...)
|
args = append(gOpts.shellopts, args...)
|
||||||
|
|
||||||
@@ -145,6 +136,31 @@ func isHidden(f os.FileInfo, path string, hiddenfiles []string) bool {
|
|||||||
return hidden
|
return hidden
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func userName(f os.FileInfo) string {
|
||||||
|
if stat, ok := f.Sys().(*syscall.Stat_t); ok {
|
||||||
|
if u, err := user.LookupId(fmt.Sprint(stat.Uid)); err == nil {
|
||||||
|
return fmt.Sprintf("%v ", u.Username)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func groupName(f os.FileInfo) string {
|
||||||
|
if stat, ok := f.Sys().(*syscall.Stat_t); ok {
|
||||||
|
if g, err := user.LookupGroupId(fmt.Sprint(stat.Gid)); err == nil {
|
||||||
|
return fmt.Sprintf("%v ", g.Name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func linkCount(f os.FileInfo) string {
|
||||||
|
if stat, ok := f.Sys().(*syscall.Stat_t); ok {
|
||||||
|
return fmt.Sprintf("%v ", stat.Nlink)
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
func matchPattern(pattern, name, path string) bool {
|
func matchPattern(pattern, name, path string) bool {
|
||||||
s := name
|
s := name
|
||||||
|
|
||||||
@@ -164,12 +180,13 @@ func errCrossDevice(err error) bool {
|
|||||||
return err.(*os.LinkError).Err.(syscall.Errno) == syscall.EXDEV
|
return err.(*os.LinkError).Err.(syscall.Errno) == syscall.EXDEV
|
||||||
}
|
}
|
||||||
|
|
||||||
func exportFiles(f string, fs []string) {
|
func exportFiles(f string, fs []string, pwd string) {
|
||||||
envFile := f
|
envFile := f
|
||||||
envFiles := strings.Join(fs, gOpts.filesep)
|
envFiles := strings.Join(fs, gOpts.filesep)
|
||||||
|
|
||||||
os.Setenv("f", envFile)
|
os.Setenv("f", envFile)
|
||||||
os.Setenv("fs", envFiles)
|
os.Setenv("fs", envFiles)
|
||||||
|
os.Setenv("PWD", pwd)
|
||||||
|
|
||||||
if len(fs) == 0 {
|
if len(fs) == 0 {
|
||||||
os.Setenv("fx", envFile)
|
os.Setenv("fx", envFile)
|
||||||
|
|||||||
+18
-6
@@ -22,6 +22,7 @@ var envPathExt = os.Getenv("PATHEXT")
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
gDefaultShell = "cmd"
|
gDefaultShell = "cmd"
|
||||||
|
gDefaultShellFlag = "/c"
|
||||||
gDefaultSocketProt = "tcp"
|
gDefaultSocketProt = "tcp"
|
||||||
gDefaultSocketPath = "127.0.0.1:12345"
|
gDefaultSocketPath = "127.0.0.1:12345"
|
||||||
)
|
)
|
||||||
@@ -29,6 +30,7 @@ var (
|
|||||||
var (
|
var (
|
||||||
gUser *user.User
|
gUser *user.User
|
||||||
gConfigPaths []string
|
gConfigPaths []string
|
||||||
|
gFilesPath string
|
||||||
gMarksPath string
|
gMarksPath string
|
||||||
gHistoryPath string
|
gHistoryPath string
|
||||||
)
|
)
|
||||||
@@ -66,6 +68,7 @@ func init() {
|
|||||||
filepath.Join(data, "lf", "lfrc"),
|
filepath.Join(data, "lf", "lfrc"),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gFilesPath = filepath.Join(data, "lf", "files")
|
||||||
gMarksPath = filepath.Join(data, "lf", "marks")
|
gMarksPath = filepath.Join(data, "lf", "marks")
|
||||||
gHistoryPath = filepath.Join(data, "lf", "history")
|
gHistoryPath = filepath.Join(data, "lf", "history")
|
||||||
}
|
}
|
||||||
@@ -76,12 +79,8 @@ func detachedCommand(name string, arg ...string) *exec.Cmd {
|
|||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
func pauseCommand() *exec.Cmd {
|
|
||||||
return exec.Command("cmd", "/c", "pause")
|
|
||||||
}
|
|
||||||
|
|
||||||
func shellCommand(s string, args []string) *exec.Cmd {
|
func shellCommand(s string, args []string) *exec.Cmd {
|
||||||
args = append([]string{"/c", s}, args...)
|
args = append([]string{gOpts.shellflag, s}, args...)
|
||||||
|
|
||||||
args = append(gOpts.shellopts, args...)
|
args = append(gOpts.shellopts, args...)
|
||||||
|
|
||||||
@@ -121,11 +120,23 @@ func isHidden(f os.FileInfo, path string, hiddenfiles []string) bool {
|
|||||||
return attrs&syscall.FILE_ATTRIBUTE_HIDDEN != 0
|
return attrs&syscall.FILE_ATTRIBUTE_HIDDEN != 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func userName(f os.FileInfo) string {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func groupName(f os.FileInfo) string {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func linkCount(f os.FileInfo) string {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
func errCrossDevice(err error) bool {
|
func errCrossDevice(err error) bool {
|
||||||
return err.(*os.LinkError).Err.(syscall.Errno) == 17
|
return err.(*os.LinkError).Err.(syscall.Errno) == 17
|
||||||
}
|
}
|
||||||
|
|
||||||
func exportFiles(f string, fs []string) {
|
func exportFiles(f string, fs []string, pwd string) {
|
||||||
envFile := fmt.Sprintf(`"%s"`, f)
|
envFile := fmt.Sprintf(`"%s"`, f)
|
||||||
|
|
||||||
var quotedFiles []string
|
var quotedFiles []string
|
||||||
@@ -136,6 +147,7 @@ func exportFiles(f string, fs []string) {
|
|||||||
|
|
||||||
os.Setenv("f", envFile)
|
os.Setenv("f", envFile)
|
||||||
os.Setenv("fs", envFiles)
|
os.Setenv("fs", envFiles)
|
||||||
|
os.Setenv("PWD", pwd)
|
||||||
|
|
||||||
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
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"strconv"
|
"strconv"
|
||||||
"unicode"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type tokenType byte
|
type tokenType byte
|
||||||
@@ -82,15 +81,23 @@ func (s *scanner) peek() byte {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func isSpace(b byte) bool {
|
func isSpace(b byte) bool {
|
||||||
return unicode.IsSpace(rune(b))
|
switch b {
|
||||||
|
case '\t', '\n', '\v', '\f', '\r', ' ':
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func isDigit(b byte) bool {
|
func isDigit(b byte) bool {
|
||||||
return unicode.IsDigit(rune(b))
|
return '0' <= b && b <= '9'
|
||||||
}
|
}
|
||||||
|
|
||||||
func isPrefix(b byte) bool {
|
func isPrefix(b byte) bool {
|
||||||
return b == '$' || b == '%' || b == '!' || b == '&'
|
switch b {
|
||||||
|
case '$', '%', '!', '&':
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *scanner) scan() bool {
|
func (s *scanner) scan() bool {
|
||||||
|
|||||||
@@ -10,8 +10,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
gCopyFile bool
|
|
||||||
gFileList []string
|
|
||||||
gConnList = make(map[int]net.Conn)
|
gConnList = make(map[int]net.Conn)
|
||||||
gQuitChan = make(chan struct{}, 1)
|
gQuitChan = make(chan struct{}, 1)
|
||||||
gListener net.Listener
|
gListener net.Listener
|
||||||
@@ -55,6 +53,15 @@ func listen(l net.Listener) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func echoerr(c net.Conn, msg string) {
|
||||||
|
fmt.Fprintln(c, msg)
|
||||||
|
log.Printf(msg)
|
||||||
|
}
|
||||||
|
|
||||||
|
func echoerrf(c net.Conn, format string, a ...interface{}) {
|
||||||
|
echoerr(c, fmt.Sprintf(format, a...))
|
||||||
|
}
|
||||||
|
|
||||||
func handleConn(c net.Conn) {
|
func handleConn(c net.Conn) {
|
||||||
s := bufio.NewScanner(c)
|
s := bufio.NewScanner(c)
|
||||||
|
|
||||||
@@ -63,42 +70,29 @@ Loop:
|
|||||||
log.Printf("listen: %s", s.Text())
|
log.Printf("listen: %s", s.Text())
|
||||||
word, rest := splitWord(s.Text())
|
word, rest := splitWord(s.Text())
|
||||||
switch word {
|
switch word {
|
||||||
case "save":
|
|
||||||
s.Scan()
|
|
||||||
switch s.Text() {
|
|
||||||
case "copy":
|
|
||||||
gCopyFile = true
|
|
||||||
case "move":
|
|
||||||
gCopyFile = false
|
|
||||||
default:
|
|
||||||
log.Printf("unexpected option to copy file(s): %s", s.Text())
|
|
||||||
break Loop
|
|
||||||
}
|
|
||||||
gFileList = nil
|
|
||||||
for s.Scan() && s.Text() != "" {
|
|
||||||
gFileList = append(gFileList, s.Text())
|
|
||||||
}
|
|
||||||
case "load":
|
|
||||||
if gCopyFile {
|
|
||||||
fmt.Fprintln(c, "copy")
|
|
||||||
} else {
|
|
||||||
fmt.Fprintln(c, "move")
|
|
||||||
}
|
|
||||||
for _, f := range gFileList {
|
|
||||||
fmt.Fprintln(c, f)
|
|
||||||
}
|
|
||||||
fmt.Fprintln(c)
|
|
||||||
case "conn":
|
case "conn":
|
||||||
if rest != "" {
|
if rest != "" {
|
||||||
word2, _ := splitWord(rest)
|
word2, _ := splitWord(rest)
|
||||||
id, err := strconv.Atoi(word2)
|
id, err := strconv.Atoi(word2)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Print("listen: conn: client id should be a number")
|
echoerr(c, "listen: conn: client id should be a number")
|
||||||
} else {
|
} else {
|
||||||
gConnList[id] = c
|
gConnList[id] = c
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log.Print("listen: conn: requires a client id")
|
echoerr(c, "listen: conn: requires a client id")
|
||||||
|
}
|
||||||
|
case "drop":
|
||||||
|
if rest != "" {
|
||||||
|
word2, _ := splitWord(rest)
|
||||||
|
id, err := strconv.Atoi(word2)
|
||||||
|
if err != nil {
|
||||||
|
echoerr(c, "listen: drop: client id should be a number")
|
||||||
|
} else {
|
||||||
|
delete(gConnList, id)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
echoerr(c, "listen: drop: requires a client id")
|
||||||
}
|
}
|
||||||
case "send":
|
case "send":
|
||||||
if rest != "" {
|
if rest != "" {
|
||||||
@@ -109,12 +103,20 @@ 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")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case "quit":
|
case "quit":
|
||||||
|
if len(gConnList) == 0 {
|
||||||
|
gQuitChan <- struct{}{}
|
||||||
|
gListener.Close()
|
||||||
|
break Loop
|
||||||
|
}
|
||||||
|
case "quit!":
|
||||||
gQuitChan <- struct{}{}
|
gQuitChan <- struct{}{}
|
||||||
for _, c := range gConnList {
|
for _, c := range gConnList {
|
||||||
fmt.Fprintln(c, "echo server is quitting...")
|
fmt.Fprintln(c, "echo server is quitting...")
|
||||||
@@ -123,12 +125,12 @@ Loop:
|
|||||||
gListener.Close()
|
gListener.Close()
|
||||||
break Loop
|
break Loop
|
||||||
default:
|
default:
|
||||||
log.Printf("listen: unexpected command: %s", word)
|
echoerrf(c, "listen: unexpected command: %s", word)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if s.Err() != nil {
|
if s.Err() != nil {
|
||||||
log.Printf("listening: %s", s.Err())
|
echoerrf(c, "listening: %s", s.Err())
|
||||||
}
|
}
|
||||||
|
|
||||||
c.Close()
|
c.Close()
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import (
|
|||||||
|
|
||||||
"github.com/gdamore/tcell/v2"
|
"github.com/gdamore/tcell/v2"
|
||||||
"github.com/mattn/go-runewidth"
|
"github.com/mattn/go-runewidth"
|
||||||
|
"golang.org/x/term"
|
||||||
)
|
)
|
||||||
|
|
||||||
const gEscapeCode = 27
|
const gEscapeCode = 27
|
||||||
@@ -170,7 +171,7 @@ func printLength(s string) int {
|
|||||||
r, w := utf8.DecodeRuneInString(s[i:])
|
r, w := utf8.DecodeRuneInString(s[i:])
|
||||||
|
|
||||||
if r == gEscapeCode && i+1 < len(s) && s[i+1] == '[' {
|
if r == gEscapeCode && i+1 < len(s) && s[i+1] == '[' {
|
||||||
j := strings.IndexByte(s[i:min(len(s), i+32)], 'm')
|
j := strings.IndexAny(s[i:min(len(s), i+64)], "mK")
|
||||||
if j == -1 {
|
if j == -1 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@@ -198,12 +199,13 @@ func (win *win) print(screen tcell.Screen, x, y int, st tcell.Style, s string) t
|
|||||||
r, w := utf8.DecodeRuneInString(s[i:])
|
r, w := utf8.DecodeRuneInString(s[i:])
|
||||||
|
|
||||||
if r == gEscapeCode && i+1 < len(s) && s[i+1] == '[' {
|
if r == gEscapeCode && i+1 < len(s) && s[i+1] == '[' {
|
||||||
j := strings.IndexByte(s[i:min(len(s), i+32)], 'm')
|
j := strings.IndexAny(s[i:min(len(s), i+64)], "mK")
|
||||||
if j == -1 {
|
if j == -1 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
if s[i+j] == 'm' {
|
||||||
st = applyAnsiCodes(s[i+2:i+j], st)
|
st = applyAnsiCodes(s[i+2:i+j], st)
|
||||||
|
}
|
||||||
|
|
||||||
i += j
|
i += j
|
||||||
continue
|
continue
|
||||||
@@ -211,7 +213,7 @@ func (win *win) print(screen tcell.Screen, x, y int, st tcell.Style, s string) t
|
|||||||
|
|
||||||
for {
|
for {
|
||||||
rc, wc := utf8.DecodeRuneInString(s[i+w:])
|
rc, wc := utf8.DecodeRuneInString(s[i+w:])
|
||||||
if rc == gEscapeCode || rc == '\t' || runewidth.RuneWidth(rc) != 0 {
|
if !unicode.Is(unicode.Mn, rc) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
comb = append(comb, rc)
|
comb = append(comb, rc)
|
||||||
@@ -244,11 +246,11 @@ func (win *win) printf(screen tcell.Screen, x, y int, st tcell.Style, format str
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (win *win) printLine(screen tcell.Screen, x, y int, st tcell.Style, s string) {
|
func (win *win) printLine(screen tcell.Screen, x, y int, st tcell.Style, s string) {
|
||||||
win.printf(screen, x, y, st, "%s%*s", s, win.w-len(s), "")
|
win.printf(screen, x, y, st, "%s%*s", s, win.w-printLength(s), "")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (win *win) printRight(screen tcell.Screen, y int, st tcell.Style, s string) {
|
func (win *win) printRight(screen tcell.Screen, y int, st tcell.Style, s string) {
|
||||||
win.print(screen, win.w-len(s), y, st, s)
|
win.print(screen, win.w-printLength(s), y, st, s)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (win *win) printReg(screen tcell.Screen, reg *reg) {
|
func (win *win) printReg(screen tcell.Screen, reg *reg) {
|
||||||
@@ -498,7 +500,7 @@ func getWidths(wtot int) []int {
|
|||||||
|
|
||||||
wsum := 0
|
wsum := 0
|
||||||
for i := 0; i < wlen-1; i++ {
|
for i := 0; i < wlen-1; i++ {
|
||||||
widths[i] = gOpts.ratios[i] * (wtot / rsum)
|
widths[i] = gOpts.ratios[i] * wtot / rsum
|
||||||
wsum += widths[i]
|
wsum += widths[i]
|
||||||
}
|
}
|
||||||
widths[wlen-1] = wtot - wsum
|
widths[wlen-1] = wtot - wsum
|
||||||
@@ -660,13 +662,22 @@ func (ui *ui) loadFileInfo(nav *nav) {
|
|||||||
if curr.linkTarget != "" {
|
if curr.linkTarget != "" {
|
||||||
linkTarget = " -> " + curr.linkTarget
|
linkTarget = " -> " + curr.linkTarget
|
||||||
}
|
}
|
||||||
ui.echof("%v %4s %v%s", curr.Mode(), humanize(curr.Size()), curr.ModTime().Format(gOpts.timefmt), linkTarget)
|
|
||||||
|
ui.echof("%v %v%v%v%4s %v%s",
|
||||||
|
curr.Mode(),
|
||||||
|
linkCount(curr), // optional
|
||||||
|
userName(curr), // optional
|
||||||
|
groupName(curr), // optional
|
||||||
|
humanize(curr.Size()),
|
||||||
|
curr.ModTime().Format(gOpts.timefmt),
|
||||||
|
linkTarget)
|
||||||
}
|
}
|
||||||
|
|
||||||
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))
|
||||||
@@ -707,6 +718,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)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -721,6 +738,34 @@ func (ui *ui) drawStatLine(nav *nav) {
|
|||||||
ind := min(dir.ind+1, tot)
|
ind := min(dir.ind+1, tot)
|
||||||
acc := string(ui.keyCount) + string(ui.keyAcc)
|
acc := string(ui.keyCount) + string(ui.keyAcc)
|
||||||
|
|
||||||
|
var selection string
|
||||||
|
|
||||||
|
if len(nav.saves) > 0 {
|
||||||
|
copy := 0
|
||||||
|
move := 0
|
||||||
|
for _, cp := range nav.saves {
|
||||||
|
if cp {
|
||||||
|
copy++
|
||||||
|
} else {
|
||||||
|
move++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if copy > 0 {
|
||||||
|
selection += fmt.Sprintf(" \033[33;7m %d \033[0m", copy)
|
||||||
|
}
|
||||||
|
if move > 0 {
|
||||||
|
selection += fmt.Sprintf(" \033[31;7m %d \033[0m", move)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(nav.selections) > 0 {
|
||||||
|
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 {
|
||||||
@@ -736,7 +781,7 @@ func (ui *ui) drawStatLine(nav *nav) {
|
|||||||
progress += fmt.Sprintf(" [%d/%d]", nav.deleteCount, nav.deleteTotal)
|
progress += fmt.Sprintf(" [%d/%d]", nav.deleteCount, nav.deleteTotal)
|
||||||
}
|
}
|
||||||
|
|
||||||
ruler := fmt.Sprintf("%s%s %d/%d", acc, progress, ind, tot)
|
ruler := fmt.Sprintf("%s%s%s %d/%d", acc, progress, selection, ind, tot)
|
||||||
|
|
||||||
ui.msgWin.printRight(ui.screen, 0, st, ruler)
|
ui.msgWin.printRight(ui.screen, 0, st, ruler)
|
||||||
}
|
}
|
||||||
@@ -802,16 +847,24 @@ func (ui *ui) draw(nav *nav) {
|
|||||||
ui.drawStatLine(nav)
|
ui.drawStatLine(nav)
|
||||||
ui.screen.HideCursor()
|
ui.screen.HideCursor()
|
||||||
case ">":
|
case ">":
|
||||||
ui.msgWin.printLine(ui.screen, 0, 0, st, ui.cmdPrefix)
|
prefix := ui.cmdPrefix[:min(ui.msgWin.w-1, len(ui.cmdPrefix))]
|
||||||
ui.msgWin.print(ui.screen, len(ui.cmdPrefix), 0, st, ui.msg)
|
pos := min(runeSliceWidth(ui.cmdAccLeft), ui.msgWin.w-len(prefix)-1)
|
||||||
ui.msgWin.print(ui.screen, len(ui.cmdPrefix)+len(ui.msg), 0, st, string(ui.cmdAccLeft))
|
left := ui.cmdAccLeft[runeSliceWidth(ui.cmdAccLeft)-pos:]
|
||||||
ui.msgWin.print(ui.screen, len(ui.cmdPrefix)+len(ui.msg)+runeSliceWidth(ui.cmdAccLeft), 0, st, string(ui.cmdAccRight))
|
right := ui.cmdAccRight
|
||||||
ui.screen.ShowCursor(ui.msgWin.x+len(ui.cmdPrefix)+len(ui.msg)+runeSliceWidth(ui.cmdAccLeft), ui.msgWin.y)
|
ui.msgWin.printLine(ui.screen, 0, 0, st, prefix)
|
||||||
|
ui.msgWin.print(ui.screen, len(prefix), 0, st, ui.msg)
|
||||||
|
ui.msgWin.print(ui.screen, len(prefix)+printLength(ui.msg), 0, st, string(left))
|
||||||
|
ui.msgWin.print(ui.screen, len(prefix)+printLength(ui.msg)+runeSliceWidth(left), 0, st, string(right))
|
||||||
|
ui.screen.ShowCursor(ui.msgWin.x+len(prefix)+printLength(ui.msg)+runeSliceWidth(left), ui.msgWin.y)
|
||||||
default:
|
default:
|
||||||
ui.msgWin.printLine(ui.screen, 0, 0, st, ui.cmdPrefix)
|
prefix := ui.cmdPrefix[:min(ui.msgWin.w-1, len(ui.cmdPrefix))]
|
||||||
ui.msgWin.print(ui.screen, len(ui.cmdPrefix), 0, st, string(ui.cmdAccLeft))
|
pos := min(runeSliceWidth(ui.cmdAccLeft), ui.msgWin.w-len(prefix)-1)
|
||||||
ui.msgWin.print(ui.screen, len(ui.cmdPrefix)+runeSliceWidth(ui.cmdAccLeft), 0, st, string(ui.cmdAccRight))
|
left := ui.cmdAccLeft[runeSliceWidth(ui.cmdAccLeft)-pos:]
|
||||||
ui.screen.ShowCursor(ui.msgWin.x+len(ui.cmdPrefix)+runeSliceWidth(ui.cmdAccLeft), ui.msgWin.y)
|
right := ui.cmdAccRight
|
||||||
|
ui.msgWin.printLine(ui.screen, 0, 0, st, prefix)
|
||||||
|
ui.msgWin.print(ui.screen, len(prefix), 0, st, string(left))
|
||||||
|
ui.msgWin.print(ui.screen, len(prefix)+runeSliceWidth(left), 0, st, string(right))
|
||||||
|
ui.screen.ShowCursor(ui.msgWin.x+len(prefix)+runeSliceWidth(left), ui.msgWin.y)
|
||||||
}
|
}
|
||||||
|
|
||||||
if gOpts.preview {
|
if gOpts.preview {
|
||||||
@@ -1051,11 +1104,12 @@ func (ui *ui) readNormalEvent(ev tcell.Event) expr {
|
|||||||
}
|
}
|
||||||
|
|
||||||
expr, ok := gOpts.keys[button]
|
expr, ok := gOpts.keys[button]
|
||||||
if ok {
|
if !ok {
|
||||||
return expr
|
ui.echoerrf("unknown mapping: %s", button)
|
||||||
|
return draw
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return expr
|
||||||
case *tcell.EventResize:
|
case *tcell.EventResize:
|
||||||
return &callExpr{"redraw", nil, 1}
|
return &callExpr{"redraw", nil, 1}
|
||||||
case *tcell.EventError:
|
case *tcell.EventError:
|
||||||
@@ -1110,25 +1164,25 @@ func (ui *ui) readExpr() {
|
|||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ui *ui) pause() {
|
func (ui *ui) suspend() error {
|
||||||
ui.screen.Fini()
|
return ui.screen.Suspend()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ui *ui) resume() {
|
func (ui *ui) resume() error {
|
||||||
var screen tcell.Screen
|
return ui.screen.Resume()
|
||||||
var err error
|
|
||||||
if screen, err = tcell.NewScreen(); err != nil {
|
|
||||||
log.Fatalf("creating screen: %s", err)
|
|
||||||
} else if err = screen.Init(); err != nil {
|
|
||||||
log.Fatalf("initializing screen: %s", err)
|
|
||||||
}
|
}
|
||||||
screen.EnableMouse()
|
|
||||||
|
|
||||||
ui.screen = screen
|
func anyKey() {
|
||||||
|
fmt.Print(gOpts.waitmsg)
|
||||||
|
defer fmt.Print("\n")
|
||||||
|
oldState, err := term.MakeRaw(int(os.Stdin.Fd()))
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
defer term.Restore(int(os.Stdin.Fd()), oldState)
|
||||||
|
|
||||||
go ui.pollEvents()
|
b := make([]byte, 1)
|
||||||
|
os.Stdin.Read(b)
|
||||||
ui.renew()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func listMatches(screen tcell.Screen, matches []string) (*bytes.Buffer, error) {
|
func listMatches(screen tcell.Screen, matches []string) (*bytes.Buffer, error) {
|
||||||
|
|||||||
Reference in new issue
Block a user