Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
[](https://travis-ci.org/gokcehan/lf)
|
[](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 +62,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{
|
||||||
@@ -160,6 +155,8 @@ 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() {
|
||||||
|
go app.nav.previewLoop(app.ui)
|
||||||
|
|
||||||
serverChan := readExpr()
|
serverChan := readExpr()
|
||||||
|
|
||||||
app.ui.readExpr()
|
app.ui.readExpr()
|
||||||
@@ -177,11 +174,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))
|
||||||
@@ -366,21 +371,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,8 +396,17 @@ 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.writeHistory()
|
||||||
|
os.Remove(gLogPath)
|
||||||
|
os.Exit(3)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}()
|
||||||
defer app.nav.renew()
|
defer app.nav.renew()
|
||||||
|
|
||||||
err = cmd.Run()
|
err = cmd.Run()
|
||||||
@@ -433,9 +433,7 @@ 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)
|
||||||
|
|||||||
@@ -21,7 +21,9 @@ 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 {
|
||||||
@@ -33,7 +35,9 @@ func run() {
|
|||||||
|
|
||||||
log.Print("hi!")
|
log.Print("hi!")
|
||||||
|
|
||||||
app := newApp(screen)
|
ui := newUI(screen)
|
||||||
|
nav := newNav(ui.wins[0].h)
|
||||||
|
app := newApp(ui, nav)
|
||||||
|
|
||||||
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 +47,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()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+13
-2
@@ -97,6 +97,9 @@ var (
|
|||||||
"incsearch",
|
"incsearch",
|
||||||
"noincsearch",
|
"noincsearch",
|
||||||
"incsearch!",
|
"incsearch!",
|
||||||
|
"mouse",
|
||||||
|
"nomouse",
|
||||||
|
"mouse!",
|
||||||
"number",
|
"number",
|
||||||
"nonumber",
|
"nonumber",
|
||||||
"number!",
|
"number!",
|
||||||
@@ -115,6 +118,7 @@ var (
|
|||||||
"smartdia",
|
"smartdia",
|
||||||
"nosmartdia",
|
"nosmartdia",
|
||||||
"smartdia!",
|
"smartdia!",
|
||||||
|
"waitmsg",
|
||||||
"wrapscan",
|
"wrapscan",
|
||||||
"nowrapscan",
|
"nowrapscan",
|
||||||
"wrapscan!",
|
"wrapscan!",
|
||||||
@@ -135,6 +139,7 @@ var (
|
|||||||
"promptfmt",
|
"promptfmt",
|
||||||
"ratios",
|
"ratios",
|
||||||
"shell",
|
"shell",
|
||||||
|
"shellflag",
|
||||||
"shellopts",
|
"shellopts",
|
||||||
"sortby",
|
"sortby",
|
||||||
"timefmt",
|
"timefmt",
|
||||||
@@ -243,18 +248,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.
|
||||||
|
|
||||||
@@ -114,6 +113,7 @@ The following options can be used to customize the behavior of lf:
|
|||||||
ignoredia bool (default on)
|
ignoredia bool (default on)
|
||||||
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 +125,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 +133,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 +143,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
|
||||||
@@ -569,6 +573,10 @@ 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.
|
||||||
@@ -635,9 +643,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 +680,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 +713,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.
|
||||||
@@ -1028,8 +1050,8 @@ 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.
|
||||||
@@ -1158,7 +1180,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 +1190,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'.
|
||||||
|
|||||||
+33
-14
@@ -117,6 +117,7 @@ The following options can be used to customize the behavior of lf:
|
|||||||
ignoredia bool (default on)
|
ignoredia bool (default on)
|
||||||
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 +129,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 +137,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 +147,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
|
||||||
@@ -600,6 +605,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
|
||||||
@@ -678,10 +687,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 +727,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 +765,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
|
||||||
@@ -1132,8 +1155,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
|
||||||
@@ -1293,7 +1316,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 +1329,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
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
+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 -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)'
|
||||||
|
|||||||
@@ -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)')
|
||||||
@@ -18,6 +19,7 @@ Register-ArgumentCompleter -Native -CommandName 'lf' -ScriptBlock {
|
|||||||
[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('-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)]'
|
||||||
@@ -22,6 +23,7 @@ arguments=(
|
|||||||
'-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)]'
|
||||||
'-version[show version]'
|
'-version[show version]'
|
||||||
|
'-help[show help]'
|
||||||
'*:filename:_files'
|
'*:filename:_files'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
+1
-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
|
||||||
|
|||||||
@@ -110,6 +110,24 @@ func (e *setExpr) eval(app *app, args []string) {
|
|||||||
gOpts.incsearch = false
|
gOpts.incsearch = false
|
||||||
case "incsearch!":
|
case "incsearch!":
|
||||||
gOpts.incsearch = !gOpts.incsearch
|
gOpts.incsearch = !gOpts.incsearch
|
||||||
|
case "mouse":
|
||||||
|
if !gOpts.mouse {
|
||||||
|
gOpts.mouse = true
|
||||||
|
app.ui.screen.EnableMouse()
|
||||||
|
}
|
||||||
|
case "nomouse":
|
||||||
|
if gOpts.mouse {
|
||||||
|
gOpts.mouse = false
|
||||||
|
app.ui.screen.DisableMouse()
|
||||||
|
}
|
||||||
|
case "mouse!":
|
||||||
|
if gOpts.mouse {
|
||||||
|
gOpts.mouse = false
|
||||||
|
app.ui.screen.DisableMouse()
|
||||||
|
} else {
|
||||||
|
gOpts.mouse = true
|
||||||
|
app.ui.screen.EnableMouse()
|
||||||
|
}
|
||||||
case "number":
|
case "number":
|
||||||
gOpts.number = true
|
gOpts.number = true
|
||||||
case "nonumber":
|
case "nonumber":
|
||||||
@@ -160,6 +178,8 @@ func (e *setExpr) eval(app *app, args []string) {
|
|||||||
gOpts.smartdia = false
|
gOpts.smartdia = false
|
||||||
case "smartdia!":
|
case "smartdia!":
|
||||||
gOpts.smartdia = !gOpts.smartdia
|
gOpts.smartdia = !gOpts.smartdia
|
||||||
|
case "waitmsg":
|
||||||
|
gOpts.waitmsg = e.val
|
||||||
case "wrapscan":
|
case "wrapscan":
|
||||||
gOpts.wrapscan = true
|
gOpts.wrapscan = true
|
||||||
case "nowrapscan":
|
case "nowrapscan":
|
||||||
@@ -291,7 +311,13 @@ func (e *setExpr) eval(app *app, args []string) {
|
|||||||
app.ui.loadFile(app.nav, true)
|
app.ui.loadFile(app.nav, true)
|
||||||
case "shell":
|
case "shell":
|
||||||
gOpts.shell = e.val
|
gOpts.shell = e.val
|
||||||
|
case "shellflag":
|
||||||
|
gOpts.shellflag = e.val
|
||||||
case "shellopts":
|
case "shellopts":
|
||||||
|
if e.val == "" {
|
||||||
|
gOpts.shellopts = nil
|
||||||
|
return
|
||||||
|
}
|
||||||
gOpts.shellopts = strings.Split(e.val, ":")
|
gOpts.shellopts = strings.Split(e.val, ":")
|
||||||
case "sortby":
|
case "sortby":
|
||||||
switch e.val {
|
switch e.val {
|
||||||
@@ -393,31 +419,31 @@ func update(app *app) {
|
|||||||
app.nav.search = string(app.ui.cmdAccLeft) + string(app.ui.cmdAccRight)
|
app.nav.search = string(app.ui.cmdAccLeft) + string(app.ui.cmdAccRight)
|
||||||
|
|
||||||
dir := app.nav.currDir()
|
dir := app.nav.currDir()
|
||||||
|
old := dir.ind
|
||||||
dir.ind = app.nav.searchInd
|
dir.ind = app.nav.searchInd
|
||||||
dir.pos = app.nav.searchPos
|
dir.pos = app.nav.searchPos
|
||||||
|
|
||||||
if err := app.nav.searchNext(); err != nil {
|
if _, err := app.nav.searchNext(); err != nil {
|
||||||
app.ui.echoerrf("search: %s: %s", err, app.nav.search)
|
app.ui.echoerrf("search: %s: %s", err, app.nav.search)
|
||||||
return
|
} else if old != dir.ind {
|
||||||
}
|
|
||||||
|
|
||||||
app.ui.loadFile(app.nav, true)
|
app.ui.loadFile(app.nav, true)
|
||||||
app.ui.loadFileInfo(app.nav)
|
app.ui.loadFileInfo(app.nav)
|
||||||
|
}
|
||||||
case gOpts.incsearch && app.ui.cmdPrefix == "?":
|
case gOpts.incsearch && app.ui.cmdPrefix == "?":
|
||||||
app.nav.search = string(app.ui.cmdAccLeft) + string(app.ui.cmdAccRight)
|
app.nav.search = string(app.ui.cmdAccLeft) + string(app.ui.cmdAccRight)
|
||||||
|
|
||||||
dir := app.nav.currDir()
|
dir := app.nav.currDir()
|
||||||
|
old := dir.ind
|
||||||
dir.ind = app.nav.searchInd
|
dir.ind = app.nav.searchInd
|
||||||
dir.pos = app.nav.searchPos
|
dir.pos = app.nav.searchPos
|
||||||
|
|
||||||
if err := app.nav.searchPrev(); err != nil {
|
if _, err := app.nav.searchPrev(); err != nil {
|
||||||
app.ui.echoerrf("search: %s: %s", err, app.nav.search)
|
app.ui.echoerrf("search: %s: %s", err, app.nav.search)
|
||||||
return
|
} else if old != dir.ind {
|
||||||
}
|
|
||||||
|
|
||||||
app.ui.loadFile(app.nav, true)
|
app.ui.loadFile(app.nav, true)
|
||||||
app.ui.loadFileInfo(app.nav)
|
app.ui.loadFileInfo(app.nav)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func normal(app *app) {
|
func normal(app *app) {
|
||||||
@@ -455,9 +481,9 @@ func insert(app *app, arg string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if !app.nav.findNext() {
|
if moved, found := app.nav.findNext(); !found {
|
||||||
app.ui.echoerrf("find: pattern not found: %s", app.nav.find)
|
app.ui.echoerrf("find: pattern not found: %s", app.nav.find)
|
||||||
} else {
|
} else if moved {
|
||||||
app.ui.loadFile(app.nav, true)
|
app.ui.loadFile(app.nav, true)
|
||||||
app.ui.loadFileInfo(app.nav)
|
app.ui.loadFileInfo(app.nav)
|
||||||
}
|
}
|
||||||
@@ -484,9 +510,9 @@ func insert(app *app, arg string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if !app.nav.findPrev() {
|
if moved, found := app.nav.findPrev(); !found {
|
||||||
app.ui.echoerrf("find-back: pattern not found: %s", app.nav.find)
|
app.ui.echoerrf("find-back: pattern not found: %s", app.nav.find)
|
||||||
} else {
|
} else if moved {
|
||||||
app.ui.loadFile(app.nav, true)
|
app.ui.loadFile(app.nav, true)
|
||||||
app.ui.loadFileInfo(app.nav)
|
app.ui.loadFileInfo(app.nav)
|
||||||
}
|
}
|
||||||
@@ -854,6 +880,8 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
app.nav.findBack = true
|
app.nav.findBack = true
|
||||||
app.ui.loadFileInfo(app.nav)
|
app.ui.loadFileInfo(app.nav)
|
||||||
case "find-next":
|
case "find-next":
|
||||||
|
dir := app.nav.currDir()
|
||||||
|
old := dir.ind
|
||||||
for i := 0; i < e.count; i++ {
|
for i := 0; i < e.count; i++ {
|
||||||
if app.nav.findBack {
|
if app.nav.findBack {
|
||||||
app.nav.findPrev()
|
app.nav.findPrev()
|
||||||
@@ -861,9 +889,13 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
app.nav.findNext()
|
app.nav.findNext()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if old != dir.ind {
|
||||||
app.ui.loadFile(app.nav, true)
|
app.ui.loadFile(app.nav, true)
|
||||||
app.ui.loadFileInfo(app.nav)
|
app.ui.loadFileInfo(app.nav)
|
||||||
|
}
|
||||||
case "find-prev":
|
case "find-prev":
|
||||||
|
dir := app.nav.currDir()
|
||||||
|
old := dir.ind
|
||||||
for i := 0; i < e.count; i++ {
|
for i := 0; i < e.count; i++ {
|
||||||
if app.nav.findBack {
|
if app.nav.findBack {
|
||||||
app.nav.findNext()
|
app.nav.findNext()
|
||||||
@@ -871,8 +903,10 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
app.nav.findPrev()
|
app.nav.findPrev()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if old != dir.ind {
|
||||||
app.ui.loadFile(app.nav, true)
|
app.ui.loadFile(app.nav, true)
|
||||||
app.ui.loadFileInfo(app.nav)
|
app.ui.loadFileInfo(app.nav)
|
||||||
|
}
|
||||||
case "search":
|
case "search":
|
||||||
app.ui.cmdPrefix = "/"
|
app.ui.cmdPrefix = "/"
|
||||||
dir := app.nav.currDir()
|
dir := app.nav.currDir()
|
||||||
@@ -890,35 +924,39 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
case "search-next":
|
case "search-next":
|
||||||
for i := 0; i < e.count; i++ {
|
for i := 0; i < e.count; i++ {
|
||||||
if app.nav.searchBack {
|
if app.nav.searchBack {
|
||||||
if err := app.nav.searchPrev(); err != nil {
|
if moved, err := app.nav.searchPrev(); err != nil {
|
||||||
app.ui.echoerrf("search-back: %s: %s", err, app.nav.search)
|
app.ui.echoerrf("search-back: %s: %s", err, app.nav.search)
|
||||||
return
|
} else if moved {
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if err := app.nav.searchNext(); err != nil {
|
|
||||||
app.ui.echoerrf("search: %s: %s", err, app.nav.search)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
app.ui.loadFile(app.nav, true)
|
app.ui.loadFile(app.nav, true)
|
||||||
app.ui.loadFileInfo(app.nav)
|
app.ui.loadFileInfo(app.nav)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if moved, err := app.nav.searchNext(); err != nil {
|
||||||
|
app.ui.echoerrf("search: %s: %s", err, app.nav.search)
|
||||||
|
} else if moved {
|
||||||
|
app.ui.loadFile(app.nav, true)
|
||||||
|
app.ui.loadFileInfo(app.nav)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
case "search-prev":
|
case "search-prev":
|
||||||
for i := 0; i < e.count; i++ {
|
for i := 0; i < e.count; i++ {
|
||||||
if app.nav.searchBack {
|
if app.nav.searchBack {
|
||||||
if err := app.nav.searchNext(); err != nil {
|
if moved, err := app.nav.searchNext(); err != nil {
|
||||||
app.ui.echoerrf("search-back: %s: %s", err, app.nav.search)
|
app.ui.echoerrf("search-back: %s: %s", err, app.nav.search)
|
||||||
return
|
} else if moved {
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if err := app.nav.searchPrev(); err != nil {
|
|
||||||
app.ui.echoerrf("search: %s: %s", err, app.nav.search)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
app.ui.loadFile(app.nav, true)
|
app.ui.loadFile(app.nav, true)
|
||||||
app.ui.loadFileInfo(app.nav)
|
app.ui.loadFileInfo(app.nav)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if moved, err := app.nav.searchPrev(); err != nil {
|
||||||
|
app.ui.echoerrf("search: %s: %s", err, app.nav.search)
|
||||||
|
} else if moved {
|
||||||
|
app.ui.loadFile(app.nav, true)
|
||||||
|
app.ui.loadFileInfo(app.nav)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
case "mark-save":
|
case "mark-save":
|
||||||
app.ui.cmdPrefix = "mark-save: "
|
app.ui.cmdPrefix = "mark-save: "
|
||||||
case "mark-load":
|
case "mark-load":
|
||||||
@@ -1067,12 +1105,13 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
}
|
}
|
||||||
if gOpts.incsearch && (app.ui.cmdPrefix == "/" || app.ui.cmdPrefix == "?") {
|
if gOpts.incsearch && (app.ui.cmdPrefix == "/" || app.ui.cmdPrefix == "?") {
|
||||||
dir := app.nav.currDir()
|
dir := app.nav.currDir()
|
||||||
dir.ind = app.nav.searchInd
|
|
||||||
dir.pos = app.nav.searchPos
|
dir.pos = app.nav.searchPos
|
||||||
|
if dir.ind != app.nav.searchInd {
|
||||||
|
dir.ind = app.nav.searchInd
|
||||||
app.ui.loadFile(app.nav, true)
|
app.ui.loadFile(app.nav, true)
|
||||||
app.ui.loadFileInfo(app.nav)
|
app.ui.loadFileInfo(app.nav)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
normal(app)
|
normal(app)
|
||||||
case "cmd-complete":
|
case "cmd-complete":
|
||||||
var matches []string
|
var matches []string
|
||||||
@@ -1235,32 +1274,50 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
app.cmdHistory = append(app.cmdHistory, cmdItem{"&", s})
|
app.cmdHistory = append(app.cmdHistory, cmdItem{"&", s})
|
||||||
app.runShell(s, nil, "&")
|
app.runShell(s, nil, "&")
|
||||||
case "/":
|
case "/":
|
||||||
if gOpts.incsearch {
|
|
||||||
dir := app.nav.currDir()
|
dir := app.nav.currDir()
|
||||||
|
old := dir.ind
|
||||||
|
if gOpts.incsearch {
|
||||||
dir.ind = app.nav.searchInd
|
dir.ind = app.nav.searchInd
|
||||||
dir.pos = app.nav.searchPos
|
dir.pos = app.nav.searchPos
|
||||||
}
|
}
|
||||||
log.Printf("search: %s", s)
|
log.Printf("search: %s", s)
|
||||||
app.ui.cmdPrefix = ""
|
app.ui.cmdPrefix = ""
|
||||||
app.nav.search = s
|
app.nav.search = s
|
||||||
if err := app.nav.searchNext(); err != nil {
|
if _, err := app.nav.searchNext(); err != nil {
|
||||||
app.ui.echoerrf("search: %s: %s", err, app.nav.search)
|
app.ui.echoerrf("search: %s: %s", err, app.nav.search)
|
||||||
} else {
|
} else if old != dir.ind {
|
||||||
app.ui.loadFile(app.nav, true)
|
app.ui.loadFile(app.nav, true)
|
||||||
app.ui.loadFileInfo(app.nav)
|
app.ui.loadFileInfo(app.nav)
|
||||||
}
|
}
|
||||||
case "?":
|
case "?":
|
||||||
if gOpts.incsearch {
|
|
||||||
dir := app.nav.currDir()
|
dir := app.nav.currDir()
|
||||||
|
old := dir.ind
|
||||||
|
if gOpts.incsearch {
|
||||||
dir.ind = app.nav.searchInd
|
dir.ind = app.nav.searchInd
|
||||||
dir.pos = app.nav.searchPos
|
dir.pos = app.nav.searchPos
|
||||||
}
|
}
|
||||||
log.Printf("search-back: %s", s)
|
log.Printf("search-back: %s", s)
|
||||||
app.ui.cmdPrefix = ""
|
app.ui.cmdPrefix = ""
|
||||||
app.nav.search = s
|
app.nav.search = s
|
||||||
if err := app.nav.searchPrev(); err != nil {
|
if _, err := app.nav.searchPrev(); err != nil {
|
||||||
app.ui.echoerrf("search-back: %s: %s", err, app.nav.search)
|
app.ui.echoerrf("search-back: %s: %s", err, app.nav.search)
|
||||||
} else {
|
} else if old != dir.ind {
|
||||||
|
app.ui.loadFile(app.nav, true)
|
||||||
|
app.ui.loadFileInfo(app.nav)
|
||||||
|
}
|
||||||
|
case "find: ":
|
||||||
|
app.ui.cmdPrefix = ""
|
||||||
|
if moved, found := app.nav.findNext(); !found {
|
||||||
|
app.ui.echoerrf("find: pattern not found: %s", app.nav.find)
|
||||||
|
} else if moved {
|
||||||
|
app.ui.loadFile(app.nav, true)
|
||||||
|
app.ui.loadFileInfo(app.nav)
|
||||||
|
}
|
||||||
|
case "find-back: ":
|
||||||
|
app.ui.cmdPrefix = ""
|
||||||
|
if moved, found := app.nav.findPrev(); !found {
|
||||||
|
app.ui.echoerrf("find-back: pattern not found: %s", app.nav.find)
|
||||||
|
} else if moved {
|
||||||
app.ui.loadFile(app.nav, true)
|
app.ui.loadFile(app.nav, true)
|
||||||
app.ui.loadFileInfo(app.nav)
|
app.ui.loadFileInfo(app.nav)
|
||||||
}
|
}
|
||||||
@@ -1295,13 +1352,13 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
oldStat, err := os.Stat(oldPath)
|
oldStat, err := os.Lstat(oldPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
app.ui.echoerrf("rename: %s", err)
|
app.ui.echoerrf("rename: %s", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if newStat, err := os.Stat(newPath); !os.IsNotExist(err) && !os.SameFile(oldStat, newStat) {
|
if newStat, err := os.Lstat(newPath); !os.IsNotExist(err) && !os.SameFile(oldStat, newStat) {
|
||||||
app.ui.cmdPrefix = "replace '" + newPath + "' ? [y/N] "
|
app.ui.cmdPrefix = "replace '" + newPath + "' ? [y/N] "
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -31,6 +33,7 @@ lf \- terminal file manager
|
|||||||
.OP \-selection-path path
|
.OP \-selection-path path
|
||||||
.OP \-server
|
.OP \-server
|
||||||
.OP \-version
|
.OP \-version
|
||||||
|
.OP \-help
|
||||||
.RI [ directory ]
|
.RI [ directory ]
|
||||||
.YS
|
.YS
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
|
|||||||
@@ -3,7 +3,10 @@ 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.2.0
|
||||||
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
|
||||||
)
|
)
|
||||||
|
|
||||||
|
replace github.com/gdamore/tcell/v2 => github.com/gokcehan/tcell/v2 v2.2.1-0.20210329222449-4dd2d52e83ef
|
||||||
@@ -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/gokcehan/tcell/v2 v2.2.1-0.20210329222449-4dd2d52e83ef h1:I2KyR549rTlwGBHe2uwZHGNNeAIHUpwIs6V522yK+SE=
|
||||||
github.com/gdamore/tcell/v2 v2.0.0/go.mod h1:vSVL/GV5mCSlPC6thFP5kfOFdM9MGZcalipmpTxTgQA=
|
github.com/gokcehan/tcell/v2 v2.2.1-0.20210329222449-4dd2d52e83ef/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
|
||||||
@@ -12,6 +14,7 @@ lf \- terminal file manager
|
|||||||
.OP \-selection-path path
|
.OP \-selection-path path
|
||||||
.OP \-server
|
.OP \-server
|
||||||
.OP \-version
|
.OP \-version
|
||||||
|
.OP \-help
|
||||||
.RI [ directory ]
|
.RI [ directory ]
|
||||||
.YS
|
.YS
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
@@ -128,6 +131,7 @@ The following options can be used to customize the behavior of lf:
|
|||||||
ignoredia bool (default on)
|
ignoredia bool (default on)
|
||||||
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 +143,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 +151,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 +163,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
|
||||||
@@ -691,6 +699,12 @@ Jump to the first match after each keystroke during searching.
|
|||||||
.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
|
||||||
@@ -755,7 +769,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 +819,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 +863,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
|
||||||
@@ -1183,7 +1221,7 @@ There is a 'quit' command to close client connections and quit the server:
|
|||||||
.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 memory. The actual file copying takes place when you 'paste'. Similarly 'paste' after a 'cut' operation moves the file.
|
||||||
.PP
|
.PP
|
||||||
@@ -1285,22 +1323,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.
|
||||||
|
|||||||
@@ -31,6 +31,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 +65,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 +194,16 @@ 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)")
|
||||||
|
|
||||||
|
remoteCmd := flag.String(
|
||||||
|
"remote",
|
||||||
|
"",
|
||||||
|
"send remote command to server")
|
||||||
|
|
||||||
cpuprofile := flag.String(
|
cpuprofile := flag.String(
|
||||||
"cpuprofile",
|
"cpuprofile",
|
||||||
"",
|
"",
|
||||||
@@ -217,6 +224,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")
|
||||||
|
|||||||
@@ -824,7 +824,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)
|
||||||
@@ -1123,42 +1123,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 +1178,46 @@ 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 {
|
||||||
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
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return false, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (nav *nav) removeMark(mark string) error {
|
func (nav *nav) removeMark(mark string) error {
|
||||||
|
|||||||
@@ -36,11 +36,13 @@ var gOpts struct {
|
|||||||
ignorecase bool
|
ignorecase bool
|
||||||
ignoredia bool
|
ignoredia 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 +56,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
|
||||||
@@ -75,11 +78,13 @@ func init() {
|
|||||||
gOpts.ignorecase = true
|
gOpts.ignorecase = true
|
||||||
gOpts.ignoredia = true
|
gOpts.ignoredia = true
|
||||||
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 +98,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
|
||||||
)
|
)
|
||||||
@@ -94,24 +95,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 +134,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 +178,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)
|
||||||
|
|||||||
+16
-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"
|
||||||
)
|
)
|
||||||
@@ -76,12 +77,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 +118,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 +145,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)
|
||||||
|
|||||||
@@ -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 {
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -211,7 +212,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 +245,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) {
|
||||||
@@ -660,7 +661,15 @@ 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) {
|
||||||
@@ -721,6 +730,30 @@ 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))
|
||||||
|
}
|
||||||
|
|
||||||
var progress string
|
var progress string
|
||||||
|
|
||||||
if nav.copyTotal > 0 {
|
if nav.copyTotal > 0 {
|
||||||
@@ -736,7 +769,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)
|
||||||
}
|
}
|
||||||
@@ -1051,11 +1084,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 +1144,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)
|
func anyKey() {
|
||||||
} else if err = screen.Init(); err != nil {
|
fmt.Print(gOpts.waitmsg)
|
||||||
log.Fatalf("initializing screen: %s", err)
|
defer fmt.Print("\n")
|
||||||
|
oldState, err := term.MakeRaw(int(os.Stdin.Fd()))
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
}
|
}
|
||||||
screen.EnableMouse()
|
defer term.Restore(int(os.Stdin.Fd()), oldState)
|
||||||
|
|
||||||
ui.screen = screen
|
b := make([]byte, 1)
|
||||||
|
os.Stdin.Read(b)
|
||||||
go ui.pollEvents()
|
|
||||||
|
|
||||||
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