Compare commits
30
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0ede943dd3 | ||
|
|
8875efcb30 | ||
|
|
6f9b1879f3 | ||
|
|
a9d6c5d834 | ||
|
|
78f781b1e6 | ||
|
|
b44676154f | ||
|
|
664d7c88e1 | ||
|
|
5d3c7b7025 | ||
|
|
df5f71c523 | ||
|
|
725e63c0a8 | ||
|
|
20c85c9477 | ||
|
|
1f31d6634e | ||
|
|
1a1cbc992e | ||
|
|
4f45fc2cda | ||
|
|
9ecf9ac660 | ||
|
|
3eb06f2103 | ||
|
|
efd8e6e04a | ||
|
|
281eda3c1a | ||
|
|
5962d8d9b7 | ||
|
|
274b13df9e | ||
|
|
1c9029e9ec | ||
|
|
252ca3e425 | ||
|
|
e6789ab125 | ||
|
|
f918e34e9b | ||
|
|
1f779c5d7e | ||
|
|
7351444397 | ||
|
|
34ecd96967 | ||
|
|
9f27e57c4b | ||
|
|
3eeafab106 | ||
|
|
685c6e24a5 |
No files matched your search
@@ -0,0 +1,41 @@
|
||||
name: Bug report
|
||||
description: Report a problem
|
||||
labels: [bug]
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
- Search [existing issues](https://github.com/gokcehan/lf/issues) before reporting.
|
||||
- Verify bugs yourself. AI claims alone aren't proof.
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Description
|
||||
description: Describe the problem. Include logs (`lf -log lf.log`), images, or videos if useful.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Steps to reproduce
|
||||
description: |
|
||||
Describe how to reproduce or verify the problem.
|
||||
- Try `lf -config /dev/null` (Windows: `lf -config NUL`) to skip loading your `lfrc`.
|
||||
- If the problem disappears, include any settings or scripts needed to reproduce it.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: lf version
|
||||
description: Paste the output of `lf -version`.
|
||||
render: text
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Environment
|
||||
description: Include your operating system, terminal, and any other details relevant to the issue.
|
||||
placeholder: |
|
||||
Operating system:
|
||||
Terminal:
|
||||
...
|
||||
validations:
|
||||
required: true
|
||||
@@ -0,0 +1,5 @@
|
||||
blank_issues_enabled: false
|
||||
contact_links:
|
||||
- name: Question
|
||||
url: https://github.com/gokcehan/lf/discussions
|
||||
about: Ask a question about using or configuring lf
|
||||
@@ -0,0 +1,23 @@
|
||||
name: Feature request
|
||||
description: Suggest a feature or improvement
|
||||
labels: [enhancement]
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: Search [existing issues](https://github.com/gokcehan/lf/issues) before submitting.
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Problem or use case
|
||||
description: What is missing or difficult to do in lf?
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Desired behavior
|
||||
description: Describe how the feature should work. Include examples from other tools if relevant.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Configuration and workarounds
|
||||
description: Have you tried achieving this through configuration or scripting? If so, what limitations did you encounter?
|
||||
@@ -42,7 +42,7 @@ jobs:
|
||||
- name: golangci-lint
|
||||
uses: golangci/golangci-lint-action@v9
|
||||
with:
|
||||
version: v2.5.0
|
||||
version: v2.9.0
|
||||
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
+18
-2
@@ -10,6 +10,20 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
||||
|
||||
## Unreleased
|
||||
|
||||
### Added
|
||||
|
||||
- The `cd` command now supports `-` to change to the previous directory (#2693).
|
||||
|
||||
### Fixed
|
||||
|
||||
- Attempting to copy irregular files now results in an error instead of causing the copy operation to hang (#2618).
|
||||
- Dead client connections no longer prevent the `quit` server command from terminating the server (#2643).
|
||||
- The `calcdirsize` command now calculates the size of the target directory for symbolic links instead of the size of the link itself (#2650).
|
||||
- Readline markers in `promptfmt` are no longer rendered as visible characters (#2657).
|
||||
- Selecting entries with the mouse no longer causes the file list to jump unexpectedly (#2664).
|
||||
- A bug where executing the `quit` command multiple times in quick succession could cause `lf` to become unresponsive is now fixed (#2674).
|
||||
- The home directory abbreviation `~` no longer matches partial directory names (#2679).
|
||||
|
||||
## [r42](https://github.com/gokcehan/lf/releases/tag/r42)
|
||||
|
||||
### Changed
|
||||
@@ -61,10 +75,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
||||
- Previews no longer flicker when the terminal height decreases (#2537).
|
||||
- Symbolic linked directories are now updated properly when the `watch` option is enabled (#2550).
|
||||
- Previews of modified files are now updated properly when the `preload` option is enabled (#2567).
|
||||
- Previews of files other than the current file are now reloaded immediately after being modified when the `watch` option is enabled (#2594).
|
||||
- Previews of files other than the current file are now reloaded immediately after being modified when the `watch` option is enabled (#2594) (#2602) (#2648).
|
||||
- The `loading...` message now shows for files that are reloading due to being modified (#2597).
|
||||
- Attempting to copy a directory into itself will now result in an error (#2608).
|
||||
- Attempting to copy a directory into itself will now result in an error (#2608) (#2623).
|
||||
- The permissions of state files (i.e. `files`/`history`/`marks`/`tags`) is now changed to only be accessible by the owner (#2612).
|
||||
- Broken symbolic links are no longer silently overwritten when moving files (#2619).
|
||||
- Using the `copy` or `cut` command with a path containing newline characters now results in an error instead of silently omitting the path (#2620).
|
||||
|
||||
## [r41](https://github.com/gokcehan/lf/releases/tag/r41)
|
||||
|
||||
|
||||
@@ -54,12 +54,14 @@ func newApp(ui *ui, nav *nav) *app {
|
||||
signal.Notify(sigChan, os.Interrupt, syscall.SIGHUP, syscall.SIGQUIT, syscall.SIGTERM)
|
||||
go func() {
|
||||
for {
|
||||
switch <-sigChan {
|
||||
sig := <-sigChan
|
||||
switch sig {
|
||||
case os.Interrupt:
|
||||
case syscall.SIGHUP, syscall.SIGQUIT, syscall.SIGTERM:
|
||||
log.Printf("received termination signal: %s", sig)
|
||||
app.quit()
|
||||
app.ui.screen.Fini()
|
||||
os.Exit(3)
|
||||
return
|
||||
}
|
||||
}
|
||||
}()
|
||||
@@ -95,6 +97,14 @@ func (app *app) quit() {
|
||||
}
|
||||
}
|
||||
|
||||
// requestQuit signals the main loop to quit and never blocks when a request is already pending.
|
||||
func (app *app) requestQuit() {
|
||||
select {
|
||||
case app.quitChan <- struct{}{}:
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
func (app *app) readFile(path string) {
|
||||
log.Printf("reading file: %s", path)
|
||||
|
||||
@@ -529,10 +539,11 @@ func (app *app) runCmdSync(cmd *exec.Cmd, pauseAfter bool) {
|
||||
app.nav.previewChan <- ""
|
||||
|
||||
if err := app.ui.suspend(); err != nil {
|
||||
log.Printf("suspend: %s", err)
|
||||
log.Printf("suspending screen: %s", err)
|
||||
}
|
||||
defer func() {
|
||||
if err := app.ui.resume(); err != nil {
|
||||
log.Printf("resuming screen: %s", err)
|
||||
app.quit()
|
||||
os.Exit(3)
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ func run() {
|
||||
if gLogPath != "" {
|
||||
f, err := os.OpenFile(gLogPath, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0o600)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to open log file: %s", err)
|
||||
log.Fatalf("opening log file: %s", err)
|
||||
}
|
||||
defer f.Close()
|
||||
log.SetOutput(f)
|
||||
@@ -108,7 +108,7 @@ func printPath(label, path string, stdoutIsTerminal bool) {
|
||||
|
||||
func writeLastDir(filename, lastDir string) {
|
||||
if strings.ContainsAny(lastDir, "\n\r") {
|
||||
log.Printf("last-dir: path contains newline: %q", lastDir)
|
||||
log.Printf("last-dir: skipping path with newline: %q", lastDir)
|
||||
return
|
||||
}
|
||||
f, err := os.Create(filename)
|
||||
@@ -153,7 +153,7 @@ func readExpr() <-chan expr {
|
||||
|
||||
c, err := net.Dial("unix", gSocketPath)
|
||||
for err != nil {
|
||||
log.Printf("connecting server: %s", err)
|
||||
log.Printf("connecting to server (retrying in %s): %s", duration, err)
|
||||
time.Sleep(duration)
|
||||
duration *= 2
|
||||
c, err = net.Dial("unix", gSocketPath)
|
||||
|
||||
+6
-8
@@ -127,8 +127,7 @@ var (
|
||||
|
||||
func getOptWords(opts any) (optWords []string) {
|
||||
t := reflect.TypeOf(opts)
|
||||
for i := range t.NumField() {
|
||||
field := t.Field(i)
|
||||
for field := range t.Fields() {
|
||||
switch field.Type.Kind() {
|
||||
case reflect.Map:
|
||||
continue
|
||||
@@ -145,8 +144,7 @@ func getOptWords(opts any) (optWords []string) {
|
||||
|
||||
func getLocalOptWords(localOpts any) (localOptWords []string) {
|
||||
t := reflect.TypeOf(localOpts)
|
||||
for i := range t.NumField() {
|
||||
field := t.Field(i)
|
||||
for field := range t.Fields() {
|
||||
name := field.Name
|
||||
if field.Type.Kind() != reflect.Map {
|
||||
continue
|
||||
@@ -248,7 +246,7 @@ func matchFile(s string, dirOnly bool, escape, unescape func(string) string) (ma
|
||||
}
|
||||
files, err := os.ReadDir(d)
|
||||
if err != nil {
|
||||
log.Printf("reading directory: %s", err)
|
||||
log.Printf("completing path: %s", err)
|
||||
longest = s
|
||||
return
|
||||
}
|
||||
@@ -318,7 +316,7 @@ func matchExec(s string) (matches []compMatch, longest string) {
|
||||
files, err := os.ReadDir(p)
|
||||
if err != nil {
|
||||
if !os.IsNotExist(err) {
|
||||
log.Printf("reading path: %s", err)
|
||||
log.Printf("completing shell command: %s", err)
|
||||
}
|
||||
continue
|
||||
}
|
||||
@@ -330,7 +328,7 @@ func matchExec(s string) (matches []compMatch, longest string) {
|
||||
|
||||
finfo, err := f.Info()
|
||||
if err != nil {
|
||||
log.Printf("getting file information: %s", err)
|
||||
log.Printf("completing shell command: %s", err)
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -348,7 +346,7 @@ func matchExec(s string) (matches []compMatch, longest string) {
|
||||
func matchSearch(s string) (matches []compMatch, longest string) {
|
||||
files, err := os.ReadDir(".")
|
||||
if err != nil {
|
||||
log.Printf("reading directory: %s", err)
|
||||
log.Printf("completing search: %s", err)
|
||||
longest = s
|
||||
return
|
||||
}
|
||||
|
||||
@@ -140,8 +140,8 @@ func copyAll(srcs []string, dstDir string, preserve []string) (nums chan int64,
|
||||
return nil
|
||||
}
|
||||
newPath := filepath.Join(dst, rel)
|
||||
switch {
|
||||
case info.IsDir():
|
||||
switch info.Mode() & os.ModeType {
|
||||
case os.ModeDir:
|
||||
dstMode := os.ModePerm
|
||||
if slices.Contains(preserve, "mode") {
|
||||
dstMode = info.Mode()
|
||||
@@ -153,7 +153,7 @@ func copyAll(srcs []string, dstDir string, preserve []string) (nums chan int64,
|
||||
dirInfos[newPath] = info
|
||||
}
|
||||
nums <- info.Size()
|
||||
case info.Mode()&os.ModeSymlink != 0:
|
||||
case os.ModeSymlink:
|
||||
if rlink, err := os.Readlink(path); err != nil {
|
||||
errs <- fmt.Errorf("symlink: %w", err)
|
||||
} else {
|
||||
@@ -162,8 +162,12 @@ func copyAll(srcs []string, dstDir string, preserve []string) (nums chan int64,
|
||||
}
|
||||
}
|
||||
nums <- info.Size()
|
||||
default:
|
||||
case 0:
|
||||
copyFile(path, newPath, preserve, info, nums, errs)
|
||||
default:
|
||||
// pipes, sockets and devices cannot be copied like regular files
|
||||
errs <- fmt.Errorf("cannot copy irregular file %s (named pipe, socket or device)", path)
|
||||
nums <- info.Size()
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
||||
@@ -20,7 +20,7 @@ lf - terminal file manager
|
||||
[**-server**]
|
||||
[**-single**]
|
||||
[**-version**]
|
||||
[*cd-or-select-path*]
|
||||
[*path*]
|
||||
|
||||
# DESCRIPTION
|
||||
|
||||
@@ -36,7 +36,7 @@ A man page with the same content is also available in the repository at https://
|
||||
|
||||
## POSITIONAL ARGUMENTS
|
||||
|
||||
**cd-or-select-path**
|
||||
**path**
|
||||
|
||||
Set the starting location. If *path* is a directory, start in there. If it's a file, start in the file's parent directory and select the file. When no *path* is supplied, lf uses the current directory. Only accepts one argument.
|
||||
|
||||
@@ -522,7 +522,8 @@ A custom `open` command can be defined to override this default.
|
||||
|
||||
## jump-next (default `]`), jump-prev (default `[`)
|
||||
|
||||
Change the current working directory to the next/previous jumplist item.
|
||||
Change the current working directory to the next/previous entry in the jump list.
|
||||
The jump list is a history of directories visited during the current session.
|
||||
|
||||
## top (default `gg` and `<home>`), bottom (default `G` and `<end>`)
|
||||
|
||||
@@ -674,6 +675,7 @@ Print given arguments to the message line at the bottom as `errorfmt` and also t
|
||||
## cd
|
||||
|
||||
Change the working directory to the given argument.
|
||||
If the argument is `-`, change to the previous directory stored in the special bookmark `'`.
|
||||
|
||||
## select
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ SYNOPSIS
|
||||
lf [-command command] [-config path] [-cpuprofile path] [-doc] [-help]
|
||||
[-last-dir-path path] [-log path] [-memprofile path] [-print-last-dir]
|
||||
[-print-selection] [-remote command] [-selection-path path] [-server]
|
||||
[-single] [-version] [cd-or-select-path]
|
||||
[-single] [-version] [path]
|
||||
|
||||
DESCRIPTION
|
||||
|
||||
@@ -26,7 +26,7 @@ OPTIONS
|
||||
|
||||
POSITIONAL ARGUMENTS
|
||||
|
||||
cd-or-select-path
|
||||
path
|
||||
|
||||
Set the starting location. If path is a directory, start in there.
|
||||
If it's a file, start in the file's parent directory and select the
|
||||
@@ -542,7 +542,9 @@ override this default.
|
||||
|
||||
jump-next (default ]), jump-prev (default [)
|
||||
|
||||
Change the current working directory to the next/previous jumplist item.
|
||||
Change the current working directory to the next/previous entry in the
|
||||
jump list. The jump list is a history of directories visited during the
|
||||
current session.
|
||||
|
||||
top (default gg and <home>), bottom (default G and <end>)
|
||||
|
||||
@@ -707,7 +709,8 @@ also to the log file.
|
||||
|
||||
cd
|
||||
|
||||
Change the working directory to the given argument.
|
||||
Change the working directory to the given argument. If the argument is
|
||||
-, change to the previous directory stored in the special bookmark '.
|
||||
|
||||
select
|
||||
|
||||
|
||||
@@ -154,9 +154,6 @@ func (e *setExpr) eval(app *app, _ []string) {
|
||||
if err == nil {
|
||||
app.nav.sort()
|
||||
}
|
||||
// DEPRECATED: remove after r42 is released
|
||||
case "roundbox", "noroundbox", "roundbox!":
|
||||
app.ui.echoerr("option 'roundbox' is deprecated, use 'borderstyle' instead")
|
||||
case "showbinds", "noshowbinds", "showbinds!":
|
||||
err = applyBoolOpt(&gOpts.showbinds, e)
|
||||
case "smartcase", "nosmartcase", "smartcase!":
|
||||
@@ -789,7 +786,7 @@ func resetIncCmd(app *app) {
|
||||
dir := app.nav.currDir()
|
||||
old := dir.ind
|
||||
if err := app.nav.setFilter(app.nav.prevFilter); err != nil {
|
||||
log.Printf("reset filter: %s", err)
|
||||
log.Printf("resetting filter: %s", err)
|
||||
} else if old != dir.ind {
|
||||
app.ui.loadFile(app, true)
|
||||
}
|
||||
@@ -992,13 +989,20 @@ func insert(app *app, arg string) {
|
||||
}
|
||||
|
||||
func cd(app *app, path string) error {
|
||||
wd := app.nav.currDir().path
|
||||
if path == "-" {
|
||||
prev, ok := app.nav.marks["'"]
|
||||
if !ok {
|
||||
return errors.New("no previous directory")
|
||||
}
|
||||
path = prev
|
||||
}
|
||||
|
||||
path, err := filepath.Abs(replaceTilde(path))
|
||||
if err != nil {
|
||||
return fmt.Errorf("getting absolute path: %w", err)
|
||||
}
|
||||
|
||||
wd := app.nav.currDir().path
|
||||
if path == wd {
|
||||
return nil
|
||||
}
|
||||
@@ -1007,7 +1011,7 @@ func cd(app *app, path string) error {
|
||||
preChdir(app)
|
||||
|
||||
if err := app.nav.cd(path); err != nil {
|
||||
return fmt.Errorf("changing directory: %w", err)
|
||||
return err
|
||||
}
|
||||
|
||||
app.ui.loadFile(app, true)
|
||||
@@ -1049,7 +1053,7 @@ func (e *callExpr) eval(app *app, _ []string) {
|
||||
|
||||
switch e.name {
|
||||
case "quit":
|
||||
app.quitChan <- struct{}{}
|
||||
app.requestQuit()
|
||||
case "up":
|
||||
if app.nav.up(e.count) {
|
||||
app.ui.loadFile(app, true)
|
||||
@@ -1105,7 +1109,7 @@ func (e *callExpr) eval(app *app, _ []string) {
|
||||
preChdir(app)
|
||||
err := app.nav.open()
|
||||
if err != nil {
|
||||
app.ui.echoerrf("opening directory: %s", err)
|
||||
app.ui.echoerrf("open: %s", err)
|
||||
return
|
||||
}
|
||||
app.ui.loadFile(app, true)
|
||||
@@ -1114,7 +1118,7 @@ func (e *callExpr) eval(app *app, _ []string) {
|
||||
} else {
|
||||
if gSelectionPath != "" || gPrintSelection {
|
||||
app.selectionOut, _ = app.nav.currFileOrSelections()
|
||||
app.quitChan <- struct{}{}
|
||||
app.requestQuit()
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1499,6 +1503,7 @@ func (e *callExpr) eval(app *app, _ []string) {
|
||||
return
|
||||
}
|
||||
normal(app)
|
||||
app.ui.menu = listMarks(app.nav.marks)
|
||||
app.ui.cmdPrefix = "mark-save: "
|
||||
case "mark-load":
|
||||
if app.ui.cmdPrefix == ">" {
|
||||
@@ -1600,7 +1605,13 @@ func (e *callExpr) eval(app *app, _ []string) {
|
||||
if dir.loading {
|
||||
dir.files = append(dir.files, &file{FileInfo: lstat})
|
||||
}
|
||||
dir.sel(filepath.Base(path), app.nav.height)
|
||||
name := filepath.Base(path)
|
||||
for i, f := range dir.files {
|
||||
if f.Name() == name {
|
||||
app.nav.move(i)
|
||||
break
|
||||
}
|
||||
}
|
||||
app.ui.loadFile(app, true)
|
||||
case "source":
|
||||
if len(e.args) != 1 {
|
||||
@@ -1613,7 +1624,7 @@ func (e *callExpr) eval(app *app, _ []string) {
|
||||
app.ui.echoerr("push: requires an argument")
|
||||
return
|
||||
}
|
||||
log.Println("pushing keys", e.args[0])
|
||||
log.Printf("pushing keys: %s", e.args[0])
|
||||
for _, val := range splitKeys(e.args[0]) {
|
||||
app.ui.evChan <- parseKey(val)
|
||||
}
|
||||
@@ -1677,7 +1688,7 @@ func (e *callExpr) eval(app *app, _ []string) {
|
||||
|
||||
tty, ok := app.ui.screen.Tty()
|
||||
if !ok {
|
||||
log.Print("tty-write: failed to get tty")
|
||||
log.Print("tty-write: no tty available")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1901,7 +1912,7 @@ func (e *callExpr) eval(app *app, _ []string) {
|
||||
}
|
||||
app.ui.loadFile(app, true)
|
||||
default:
|
||||
log.Printf("entering unknown execution prefix: %q", app.ui.cmdPrefix)
|
||||
log.Printf("unknown execution prefix: %q", app.ui.cmdPrefix)
|
||||
}
|
||||
case "cmd-interrupt":
|
||||
if app.cmd != nil {
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
module github.com/gokcehan/lf
|
||||
|
||||
go 1.25.0
|
||||
go 1.26.0
|
||||
|
||||
require (
|
||||
github.com/clipperhouse/displaywidth v0.11.0
|
||||
github.com/djherbis/times v1.6.0
|
||||
github.com/fsnotify/fsnotify v1.10.1
|
||||
github.com/gdamore/tcell/v3 v3.4.1
|
||||
golang.org/x/sys v0.47.0
|
||||
golang.org/x/term v0.45.0
|
||||
github.com/gdamore/tcell/v3 v3.6.0
|
||||
golang.org/x/sys v0.49.0
|
||||
golang.org/x/term v0.46.0
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/clipperhouse/uax29/v2 v2.7.0 // indirect
|
||||
github.com/gdamore/encoding v1.0.1 // indirect
|
||||
github.com/lucasb-eyer/go-colorful v1.4.0 // indirect
|
||||
golang.org/x/text v0.40.0 // indirect
|
||||
github.com/lucasb-eyer/go-colorful v1.4.1 // indirect
|
||||
golang.org/x/text v0.42.0 // indirect
|
||||
)
|
||||
@@ -8,10 +8,10 @@ github.com/fsnotify/fsnotify v1.10.1 h1:b0/UzAf9yR5rhf3RPm9gf3ehBPpf0oZKIjtpKrx5
|
||||
github.com/fsnotify/fsnotify v1.10.1/go.mod h1:TLheqan6HD6GBK6PrDWyDPBaEV8LspOxvPSjC+bVfgo=
|
||||
github.com/gdamore/encoding v1.0.1 h1:YzKZckdBL6jVt2Gc+5p82qhrGiqMdG/eNs6Wy0u3Uhw=
|
||||
github.com/gdamore/encoding v1.0.1/go.mod h1:0Z0cMFinngz9kS1QfMjCP8TY7em3bZYeeklsSDPivEo=
|
||||
github.com/gdamore/tcell/v3 v3.4.1 h1:22227t1EUwqxTlmCX9vw0RUE2IEPGw6oYcNan+bPe4w=
|
||||
github.com/gdamore/tcell/v3 v3.4.1/go.mod h1:YWwuxZNi14VGQC5g2VGNEDRXpBraTwvVjMovRH6G6hw=
|
||||
github.com/lucasb-eyer/go-colorful v1.4.0 h1:UtrWVfLdarDgc44HcS7pYloGHJUjHV/4FwW4TvVgFr4=
|
||||
github.com/lucasb-eyer/go-colorful v1.4.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
|
||||
github.com/gdamore/tcell/v3 v3.6.0 h1:jW20qS6Tm38KVDqLHq9KWSvyjNl00FbhbD8rIAnHBws=
|
||||
github.com/gdamore/tcell/v3 v3.6.0/go.mod h1:CBZxkl2T+XxEyuBfOh4zaahqm27dngvhfBfCCZxJsgc=
|
||||
github.com/lucasb-eyer/go-colorful v1.4.1 h1:1EO+WB73+EH8EVbzlrG3KLAfEypQWVHIBqlTf+2hNss=
|
||||
github.com/lucasb-eyer/go-colorful v1.4.1/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
|
||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
@@ -31,20 +31,20 @@ golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBc
|
||||
golang.org/x/sys v0.0.0-20220615213510-4f61da869c0c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.47.0 h1:o7XGOvZQCADBQQ4Y7VNq2dRWQR7JmOUW8Kxx4ZsNgWs=
|
||||
golang.org/x/sys v0.47.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=
|
||||
golang.org/x/sys v0.49.0 h1:XbzkgYJHdqh/8m2Uu0W/dQv8nktxx4BFHp1M0gROTXA=
|
||||
golang.org/x/sys v0.49.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
|
||||
golang.org/x/term v0.45.0 h1:NwWyBmoJCbfTHpxrWoZ9C6/VxOf7ic219I8xZZFdrf0=
|
||||
golang.org/x/term v0.45.0/go.mod h1:9aqxs0blBcrm/n0L9QW0aRVD+ktan8ssZromtqJC43w=
|
||||
golang.org/x/term v0.46.0 h1:3+OXuTbaKDgwk8jTi3aSLHRlmWqHEUDUtxnbFigO4YE=
|
||||
golang.org/x/term v0.46.0/go.mod h1:+K02xbkittuwc0Am4abfA3Fc+XRGXkvBXNO88NCXPoc=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
golang.org/x/text v0.40.0 h1:Ub2Z6/xjgF1WrYQz2nuITOEegKFtiIy+rieRJ5lHZKs=
|
||||
golang.org/x/text v0.40.0/go.mod h1:hpnzDAfGV753zIKo+wk3u1bVKCGPbrnF7+7LBF/UHVY=
|
||||
golang.org/x/text v0.42.0 h1:JbOZXgfeCPU9gacVtYliJqOhD+zhrEqK4LfdpmlUZqI=
|
||||
golang.org/x/text v0.42.0/go.mod h1:ojzP1Z+2QtioaF8DTtO8K5q7JWVVYwZKenzujK0Zd0E=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
.\" Automatically generated by Pandoc 3.7.0.2
|
||||
.\"
|
||||
.TH "LF" "1" "2026\-07\-31" "r42" "DOCUMENTATION"
|
||||
.TH "LF" "1" "2026\-10\-29" "r43" "DOCUMENTATION"
|
||||
.SH NAME
|
||||
lf \- terminal file manager
|
||||
.SH SYNOPSIS
|
||||
@@ -11,8 +11,7 @@ lf \- terminal file manager
|
||||
\f[I]path\f[R]] [\f[B]\-print\-last\-dir\f[R]]
|
||||
[\f[B]\-print\-selection\f[R]] [\f[B]\-remote\f[R] \f[I]command\f[R]]
|
||||
[\f[B]\-selection\-path\f[R] \f[I]path\f[R]] [\f[B]\-server\f[R]]
|
||||
[\f[B]\-single\f[R]] [\f[B]\-version\f[R]]
|
||||
[\f[I]cd\-or\-select\-path\f[R]]
|
||||
[\f[B]\-single\f[R]] [\f[B]\-version\f[R]] [\f[I]path\f[R]]
|
||||
.SH DESCRIPTION
|
||||
lf is a terminal file manager.
|
||||
.PP
|
||||
@@ -33,7 +32,7 @@ A man page with the same content is also available in the repository at
|
||||
.SH OPTIONS
|
||||
.SS POSITIONAL ARGUMENTS
|
||||
.TP
|
||||
\f[B]cd\-or\-select\-path\f[R]
|
||||
\f[B]path\f[R]
|
||||
Set the starting location.
|
||||
If \f[I]path\f[R] is a directory, start in there.
|
||||
If it\(aqs a file, start in the file\(aqs parent directory and select
|
||||
@@ -570,7 +569,10 @@ opener asynchronously with the current file as the argument.
|
||||
A custom \f[CR]open\f[R] command can be defined to override this
|
||||
default.
|
||||
.SS jump\-next (default \f[CR]]\f[R]), jump\-prev (default \f[CR][\f[R])
|
||||
Change the current working directory to the next/previous jumplist item.
|
||||
Change the current working directory to the next/previous entry in the
|
||||
jump list.
|
||||
The jump list is a history of directories visited during the current
|
||||
session.
|
||||
.SS top (default \f[CR]gg\f[R] and \f[CR]<home>\f[R]), bottom (default \f[CR]G\f[R] and \f[CR]<end>\f[R])
|
||||
Move the current file selection to the top/bottom of the directory.
|
||||
A count can be specified to move to a specific line, for example, use
|
||||
@@ -677,6 +679,8 @@ Print given arguments to the message line at the bottom as
|
||||
\f[CR]errorfmt\f[R] and also to the log file.
|
||||
.SS cd
|
||||
Change the working directory to the given argument.
|
||||
If the argument is \f[CR]\-\f[R], change to the previous directory
|
||||
stored in the special bookmark \f[CR]\(aq\f[R].
|
||||
.SS select
|
||||
Change the current file selection to the given argument.
|
||||
.SS source
|
||||
|
||||
@@ -82,7 +82,7 @@ func exportEnvVars() {
|
||||
|
||||
level, err := strconv.Atoi(envLevel)
|
||||
if err != nil {
|
||||
log.Printf("reading lf level: %s", err)
|
||||
log.Printf("parsing $LF_LEVEL: %s", err)
|
||||
}
|
||||
|
||||
level++
|
||||
@@ -183,7 +183,7 @@ func checkServer() {
|
||||
startServer()
|
||||
} else if _, err := net.Dial("unix", gSocketPath); err != nil {
|
||||
if err := os.Remove(gSocketPath); err != nil {
|
||||
log.Print(err)
|
||||
log.Printf("removing socket: %s", err)
|
||||
}
|
||||
startServer()
|
||||
}
|
||||
@@ -225,10 +225,11 @@ func main() {
|
||||
f := flag.CommandLine.Output()
|
||||
fmt.Fprintf(f, `lf - Terminal file manager
|
||||
|
||||
Usage: %s [options] [cd-or-select-path]
|
||||
Usage: %s [options] [path]
|
||||
|
||||
cd-or-select-path
|
||||
set the initial dir or file selection to the given argument
|
||||
Arguments:
|
||||
path
|
||||
set the initial directory or select the given file
|
||||
|
||||
Options:
|
||||
`, os.Args[0])
|
||||
@@ -380,7 +381,7 @@ Options:
|
||||
case 1:
|
||||
gSelect = flag.Arg(0)
|
||||
default:
|
||||
fmt.Fprintln(os.Stderr, "only single file or directory is allowed")
|
||||
fmt.Fprintln(os.Stderr, "only one file or directory may be specified")
|
||||
os.Exit(2)
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"unicode"
|
||||
|
||||
@@ -32,8 +31,8 @@ var (
|
||||
func isRoot(name string) bool { return filepath.Dir(name) == name }
|
||||
|
||||
func replaceTilde(s string) string {
|
||||
if strings.HasPrefix(s, "~") {
|
||||
return gUser.HomeDir + s[1:]
|
||||
if rest, ok := strings.CutPrefix(s, "~"); ok && (rest == "" || os.IsPathSeparator(rest[0])) {
|
||||
return gUser.HomeDir + rest
|
||||
}
|
||||
return s
|
||||
}
|
||||
@@ -393,14 +392,16 @@ func naturalCmp(s1, s2 string) int {
|
||||
tok2 := s2[lo2:hi2]
|
||||
|
||||
if isDigit1 && isDigit2 {
|
||||
num1, err1 := strconv.Atoi(tok1)
|
||||
num2, err2 := strconv.Atoi(tok2)
|
||||
if err1 == nil && err2 == nil {
|
||||
if num1 != num2 {
|
||||
return cmp.Compare(num1, num2)
|
||||
} else if len(tok1) != len(tok2) {
|
||||
return cmp.Compare(len(tok1), len(tok2))
|
||||
}
|
||||
// compare the digits directly instead of parsing them, so that
|
||||
// numbers too large for an int are still ordered by value
|
||||
num1 := strings.TrimLeft(tok1, "0")
|
||||
num2 := strings.TrimLeft(tok2, "0")
|
||||
if len(num1) != len(num2) {
|
||||
return cmp.Compare(len(num1), len(num2))
|
||||
} else if num1 != num2 {
|
||||
return cmp.Compare(num1, num2)
|
||||
} else if len(tok1) != len(tok2) {
|
||||
return cmp.Compare(len(tok1), len(tok2))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -399,6 +399,12 @@ func TestNaturalCmp(t *testing.T) {
|
||||
{"foo0bar", "foo00bar", -1},
|
||||
{"foo1", "foo01", -1},
|
||||
{"foo1bar", "foo01bar", -1},
|
||||
{"9", "10000000000000000000", -1},
|
||||
{"foo9", "foo10000000000000000000", -1},
|
||||
{"9223372036854775807", "9223372036854775808", -1},
|
||||
{"99999999999999999999", "100000000000000000000", -1},
|
||||
{"100000000000000000000", "0100000000000000000000", -1},
|
||||
{"100000000000000000000a", "100000000000000000000b", -1},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
|
||||
@@ -48,7 +48,7 @@ type file struct {
|
||||
func newFile(path string) *file {
|
||||
lstat, err := os.Lstat(path)
|
||||
if err != nil {
|
||||
log.Printf("getting file information: %s", err)
|
||||
log.Printf("getting file info: %s", err)
|
||||
return &file{
|
||||
FileInfo: &fakeStat{name: filepath.Base(path)},
|
||||
linkState: notLink,
|
||||
@@ -100,13 +100,13 @@ func newFile(path string) *file {
|
||||
if lstat.IsDir() && getDirCounts(filepath.Dir(path)) {
|
||||
d, err := os.Open(path)
|
||||
if err != nil {
|
||||
log.Printf("opening file: %s", err)
|
||||
log.Printf("counting directory entries: %s", err)
|
||||
} else {
|
||||
names, err := d.Readdirnames(10000)
|
||||
d.Close()
|
||||
|
||||
if names == nil && err != io.EOF {
|
||||
log.Printf("reading directory: %s", err)
|
||||
log.Printf("counting directory entries: %s", err)
|
||||
} else {
|
||||
dirCount = len(names)
|
||||
}
|
||||
@@ -797,8 +797,7 @@ func (nav *nav) previewLoop(ui *ui) {
|
||||
cmd.Stderr = &stderr
|
||||
|
||||
if err := cmd.Run(); err != nil {
|
||||
var exitErr *exec.ExitError
|
||||
if !errors.As(err, &exitErr) {
|
||||
if _, ok := errors.AsType[*exec.ExitError](err); !ok {
|
||||
log.Printf("cleaning preview: %s", err)
|
||||
}
|
||||
}
|
||||
@@ -905,16 +904,15 @@ func (nav *nav) preview(path string, win *win, mode string) {
|
||||
|
||||
defer func() {
|
||||
if err := cmd.Wait(); err != nil {
|
||||
var exitErr *exec.ExitError
|
||||
if errors.As(err, &exitErr) {
|
||||
if _, ok := errors.AsType[*exec.ExitError](err); ok {
|
||||
reg.volatile = true
|
||||
} else {
|
||||
log.Printf("loading file: %s", err)
|
||||
log.Printf("previewing file: %s", err)
|
||||
}
|
||||
}
|
||||
if s := strings.TrimSpace(stderr.String()); s != "" {
|
||||
s = strings.Join(strings.Fields(s), " ")
|
||||
log.Printf("loading file (stderr): %s", s)
|
||||
log.Printf("previewing file (stderr): %s", s)
|
||||
}
|
||||
}()
|
||||
defer out.Close()
|
||||
@@ -922,7 +920,7 @@ func (nav *nav) preview(path string, win *win, mode string) {
|
||||
} else {
|
||||
lstat, err := os.Lstat(path)
|
||||
if err != nil {
|
||||
log.Printf("lstat: %s", err)
|
||||
log.Printf("previewing file: %s", err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -932,7 +930,7 @@ func (nav *nav) preview(path string, win *win, mode string) {
|
||||
|
||||
f, err := os.Open(path)
|
||||
if err != nil {
|
||||
log.Printf("opening file: %s", err)
|
||||
log.Printf("previewing file: %s", err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1153,7 +1151,7 @@ func (nav *nav) open() error {
|
||||
}
|
||||
|
||||
if err := os.Chdir(curr.path); err != nil {
|
||||
return fmt.Errorf("open: %w", err)
|
||||
return err
|
||||
}
|
||||
|
||||
nav.dirPaths = append(nav.dirPaths, curr.path)
|
||||
@@ -1816,7 +1814,7 @@ func isFiltered(f os.FileInfo, filter []string) bool {
|
||||
for _, pattern := range filter {
|
||||
matched, err := searchMatch(f.Name(), strings.TrimPrefix(pattern, "!"), gOpts.filtermethod)
|
||||
if err != nil {
|
||||
log.Printf("Filter Error: %s", err)
|
||||
log.Printf("applying filter: %s", err)
|
||||
return false
|
||||
}
|
||||
if strings.HasPrefix(pattern, "!") && matched {
|
||||
@@ -2007,15 +2005,32 @@ func (nav *nav) currFileOrSelections() ([]string, error) {
|
||||
return nil, errors.New("no file selected")
|
||||
}
|
||||
|
||||
// calcSize returns the total size of the given directory. Symlinks pointing to
|
||||
// directories are resolved beforehand, since `copySize` does not follow them.
|
||||
func calcSize(f *file) (int64, error) {
|
||||
path := f.path
|
||||
if f.linkState == working {
|
||||
var err error
|
||||
path, err = filepath.EvalSymlinks(f.path)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
}
|
||||
|
||||
return copySize([]string{path})
|
||||
}
|
||||
|
||||
func (nav *nav) calcDirSize() error {
|
||||
calc := func(f *file) error {
|
||||
if f.IsDir() {
|
||||
total, err := copySize([]string{f.path})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
f.dirSize = total
|
||||
if !f.IsDir() {
|
||||
return nil
|
||||
}
|
||||
|
||||
total, err := calcSize(f)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
f.dirSize = total
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -2028,8 +2043,10 @@ func (nav *nav) calcDirSize() error {
|
||||
}
|
||||
|
||||
for sel := range nav.selections {
|
||||
lstat, err := os.Lstat(sel)
|
||||
if err != nil || !lstat.IsDir() {
|
||||
// `os.Stat` is used instead of `os.Lstat` so that symlinks pointing to
|
||||
// directories are not skipped.
|
||||
stat, err := os.Stat(sel)
|
||||
if err != nil || !stat.IsDir() {
|
||||
continue
|
||||
}
|
||||
path, name := filepath.Dir(sel), filepath.Base(sel)
|
||||
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestDirSize(t *testing.T) {
|
||||
tmp := t.TempDir()
|
||||
|
||||
dir := filepath.Join(tmp, "dir")
|
||||
if err := os.Mkdir(dir, 0o755); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := os.WriteFile(filepath.Join(dir, "file"), make([]byte, 4096), 0o644); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
link := filepath.Join(tmp, "link")
|
||||
if err := os.Symlink(dir, link); err != nil {
|
||||
t.Skipf("creating symlink: %s", err)
|
||||
}
|
||||
|
||||
expected, err := calcSize(newFile(dir))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
got, err := calcSize(newFile(link))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if got != expected {
|
||||
t.Errorf("at symlink to directory expected %d but got %d", expected, got)
|
||||
}
|
||||
}
|
||||
@@ -29,7 +29,7 @@ func serve() {
|
||||
if gLogPath != "" {
|
||||
f, err := os.OpenFile(gLogPath, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0o600)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to open log file: %s", err)
|
||||
log.Fatalf("opening log file: %s", err)
|
||||
}
|
||||
defer f.Close()
|
||||
log.SetOutput(f)
|
||||
@@ -73,37 +73,46 @@ func manage() {
|
||||
case "broadcast":
|
||||
for id, c2 := range connList {
|
||||
if _, err := fmt.Fprintln(c2, cmd.msg); err != nil {
|
||||
echoerrf(cmd.c, "failed to send command to client %v: %s", id, err)
|
||||
echoerrf(cmd.c, "sending command to client %v: %s", id, err)
|
||||
c2.Close()
|
||||
delete(connList, id)
|
||||
}
|
||||
}
|
||||
case "send":
|
||||
if c2, ok := connList[cmd.id]; ok {
|
||||
if _, err := fmt.Fprintln(c2, cmd.msg); err != nil {
|
||||
echoerrf(cmd.c, "failed to send command to client %v: %s", cmd.id, err)
|
||||
echoerrf(cmd.c, "sending command to client %v: %s", cmd.id, err)
|
||||
}
|
||||
} else {
|
||||
echoerr(cmd.c, "listen: send: no such client id is connected")
|
||||
echoerrf(cmd.c, "listen: send: no client with ID %v connected", cmd.id)
|
||||
}
|
||||
case "query":
|
||||
c2, ok := connList[cmd.id]
|
||||
if !ok {
|
||||
echoerr(cmd.c, "listen: query: no such client id is connected")
|
||||
echoerrf(cmd.c, "listen: query: no client with ID %v connected", cmd.id)
|
||||
break
|
||||
}
|
||||
if _, err := fmt.Fprintln(c2, "query "+cmd.msg); err != nil {
|
||||
echoerrf(cmd.c, "failed to send query to client %v: %s", cmd.id, err)
|
||||
echoerrf(cmd.c, "sending query to client %v: %s", cmd.id, err)
|
||||
break
|
||||
}
|
||||
s2 := bufio.NewScanner(c2)
|
||||
for s2.Scan() && s2.Text() != "" {
|
||||
if _, err := fmt.Fprintln(cmd.c, s2.Text()); err != nil {
|
||||
log.Printf("failed to forward query response from client %v: %s", cmd.id, err)
|
||||
log.Printf("forwarding query response from client %v: %s", cmd.id, err)
|
||||
}
|
||||
}
|
||||
if s2.Err() != nil {
|
||||
echoerrf(cmd.c, "failed to read query response from client %v: %s", cmd.id, s2.Err())
|
||||
echoerrf(cmd.c, "reading query response from client %v: %s", cmd.id, s2.Err())
|
||||
}
|
||||
case "quit":
|
||||
for id, c := range connList {
|
||||
// an empty line is ignored by clients and exposes dead connections
|
||||
if _, err := fmt.Fprintln(c, ""); err != nil {
|
||||
c.Close()
|
||||
delete(connList, id)
|
||||
}
|
||||
}
|
||||
if len(connList) == 0 {
|
||||
gQuitChan <- struct{}{}
|
||||
gListener.Close()
|
||||
@@ -171,25 +180,25 @@ Loop:
|
||||
word2, _ := splitWord(rest)
|
||||
id, err := strconv.Atoi(word2)
|
||||
if err != nil {
|
||||
echoerr(c, "listen: conn: client id should be a number")
|
||||
echoerr(c, "listen: conn: client ID must be a number")
|
||||
} else {
|
||||
send(srvCmd{op: "conn", id: id, c: c})
|
||||
return
|
||||
}
|
||||
} else {
|
||||
echoerr(c, "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")
|
||||
echoerr(c, "listen: drop: client ID must be a number")
|
||||
} else {
|
||||
send(srvCmd{op: "drop", id: id})
|
||||
}
|
||||
} else {
|
||||
echoerr(c, "listen: drop: requires a client id")
|
||||
echoerr(c, "listen: drop: requires a client ID")
|
||||
}
|
||||
case "list":
|
||||
send(srvCmd{op: "list", c: c})
|
||||
@@ -205,13 +214,13 @@ Loop:
|
||||
}
|
||||
case "query":
|
||||
if rest == "" {
|
||||
echoerr(c, "listen: query: requires a client id")
|
||||
echoerr(c, "listen: query: requires a client ID")
|
||||
break
|
||||
}
|
||||
word2, rest2 := splitWord(rest)
|
||||
id, err := strconv.Atoi(word2)
|
||||
if err != nil {
|
||||
echoerr(c, "listen: query: client id should be a number")
|
||||
echoerr(c, "listen: query: client ID must be a number")
|
||||
break
|
||||
}
|
||||
send(srvCmd{op: "query", id: id, msg: rest2, c: c})
|
||||
|
||||
+4
-4
@@ -200,7 +200,7 @@ loop:
|
||||
case "38":
|
||||
color, offset, err := parseColor(toks[i+1:])
|
||||
if err != nil {
|
||||
log.Printf("error processing ansi code 38: %s", err)
|
||||
log.Printf("processing ANSI code 38: %s", err)
|
||||
break loop
|
||||
}
|
||||
st = st.Foreground(color)
|
||||
@@ -214,7 +214,7 @@ loop:
|
||||
case "48":
|
||||
color, offset, err := parseColor(toks[i+1:])
|
||||
if err != nil {
|
||||
log.Printf("error processing ansi code 48: %s", err)
|
||||
log.Printf("processing ANSI code 48: %s", err)
|
||||
break loop
|
||||
}
|
||||
st = st.Background(color)
|
||||
@@ -222,13 +222,13 @@ loop:
|
||||
case "58":
|
||||
color, offset, err := parseColor(toks[i+1:])
|
||||
if err != nil {
|
||||
log.Printf("error processing ansi code 58: %s", err)
|
||||
log.Printf("processing ANSI code 58: %s", err)
|
||||
break loop
|
||||
}
|
||||
st = st.Underline(color)
|
||||
i += offset
|
||||
default:
|
||||
log.Printf("unknown ansi code: %s", toks[i])
|
||||
log.Printf("unknown ANSI code: %s", toks[i])
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -647,8 +647,9 @@ func (ui *ui) drawPromptLine(nav *nav) {
|
||||
dir := nav.currDir()
|
||||
pwd := sanitizeName(dir.path)
|
||||
|
||||
if after, ok := strings.CutPrefix(pwd, gUser.HomeDir); ok {
|
||||
pwd = filepath.Join("~", after)
|
||||
// shorten the home directory itself and paths inside
|
||||
if rel, err := filepath.Rel(gUser.HomeDir, pwd); err == nil && filepath.IsLocal(rel) {
|
||||
pwd = filepath.Join("~", rel)
|
||||
}
|
||||
|
||||
sep := string(filepath.Separator)
|
||||
@@ -660,7 +661,10 @@ func (ui *ui) drawPromptLine(nav *nav) {
|
||||
|
||||
var prompt string
|
||||
|
||||
prompt = strings.ReplaceAll(gOpts.promptfmt, "%u", gUser.Username)
|
||||
// git style colored prompts contain hidden bytes that lf would print as extra characters
|
||||
prompt = strings.ReplaceAll(gOpts.promptfmt, "\x01", "")
|
||||
prompt = strings.ReplaceAll(prompt, "\x02", "")
|
||||
prompt = strings.ReplaceAll(prompt, "%u", gUser.Username)
|
||||
prompt = strings.ReplaceAll(prompt, "%h", gHostname)
|
||||
prompt = strings.ReplaceAll(prompt, "%f", fname)
|
||||
|
||||
@@ -1349,7 +1353,7 @@ func listMarks(marks map[string]string) string {
|
||||
func listFilesInCurrDir(nav *nav) string {
|
||||
dir := nav.currDir()
|
||||
if dir.loading {
|
||||
log.Printf("listFilesInCurrDir(): %s is still loading, `files` isn't ready for remote query", dir.path)
|
||||
log.Printf("listFilesInCurrDir: directory contents not loaded yet: %q", dir.path)
|
||||
return ""
|
||||
}
|
||||
|
||||
@@ -1422,7 +1426,7 @@ func (ui *ui) readNormalEvent(ev tcell.Event, nav *nav) expr {
|
||||
expr := keys[ui.keyAcc]
|
||||
if ui.keyCount != "" {
|
||||
if count, err := strconv.Atoi(ui.keyCount); err != nil {
|
||||
log.Printf("converting command count: %s", err)
|
||||
log.Printf("parsing command count: %s", err)
|
||||
} else if count > 0 {
|
||||
switch e := expr.(type) {
|
||||
case *callExpr:
|
||||
@@ -1536,9 +1540,9 @@ func (ui *ui) readNormalEvent(ev tcell.Event, nav *nav) expr {
|
||||
case *tcell.EventResize:
|
||||
return &callExpr{"redraw", nil, 1}
|
||||
case *tcell.EventError:
|
||||
log.Printf("Got EventError: '%s' at %s", tev.Error(), tev.When())
|
||||
log.Printf("event error: %q at %s", tev.Error(), tev.When())
|
||||
case *tcell.EventInterrupt:
|
||||
log.Printf("Got EventInterrupt: at %s", tev.When())
|
||||
log.Printf("event interrupt at %s", tev.When())
|
||||
case *tcell.EventFocus:
|
||||
if tev.Focused {
|
||||
return &callExpr{"on-focus-gained", nil, 1}
|
||||
@@ -1616,7 +1620,7 @@ func anyKey() {
|
||||
|
||||
b := make([]byte, 8)
|
||||
if _, err := os.Stdin.Read(b); err != nil {
|
||||
log.Printf("Failed to read key press: %s", err)
|
||||
log.Printf("reading key press: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ func (watch *watch) start() {
|
||||
|
||||
watcher, err := fsnotify.NewWatcher()
|
||||
if err != nil {
|
||||
log.Printf("start watcher: %s", err)
|
||||
log.Printf("starting watcher: %s", err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ func (watch *watch) add(path string) {
|
||||
}
|
||||
|
||||
if err := watch.watcher.Add(path); err != nil {
|
||||
log.Printf("watch path %s: %s", path, err)
|
||||
log.Printf("watching path %s: %s", path, err)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user