Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1b71c33afd | ||
|
|
f01fab6257 | ||
|
|
85aa3b9dc6 | ||
|
|
5566f82596 | ||
|
|
0edf0823b7 | ||
|
|
05a48ea315 | ||
|
|
ff0933ca03 | ||
|
|
6c46b217af | ||
|
|
bdd1747e43 | ||
|
|
ee5b3f4813 | ||
|
|
75eba115d2 | ||
|
|
8adbd2b9ef | ||
|
|
55b9189713 | ||
|
|
b763c30cc5 | ||
|
|
61489ad00b | ||
|
|
1ff3910c70 | ||
|
|
1966a30deb | ||
|
|
50e3a6856e | ||
|
|
9885c4be7a | ||
|
|
29aa77aa27 | ||
|
|
6e9f53f4bb | ||
|
|
099cccdcb5 | ||
|
|
4220868cc7 |
No files matched your search
@@ -0,0 +1,25 @@
|
||||
name: Go
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
|
||||
jobs:
|
||||
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: 1.15
|
||||
|
||||
- name: Build
|
||||
run: go build -v ./...
|
||||
|
||||
- name: Test
|
||||
run: go test -v ./...
|
||||
@@ -0,0 +1,28 @@
|
||||
name: Release
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- '*'
|
||||
|
||||
jobs:
|
||||
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: 1.15
|
||||
|
||||
- name: Build
|
||||
run: gen/xbuild.sh
|
||||
|
||||
- name: Release
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
files: dist/*
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
-19
@@ -1,19 +0,0 @@
|
||||
language: go
|
||||
|
||||
go:
|
||||
- 1.15.x
|
||||
|
||||
before_deploy:
|
||||
- gen/xbuild.sh
|
||||
|
||||
deploy:
|
||||
provider: releases
|
||||
api_key:
|
||||
secure: RdZAOPWooYq73iFQIjqe9+Awr7oA8m0j0tn1tUUfLjP+PGYpuz2lf1SHW/UjPcxySFkkBxnNPC1xgqmxekmvZadBaQbApqko4e47zCF0Pe91QG9OcDFaiJUWb7wcg+UDLoS0lJq8mcKYoi6bV76syOk0gBunLUmuYYpz/hR4lbalfq5//fD6sOOJ9cJPjeuG7LwYqbyw/8VwQWpiWgK9Sb5gu7+ZBgXkLG+/5OSHW8yNHGmtkw5sjMr4jQnNt2ixXVe5OdQ14mvRx0n4vlnzjNjmY6cPjEeqAc9eniOJ5o99k1OnR3H5kmNgI749q+VAkdu/uJfHiLXL1zerReb4SSTU+tTw9c7JYTcjBHlCT11CHlksVu55hHAbFvPkIpLfoRvdqrcjUyEHiCI/HbWiHhsQ+Gve+tpIcgu/aAC2TEsQ+vmmaXbOFcUsG77XP8gn1y+Spkyzou7tUvypIXduDSKFIvI51HYK2F5t5ttG6zJw9lpmmuoUWvCvbGvdAW893O6ef+iZvBoZYRjdeWvIqh/no2gWi1CRa4ZPSZWkn9NoE/2koaCQkrx9RHmEeLIukZVAT6ZViwvhMAOrvXQdKTDwbQ3ovMdtDvGcvjGz9k5xwnWrIcF7MV7nf7sj/JlcX2tulevcSLsYeBvcuTUFzy90erMy70MS01wp0I/IgpY=
|
||||
skip_cleanup: true
|
||||
file_glob: true
|
||||
file: dist/*
|
||||
name: $TRAVIS_TAG
|
||||
on:
|
||||
tags: true
|
||||
repo: gokcehan/lf
|
||||
@@ -5,7 +5,6 @@
|
||||
| [#lf](https://webchat.freenode.net/?channels=lf) (on Freenode)
|
||||
| [#lf:matrix.org](https://matrix.to/#/#lf:matrix.org) (with IRC bridge)
|
||||
|
||||
[](https://travis-ci.org/gokcehan/lf)
|
||||
[](https://goreportcard.com/report/github.com/gokcehan/lf)
|
||||
[](https://pkg.go.dev/github.com/gokcehan/lf)
|
||||
|
||||
|
||||
@@ -137,6 +137,10 @@ func loadFiles() (list []string, cp bool, err error) {
|
||||
}
|
||||
|
||||
func saveFiles(list []string, cp bool) error {
|
||||
if err := os.MkdirAll(filepath.Dir(gFilesPath), os.ModePerm); err != nil {
|
||||
return fmt.Errorf("creating data directory: %s", err)
|
||||
}
|
||||
|
||||
files, err := os.Create(gFilesPath)
|
||||
if err != nil {
|
||||
return fmt.Errorf("opening file selections file: %s", err)
|
||||
@@ -368,13 +372,15 @@ func (app *app) loop() {
|
||||
case d := <-app.nav.dirChan:
|
||||
app.nav.checkDir(d)
|
||||
|
||||
prev, ok := app.nav.dirCache[d.path]
|
||||
if ok {
|
||||
d.ind = prev.ind
|
||||
d.sel(prev.name(), app.nav.height)
|
||||
}
|
||||
if gOpts.dircache {
|
||||
prev, ok := app.nav.dirCache[d.path]
|
||||
if ok {
|
||||
d.ind = prev.ind
|
||||
d.sel(prev.name(), app.nav.height)
|
||||
}
|
||||
|
||||
app.nav.dirCache[d.path] = d
|
||||
app.nav.dirCache[d.path] = d
|
||||
}
|
||||
|
||||
for i := range app.nav.dirs {
|
||||
if app.nav.dirs[i].path == d.path {
|
||||
@@ -489,6 +495,9 @@ func (app *app) runShell(s string, args []string, prefix string) {
|
||||
|
||||
err = cmd.Run()
|
||||
case "%":
|
||||
if app.ui.cmdPrefix == ">" {
|
||||
return
|
||||
}
|
||||
stdin, err := cmd.StdinPipe()
|
||||
if err != nil {
|
||||
log.Printf("writing stdin: %s", err)
|
||||
@@ -518,6 +527,7 @@ func (app *app) runShell(s string, args []string, prefix string) {
|
||||
|
||||
switch prefix {
|
||||
case "%":
|
||||
normal(app)
|
||||
app.cmd = cmd
|
||||
app.cmdOutBuf = nil
|
||||
app.ui.msg = ""
|
||||
|
||||
+11
@@ -48,6 +48,8 @@ var (
|
||||
"search-back",
|
||||
"search-next",
|
||||
"search-prev",
|
||||
"filter",
|
||||
"setfilter",
|
||||
"mark-save",
|
||||
"mark-remove",
|
||||
"mark-load",
|
||||
@@ -73,12 +75,18 @@ var (
|
||||
"autoquit",
|
||||
"noautoquit",
|
||||
"autoquit!",
|
||||
"dircache",
|
||||
"nodircache",
|
||||
"dircache!",
|
||||
"dircounts",
|
||||
"nodircounts",
|
||||
"dircounts!",
|
||||
"dirfirst",
|
||||
"nodirfirst",
|
||||
"dirfirst!",
|
||||
"dironly",
|
||||
"nodironly",
|
||||
"dironly!",
|
||||
"drawbox",
|
||||
"nodrawbox",
|
||||
"drawbox!",
|
||||
@@ -100,6 +108,9 @@ var (
|
||||
"incsearch",
|
||||
"noincsearch",
|
||||
"incsearch!",
|
||||
"incfilter",
|
||||
"noincfilter",
|
||||
"incfilter!",
|
||||
"mouse",
|
||||
"nomouse",
|
||||
"mouse!",
|
||||
|
||||
@@ -62,6 +62,8 @@ The following commands are provided by lf:
|
||||
search-back (modal) (default '?')
|
||||
search-next (default 'n')
|
||||
search-prev (default 'N')
|
||||
filter (modal)
|
||||
setfilter
|
||||
mark-save (modal) (default 'm')
|
||||
mark-load (modal) (default "'")
|
||||
mark-remove (modal) (default `"`)
|
||||
@@ -99,8 +101,10 @@ The following options can be used to customize the behavior of lf:
|
||||
|
||||
anchorfind bool (default on)
|
||||
autoquit bool (default off)
|
||||
dircache bool (default on)
|
||||
dircounts bool (default off)
|
||||
dirfirst bool (default on)
|
||||
dironly bool (default off)
|
||||
drawbox bool (default off)
|
||||
errorfmt string (default "\033[7;31;47m%s\033[0m")
|
||||
filesep string (default "\n")
|
||||
@@ -112,6 +116,7 @@ The following options can be used to customize the behavior of lf:
|
||||
ifs string (default '')
|
||||
ignorecase bool (default on)
|
||||
ignoredia bool (default on)
|
||||
incfilter bool (default off)
|
||||
incsearch bool (default off)
|
||||
info []string (default '')
|
||||
mouse bool (default off)
|
||||
@@ -368,7 +373,7 @@ Read a shell command to execute and wait for a key press in the end.
|
||||
|
||||
shell-async (modal) (default '&')
|
||||
|
||||
Read a shell command to execute synchronously without standard I/O.
|
||||
Read a shell command to execute asynchronously without standard I/O.
|
||||
|
||||
find (modal) (default 'f')
|
||||
find-back (modal) (default 'F')
|
||||
@@ -388,6 +393,15 @@ Read a pattern to search for a file name match in the forward/backward direction
|
||||
|
||||
(See also 'globsearch', 'incsearch', 'wrapscan', 'ignorecase', 'smartcase', 'ignoredia', and 'smartdia' options and 'Searching Files' section)
|
||||
|
||||
filter (modal)
|
||||
setfilter
|
||||
|
||||
Read a pattern to filter out and only view files matching the pattern.
|
||||
setfilter does the same but uses an argument to set the filter immediatly.
|
||||
You can supply an argument to filter, in order to use that as the starting prompt.
|
||||
|
||||
(See also 'globsearch', 'incfilter', 'ignorecase', 'smartcase', 'ignoredia', and 'smartdia' options)
|
||||
|
||||
mark-save (modal) (default 'm')
|
||||
|
||||
Save the current directory as a bookmark assigned to the given key.
|
||||
@@ -499,6 +513,10 @@ When this option is enabled, find command starts matching patterns from the begi
|
||||
|
||||
Automatically quit server when there are no clients left connected.
|
||||
|
||||
dircache bool (default on)
|
||||
|
||||
Cache directory contents.
|
||||
|
||||
dircounts bool (default off)
|
||||
|
||||
When this option is enabled, directory sizes show the number of items inside instead of the size of directory file.
|
||||
@@ -512,6 +530,10 @@ A thousand items are counted per directory at most, and bigger directories are s
|
||||
|
||||
Show directories first above regular files.
|
||||
|
||||
dironly bool (default off)
|
||||
|
||||
Show only directories.
|
||||
|
||||
drawbox bool (default off)
|
||||
|
||||
Draw boxes around panes with box drawing characters.
|
||||
@@ -577,6 +599,10 @@ Ignore diacritics in sorting and search patterns.
|
||||
|
||||
Jump to the first match after each keystroke during searching.
|
||||
|
||||
incfilter bool (default off)
|
||||
|
||||
Apply filter pattern after each keystroke during filtering.
|
||||
|
||||
info []string (default '')
|
||||
|
||||
List of information shown for directory items at the right side of pane.
|
||||
@@ -625,7 +651,7 @@ Preview clearing is disabled when the value of this option is left empty.
|
||||
promptfmt string (default "\033[32;1m%u@%h\033[0m:\033[34;1m%d\033[0m\033[1m%f\033[0m")
|
||||
|
||||
Format string of the prompt shown in the top line.
|
||||
Special expansions are provided, '%u' as the user name, '%h' as the host name, '%w' as the working directory, '%d' as the working directory with a trailing path separator, and '%f' as the file name.
|
||||
Special expansions are provided, '%u' as the user name, '%h' as the host name, '%w' as the working directory, '%d' as the working directory with a trailing path separator, '%f' as the file name, and '%F' as the current filter.
|
||||
Home folder is shown as '~' in the working directory expansion.
|
||||
Directory names are automatically shortened to a single character starting from the left most parent when the prompt does not fit to the screen.
|
||||
|
||||
@@ -1230,6 +1256,9 @@ You can add an extra call to make it run on startup as well:
|
||||
|
||||
Note that all shell commands are possible but `%` and `&` are usually more appropriate as `$` and `!` causes flickers and pauses respectively.
|
||||
|
||||
There is also a 'pre-cd' command, that works like 'on-cd', but is run before the directory is actually changed.
|
||||
It is generally a bad idea, to put movement commands (like 'up' / 'top' etc.) here.
|
||||
|
||||
Colors
|
||||
|
||||
lf tries to automatically adapt its colors to the environment.
|
||||
|
||||
+38
-6
@@ -66,6 +66,8 @@ The following commands are provided by lf:
|
||||
search-back (modal) (default '?')
|
||||
search-next (default 'n')
|
||||
search-prev (default 'N')
|
||||
filter (modal)
|
||||
setfilter
|
||||
mark-save (modal) (default 'm')
|
||||
mark-load (modal) (default "'")
|
||||
mark-remove (modal) (default '"')
|
||||
@@ -103,8 +105,10 @@ The following options can be used to customize the behavior of lf:
|
||||
|
||||
anchorfind bool (default on)
|
||||
autoquit bool (default off)
|
||||
dircache bool (default on)
|
||||
dircounts bool (default off)
|
||||
dirfirst bool (default on)
|
||||
dironly bool (default off)
|
||||
drawbox bool (default off)
|
||||
errorfmt string (default "\033[7;31;47m%s\033[0m")
|
||||
filesep string (default "\n")
|
||||
@@ -116,6 +120,7 @@ The following options can be used to customize the behavior of lf:
|
||||
ifs string (default '')
|
||||
ignorecase bool (default on)
|
||||
ignoredia bool (default on)
|
||||
incfilter bool (default off)
|
||||
incsearch bool (default off)
|
||||
info []string (default '')
|
||||
mouse bool (default off)
|
||||
@@ -384,7 +389,7 @@ Read a shell command to execute and wait for a key press in the end.
|
||||
|
||||
shell-async (modal) (default '&')
|
||||
|
||||
Read a shell command to execute synchronously without standard I/O.
|
||||
Read a shell command to execute asynchronously without standard I/O.
|
||||
|
||||
find (modal) (default 'f')
|
||||
find-back (modal) (default 'F')
|
||||
@@ -408,6 +413,17 @@ direction and jump to the next/previous match.
|
||||
(See also 'globsearch', 'incsearch', 'wrapscan', 'ignorecase', 'smartcase',
|
||||
'ignoredia', and 'smartdia' options and 'Searching Files' section)
|
||||
|
||||
filter (modal)
|
||||
setfilter
|
||||
|
||||
Read a pattern to filter out and only view files matching the pattern.
|
||||
setfilter does the same but uses an argument to set the filter immediatly.
|
||||
You can supply an argument to filter, in order to use that as the starting
|
||||
prompt.
|
||||
|
||||
(See also 'globsearch', 'incfilter', 'ignorecase', 'smartcase', 'ignoredia',
|
||||
and 'smartdia' options)
|
||||
|
||||
mark-save (modal) (default 'm')
|
||||
|
||||
Save the current directory as a bookmark assigned to the given key.
|
||||
@@ -525,6 +541,10 @@ beginning of file names, otherwise, it can match at an arbitrary position.
|
||||
|
||||
Automatically quit server when there are no clients left connected.
|
||||
|
||||
dircache bool (default on)
|
||||
|
||||
Cache directory contents.
|
||||
|
||||
dircounts bool (default off)
|
||||
|
||||
When this option is enabled, directory sizes show the number of items inside
|
||||
@@ -541,6 +561,10 @@ directories are shown as '999+'.
|
||||
|
||||
Show directories first above regular files.
|
||||
|
||||
dironly bool (default off)
|
||||
|
||||
Show only directories.
|
||||
|
||||
drawbox bool (default off)
|
||||
|
||||
Draw boxes around panes with box drawing characters.
|
||||
@@ -608,6 +632,10 @@ Ignore diacritics in sorting and search patterns.
|
||||
|
||||
Jump to the first match after each keystroke during searching.
|
||||
|
||||
incfilter bool (default off)
|
||||
|
||||
Apply filter pattern after each keystroke during filtering.
|
||||
|
||||
info []string (default '')
|
||||
|
||||
List of information shown for directory items at the right side of pane.
|
||||
@@ -665,11 +693,11 @@ Preview clearing is disabled when the value of this option is left empty.
|
||||
|
||||
Format string of the prompt shown in the top line. Special expansions are
|
||||
provided, '%u' as the user name, '%h' as the host name, '%w' as the working
|
||||
directory, '%d' as the working directory with a trailing path separator, and
|
||||
'%f' as the file name. Home folder is shown as '~' in the working directory
|
||||
expansion. Directory names are automatically shortened to a single character
|
||||
starting from the left most parent when the prompt does not fit to the
|
||||
screen.
|
||||
directory, '%d' as the working directory with a trailing path separator,
|
||||
'%f' as the file name, and '%F' as the current filter. Home folder is shown
|
||||
as '~' in the working directory expansion. Directory names are automatically
|
||||
shortened to a single character starting from the left most parent when the
|
||||
prompt does not fit to the screen.
|
||||
|
||||
ratios []int (default '1:2:3')
|
||||
|
||||
@@ -1379,6 +1407,10 @@ add an extra call to make it run on startup as well:
|
||||
Note that all shell commands are possible but '%' and '&' are usually more
|
||||
appropriate as '$' and '!' causes flickers and pauses respectively.
|
||||
|
||||
There is also a 'pre-cd' command, that works like 'on-cd', but is run before
|
||||
the directory is actually changed. It is generally a bad idea, to put
|
||||
movement commands (like 'up' / 'top' etc.) here.
|
||||
|
||||
|
||||
Colors
|
||||
|
||||
|
||||
+4
-4
@@ -15,10 +15,10 @@
|
||||
|
||||
$tmp = [System.IO.Path]::GetTempFileName()
|
||||
lf -last-dir-path="$tmp" $args
|
||||
if (test-path -pathtype leaf "$tmp") {
|
||||
$dir = type "$tmp"
|
||||
remove-item -force "$tmp"
|
||||
if (test-path -pathtype container "$dir") {
|
||||
if (Test-Path -PathType Leaf "$tmp") {
|
||||
$dir = Get-Content "$tmp"
|
||||
Remove-Item -Force "$tmp"
|
||||
if (Test-Path -PathType Container "$dir") {
|
||||
if ("$dir" -ne "$pwd") {
|
||||
cd "$dir"
|
||||
}
|
||||
|
||||
@@ -26,12 +26,36 @@ func (e *setExpr) eval(app *app, args []string) {
|
||||
gOpts.autoquit = false
|
||||
case "autoquit!":
|
||||
gOpts.autoquit = !gOpts.autoquit
|
||||
case "dircache":
|
||||
gOpts.dircache = true
|
||||
case "nodircache":
|
||||
gOpts.dircache = false
|
||||
case "dircache!":
|
||||
gOpts.dircache = !gOpts.dircache
|
||||
case "dircounts":
|
||||
gOpts.dircounts = true
|
||||
case "nodircounts":
|
||||
gOpts.dircounts = false
|
||||
case "dircounts!":
|
||||
gOpts.dircounts = !gOpts.dircounts
|
||||
case "dironly":
|
||||
gOpts.dironly = true
|
||||
app.nav.sort()
|
||||
app.nav.position()
|
||||
app.ui.sort()
|
||||
app.ui.loadFile(app.nav, true)
|
||||
case "nodironly":
|
||||
gOpts.dironly = false
|
||||
app.nav.sort()
|
||||
app.nav.position()
|
||||
app.ui.sort()
|
||||
app.ui.loadFile(app.nav, true)
|
||||
case "dironly!":
|
||||
gOpts.dironly = !gOpts.dironly
|
||||
app.nav.sort()
|
||||
app.nav.position()
|
||||
app.ui.sort()
|
||||
app.ui.loadFile(app.nav, true)
|
||||
case "dirfirst":
|
||||
gOpts.sortType.option |= dirfirstSort
|
||||
app.nav.sort()
|
||||
@@ -70,10 +94,19 @@ func (e *setExpr) eval(app *app, args []string) {
|
||||
app.ui.loadFile(app.nav, true)
|
||||
case "globsearch":
|
||||
gOpts.globsearch = true
|
||||
app.nav.sort()
|
||||
app.ui.sort()
|
||||
app.ui.loadFile(app.nav, true)
|
||||
case "noglobsearch":
|
||||
gOpts.globsearch = false
|
||||
app.nav.sort()
|
||||
app.ui.sort()
|
||||
app.ui.loadFile(app.nav, true)
|
||||
case "globsearch!":
|
||||
gOpts.globsearch = !gOpts.globsearch
|
||||
app.nav.sort()
|
||||
app.ui.sort()
|
||||
app.ui.loadFile(app.nav, true)
|
||||
case "hidden":
|
||||
gOpts.sortType.option |= hiddenSort
|
||||
app.nav.sort()
|
||||
@@ -102,14 +135,17 @@ func (e *setExpr) eval(app *app, args []string) {
|
||||
gOpts.ignorecase = true
|
||||
app.nav.sort()
|
||||
app.ui.sort()
|
||||
app.ui.loadFile(app.nav, true)
|
||||
case "noignorecase":
|
||||
gOpts.ignorecase = false
|
||||
app.nav.sort()
|
||||
app.ui.sort()
|
||||
app.ui.loadFile(app.nav, true)
|
||||
case "ignorecase!":
|
||||
gOpts.ignorecase = !gOpts.ignorecase
|
||||
app.nav.sort()
|
||||
app.ui.sort()
|
||||
app.ui.loadFile(app.nav, true)
|
||||
case "ignoredia":
|
||||
gOpts.ignoredia = true
|
||||
app.nav.sort()
|
||||
@@ -122,6 +158,12 @@ func (e *setExpr) eval(app *app, args []string) {
|
||||
gOpts.ignoredia = !gOpts.ignoredia
|
||||
app.nav.sort()
|
||||
app.ui.sort()
|
||||
case "incfilter":
|
||||
gOpts.incfilter = true
|
||||
case "noincfilter":
|
||||
gOpts.incfilter = false
|
||||
case "incfilter!":
|
||||
gOpts.incfilter = !gOpts.incfilter
|
||||
case "incsearch":
|
||||
gOpts.incsearch = true
|
||||
case "noincsearch":
|
||||
@@ -186,10 +228,19 @@ func (e *setExpr) eval(app *app, args []string) {
|
||||
app.ui.sort()
|
||||
case "smartcase":
|
||||
gOpts.smartcase = true
|
||||
app.nav.sort()
|
||||
app.ui.sort()
|
||||
app.ui.loadFile(app.nav, true)
|
||||
case "nosmartcase":
|
||||
gOpts.smartcase = false
|
||||
app.nav.sort()
|
||||
app.ui.sort()
|
||||
app.ui.loadFile(app.nav, true)
|
||||
case "smartcase!":
|
||||
gOpts.smartcase = !gOpts.smartcase
|
||||
app.nav.sort()
|
||||
app.ui.sort()
|
||||
app.ui.loadFile(app.nav, true)
|
||||
case "smartdia":
|
||||
gOpts.smartdia = true
|
||||
case "nosmartdia":
|
||||
@@ -385,10 +436,10 @@ func (e *mapExpr) eval(app *app, args []string) {
|
||||
}
|
||||
|
||||
func (e *cmapExpr) eval(app *app, args []string) {
|
||||
if e.cmd == "" {
|
||||
if e.expr == nil {
|
||||
delete(gOpts.cmdkeys, e.key)
|
||||
} else {
|
||||
gOpts.cmdkeys[e.key] = &callExpr{e.cmd, nil, 1}
|
||||
gOpts.cmdkeys[e.key] = e.expr
|
||||
}
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
}
|
||||
@@ -402,6 +453,12 @@ func (e *cmdExpr) eval(app *app, args []string) {
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
}
|
||||
|
||||
func preChdir(app *app) {
|
||||
if cmd, ok := gOpts.cmds["pre-cd"]; ok {
|
||||
cmd.eval(app, nil)
|
||||
}
|
||||
}
|
||||
|
||||
func onChdir(app *app) {
|
||||
if cmd, ok := gOpts.cmds["on-cd"]; ok {
|
||||
cmd.eval(app, nil)
|
||||
@@ -461,10 +518,56 @@ func update(app *app) {
|
||||
app.ui.loadFile(app.nav, true)
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
}
|
||||
case gOpts.incfilter && app.ui.cmdPrefix == "filter: ":
|
||||
filter := string(app.ui.cmdAccLeft) + string(app.ui.cmdAccRight)
|
||||
dir := app.nav.currDir()
|
||||
old := dir.ind
|
||||
|
||||
if err := app.nav.setFilter(strings.Split(filter, " ")); err != nil {
|
||||
app.ui.echoerrf("filter: %s", err)
|
||||
} else if old != dir.ind {
|
||||
app.ui.loadFile(app.nav, true)
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func restartIncCmd(app *app) {
|
||||
if gOpts.incsearch && (app.ui.cmdPrefix == "/" || app.ui.cmdPrefix == "?") {
|
||||
dir := app.nav.currDir()
|
||||
app.nav.searchInd = dir.ind
|
||||
app.nav.searchPos = dir.pos
|
||||
update(app)
|
||||
} else if gOpts.incfilter && app.ui.cmdPrefix == "filter: " {
|
||||
dir := app.nav.currDir()
|
||||
app.nav.prevFilter = dir.filter
|
||||
update(app)
|
||||
}
|
||||
}
|
||||
|
||||
func resetIncCmd(app *app) {
|
||||
if gOpts.incsearch && (app.ui.cmdPrefix == "/" || app.ui.cmdPrefix == "?") {
|
||||
dir := app.nav.currDir()
|
||||
dir.pos = app.nav.searchPos
|
||||
if dir.ind != app.nav.searchInd {
|
||||
dir.ind = app.nav.searchInd
|
||||
app.ui.loadFile(app.nav, true)
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
}
|
||||
} else if gOpts.incfilter && app.ui.cmdPrefix == "filter: " {
|
||||
dir := app.nav.currDir()
|
||||
old := dir.ind
|
||||
app.nav.setFilter(app.nav.prevFilter)
|
||||
if old != dir.ind {
|
||||
app.ui.loadFile(app.nav, true)
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func normal(app *app) {
|
||||
resetIncCmd(app)
|
||||
|
||||
app.ui.menuBuf = nil
|
||||
app.ui.menuSelected = -2
|
||||
|
||||
@@ -479,6 +582,9 @@ func insert(app *app, arg string) {
|
||||
case gOpts.incsearch && (app.ui.cmdPrefix == "/" || app.ui.cmdPrefix == "?"):
|
||||
app.ui.cmdAccLeft = append(app.ui.cmdAccLeft, []rune(arg)...)
|
||||
update(app)
|
||||
case gOpts.incfilter && app.ui.cmdPrefix == "filter: ":
|
||||
app.ui.cmdAccLeft = append(app.ui.cmdAccLeft, []rune(arg)...)
|
||||
update(app)
|
||||
case app.ui.cmdPrefix == "find: ":
|
||||
app.nav.find = string(app.ui.cmdAccLeft) + arg + string(app.ui.cmdAccRight)
|
||||
|
||||
@@ -605,12 +711,7 @@ func insert(app *app, arg string) {
|
||||
case app.ui.cmdPrefix == "mark-save: ":
|
||||
normal(app)
|
||||
|
||||
wd, err := os.Getwd()
|
||||
if err != nil {
|
||||
log.Printf("getting current directory: %s", err)
|
||||
return
|
||||
}
|
||||
app.nav.marks[arg] = wd
|
||||
app.nav.marks[arg] = app.nav.currDir().path
|
||||
if err := app.nav.writeMarks(); err != nil {
|
||||
app.ui.echoerrf("mark-save: %s", err)
|
||||
}
|
||||
@@ -636,6 +737,12 @@ func insert(app *app, arg string) {
|
||||
app.ui.echoerr("mark-load: no such mark")
|
||||
return
|
||||
}
|
||||
|
||||
if wd != path {
|
||||
resetIncCmd(app)
|
||||
preChdir(app)
|
||||
}
|
||||
|
||||
if err := app.nav.cd(path); err != nil {
|
||||
app.ui.echoerrf("%s", err)
|
||||
return
|
||||
@@ -645,6 +752,7 @@ func insert(app *app, arg string) {
|
||||
|
||||
if wd != path {
|
||||
app.nav.marks["'"] = wd
|
||||
restartIncCmd(app)
|
||||
onChdir(app)
|
||||
}
|
||||
case app.ui.cmdPrefix == "mark-remove: ":
|
||||
@@ -674,57 +782,38 @@ func insert(app *app, arg string) {
|
||||
func (e *callExpr) eval(app *app, args []string) {
|
||||
switch e.name {
|
||||
case "up":
|
||||
if app.ui.cmdPrefix != "" && app.ui.cmdPrefix != ">" {
|
||||
normal(app)
|
||||
}
|
||||
if app.nav.up(e.count) {
|
||||
app.ui.loadFile(app.nav, true)
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
}
|
||||
case "half-up":
|
||||
if app.ui.cmdPrefix != "" && app.ui.cmdPrefix != ">" {
|
||||
normal(app)
|
||||
}
|
||||
if app.nav.up(e.count * app.nav.height / 2) {
|
||||
app.ui.loadFile(app.nav, true)
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
}
|
||||
case "page-up":
|
||||
if app.ui.cmdPrefix != "" && app.ui.cmdPrefix != ">" {
|
||||
normal(app)
|
||||
}
|
||||
if app.nav.up(e.count * app.nav.height) {
|
||||
app.ui.loadFile(app.nav, true)
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
}
|
||||
case "down":
|
||||
if app.ui.cmdPrefix != "" && app.ui.cmdPrefix != ">" {
|
||||
normal(app)
|
||||
}
|
||||
if app.nav.down(e.count) {
|
||||
app.ui.loadFile(app.nav, true)
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
}
|
||||
case "half-down":
|
||||
if app.ui.cmdPrefix != "" && app.ui.cmdPrefix != ">" {
|
||||
normal(app)
|
||||
}
|
||||
if app.nav.down(e.count * app.nav.height / 2) {
|
||||
app.ui.loadFile(app.nav, true)
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
}
|
||||
case "page-down":
|
||||
if app.ui.cmdPrefix != "" && app.ui.cmdPrefix != ">" {
|
||||
normal(app)
|
||||
}
|
||||
if app.nav.down(e.count * app.nav.height) {
|
||||
app.ui.loadFile(app.nav, true)
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
}
|
||||
case "updir":
|
||||
if app.ui.cmdPrefix != "" && app.ui.cmdPrefix != ">" {
|
||||
normal(app)
|
||||
}
|
||||
resetIncCmd(app)
|
||||
preChdir(app)
|
||||
for i := 0; i < e.count; i++ {
|
||||
if err := app.nav.updir(); err != nil {
|
||||
app.ui.echoerrf("%s", err)
|
||||
@@ -733,11 +822,9 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
}
|
||||
app.ui.loadFile(app.nav, true)
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
restartIncCmd(app)
|
||||
onChdir(app)
|
||||
case "open":
|
||||
if app.ui.cmdPrefix != "" && app.ui.cmdPrefix != ">" {
|
||||
normal(app)
|
||||
}
|
||||
curr, err := app.nav.currFile()
|
||||
if err != nil {
|
||||
app.ui.echoerrf("opening: %s", err)
|
||||
@@ -745,6 +832,8 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
}
|
||||
|
||||
if curr.IsDir() {
|
||||
resetIncCmd(app)
|
||||
preChdir(app)
|
||||
err := app.nav.open()
|
||||
if err != nil {
|
||||
app.ui.echoerrf("opening directory: %s", err)
|
||||
@@ -752,6 +841,7 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
}
|
||||
app.ui.loadFile(app.nav, true)
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
restartIncCmd(app)
|
||||
onChdir(app)
|
||||
return
|
||||
}
|
||||
@@ -787,17 +877,11 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
case "quit":
|
||||
app.quitChan <- struct{}{}
|
||||
case "top":
|
||||
if app.ui.cmdPrefix != "" && app.ui.cmdPrefix != ">" {
|
||||
normal(app)
|
||||
}
|
||||
if app.nav.top() {
|
||||
app.ui.loadFile(app.nav, true)
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
}
|
||||
case "bottom":
|
||||
if app.ui.cmdPrefix != "" && app.ui.cmdPrefix != ">" {
|
||||
normal(app)
|
||||
}
|
||||
if app.nav.bottom() {
|
||||
app.ui.loadFile(app.nav, true)
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
@@ -808,6 +892,7 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
} else {
|
||||
dir := app.nav.currDir()
|
||||
for _, path := range e.args {
|
||||
path = replaceTilde(path)
|
||||
if !filepath.IsAbs(path) {
|
||||
path = filepath.Join(dir.path, path)
|
||||
}
|
||||
@@ -887,6 +972,10 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
return
|
||||
}
|
||||
|
||||
if app.ui.cmdPrefix == ">" {
|
||||
return
|
||||
}
|
||||
normal(app)
|
||||
if len(list) == 1 {
|
||||
app.ui.cmdPrefix = "delete '" + list[0] + "' ? [y/N] "
|
||||
} else {
|
||||
@@ -931,25 +1020,53 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
app.ui.loadFile(app.nav, true)
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
case "read":
|
||||
if app.ui.cmdPrefix == ">" {
|
||||
return
|
||||
}
|
||||
normal(app)
|
||||
app.ui.cmdPrefix = ":"
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
case "shell":
|
||||
if app.ui.cmdPrefix == ">" {
|
||||
return
|
||||
}
|
||||
normal(app)
|
||||
app.ui.cmdPrefix = "$"
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
case "shell-pipe":
|
||||
if app.ui.cmdPrefix == ">" {
|
||||
return
|
||||
}
|
||||
normal(app)
|
||||
app.ui.cmdPrefix = "%"
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
case "shell-wait":
|
||||
if app.ui.cmdPrefix == ">" {
|
||||
return
|
||||
}
|
||||
normal(app)
|
||||
app.ui.cmdPrefix = "!"
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
case "shell-async":
|
||||
if app.ui.cmdPrefix == ">" {
|
||||
return
|
||||
}
|
||||
normal(app)
|
||||
app.ui.cmdPrefix = "&"
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
case "find":
|
||||
if app.ui.cmdPrefix == ">" {
|
||||
return
|
||||
}
|
||||
normal(app)
|
||||
app.ui.cmdPrefix = "find: "
|
||||
app.nav.findBack = false
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
case "find-back":
|
||||
if app.ui.cmdPrefix == ">" {
|
||||
return
|
||||
}
|
||||
normal(app)
|
||||
app.ui.cmdPrefix = "find-back: "
|
||||
app.nav.findBack = true
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
@@ -982,6 +1099,10 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
}
|
||||
case "search":
|
||||
if app.ui.cmdPrefix == ">" {
|
||||
return
|
||||
}
|
||||
normal(app)
|
||||
app.ui.cmdPrefix = "/"
|
||||
dir := app.nav.currDir()
|
||||
app.nav.searchInd = dir.ind
|
||||
@@ -989,6 +1110,10 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
app.nav.searchBack = false
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
case "search-back":
|
||||
if app.ui.cmdPrefix == ">" {
|
||||
return
|
||||
}
|
||||
normal(app)
|
||||
app.ui.cmdPrefix = "?"
|
||||
dir := app.nav.currDir()
|
||||
app.nav.searchInd = dir.ind
|
||||
@@ -1031,12 +1156,45 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
}
|
||||
}
|
||||
}
|
||||
case "filter":
|
||||
if app.ui.cmdPrefix == ">" {
|
||||
return
|
||||
}
|
||||
normal(app)
|
||||
app.ui.cmdPrefix = "filter: "
|
||||
dir := app.nav.currDir()
|
||||
app.nav.prevFilter = dir.filter
|
||||
if len(e.args) == 0 {
|
||||
app.ui.cmdAccLeft = []rune(strings.Join(dir.filter, " "))
|
||||
} else {
|
||||
app.ui.cmdAccLeft = []rune(strings.Join(e.args, " "))
|
||||
}
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
case "setfilter":
|
||||
log.Printf("filter: %s", e.args)
|
||||
if err := app.nav.setFilter(e.args); err != nil {
|
||||
app.ui.echoerrf("filter: %s", err)
|
||||
}
|
||||
app.ui.loadFile(app.nav, true)
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
case "mark-save":
|
||||
if app.ui.cmdPrefix == ">" {
|
||||
return
|
||||
}
|
||||
normal(app)
|
||||
app.ui.cmdPrefix = "mark-save: "
|
||||
case "mark-load":
|
||||
if app.ui.cmdPrefix == ">" {
|
||||
return
|
||||
}
|
||||
normal(app)
|
||||
app.ui.menuBuf = listMarks(app.nav.marks)
|
||||
app.ui.cmdPrefix = "mark-load: "
|
||||
case "mark-remove":
|
||||
if app.ui.cmdPrefix == ">" {
|
||||
return
|
||||
}
|
||||
normal(app)
|
||||
app.ui.menuBuf = listMarks(app.nav.marks)
|
||||
app.ui.cmdPrefix = "mark-remove: "
|
||||
case "rename":
|
||||
@@ -1057,6 +1215,10 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
app.ui.echoerrf("rename: %s:", err)
|
||||
return
|
||||
}
|
||||
if app.ui.cmdPrefix == ">" {
|
||||
return
|
||||
}
|
||||
normal(app)
|
||||
app.ui.cmdPrefix = "rename: "
|
||||
app.ui.cmdAccLeft = append(app.ui.cmdAccLeft, []rune(curr.Name())...)
|
||||
}
|
||||
@@ -1083,6 +1245,18 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
log.Printf("getting current directory: %s", err)
|
||||
}
|
||||
|
||||
path = replaceTilde(path)
|
||||
if !filepath.IsAbs(path) {
|
||||
path = filepath.Join(wd, path)
|
||||
} else {
|
||||
path = filepath.Clean(path)
|
||||
}
|
||||
|
||||
if wd != path {
|
||||
resetIncCmd(app)
|
||||
preChdir(app)
|
||||
}
|
||||
|
||||
if err := app.nav.cd(path); err != nil {
|
||||
app.ui.echoerrf("%s", err)
|
||||
return
|
||||
@@ -1091,14 +1265,9 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
app.ui.loadFile(app.nav, true)
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
|
||||
if !filepath.IsAbs(path) {
|
||||
path = filepath.Join(wd, path)
|
||||
} else {
|
||||
path = filepath.Clean(path)
|
||||
}
|
||||
|
||||
if wd != path {
|
||||
app.nav.marks["'"] = wd
|
||||
restartIncCmd(app)
|
||||
onChdir(app)
|
||||
}
|
||||
case "select":
|
||||
@@ -1112,6 +1281,18 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
log.Printf("getting current directory: %s", err)
|
||||
}
|
||||
|
||||
path := filepath.Dir(replaceTilde(e.args[0]))
|
||||
if !filepath.IsAbs(path) {
|
||||
path = filepath.Join(wd, path)
|
||||
} else {
|
||||
path = filepath.Clean(path)
|
||||
}
|
||||
|
||||
if wd != path {
|
||||
resetIncCmd(app)
|
||||
preChdir(app)
|
||||
}
|
||||
|
||||
if err := app.nav.sel(e.args[0]); err != nil {
|
||||
app.ui.echoerrf("%s", err)
|
||||
return
|
||||
@@ -1120,15 +1301,9 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
app.ui.loadFile(app.nav, true)
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
|
||||
path := filepath.Dir(e.args[0])
|
||||
if !filepath.IsAbs(path) {
|
||||
path = filepath.Join(wd, path)
|
||||
} else {
|
||||
path = filepath.Clean(path)
|
||||
}
|
||||
|
||||
if wd != path {
|
||||
app.nav.marks["'"] = wd
|
||||
restartIncCmd(app)
|
||||
onChdir(app)
|
||||
}
|
||||
case "glob-select":
|
||||
@@ -1182,15 +1357,6 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
if app.ui.cmdPrefix == ">" {
|
||||
return
|
||||
}
|
||||
if gOpts.incsearch && (app.ui.cmdPrefix == "/" || app.ui.cmdPrefix == "?") {
|
||||
dir := app.nav.currDir()
|
||||
dir.pos = app.nav.searchPos
|
||||
if dir.ind != app.nav.searchInd {
|
||||
dir.ind = app.nav.searchInd
|
||||
app.ui.loadFile(app.nav, true)
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
}
|
||||
}
|
||||
normal(app)
|
||||
case "cmd-complete":
|
||||
var matches []string
|
||||
@@ -1307,7 +1473,7 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
}
|
||||
case "cmd-enter":
|
||||
s := string(append(app.ui.cmdAccLeft, app.ui.cmdAccRight...))
|
||||
if len(s) == 0 {
|
||||
if len(s) == 0 && app.ui.cmdPrefix != "filter: " {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1384,6 +1550,14 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
app.ui.loadFile(app.nav, true)
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
}
|
||||
case "filter: ":
|
||||
log.Printf("filter: %s", s)
|
||||
app.ui.cmdPrefix = ""
|
||||
if err := app.nav.setFilter(strings.Split(s, " ")); err != nil {
|
||||
app.ui.echoerrf("filter: %s", err)
|
||||
}
|
||||
app.ui.loadFile(app.nav, true)
|
||||
app.ui.loadFileInfo(app.nav)
|
||||
case "find: ":
|
||||
app.ui.cmdPrefix = ""
|
||||
if moved, found := app.nav.findNext(); !found {
|
||||
@@ -1413,7 +1587,7 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
|
||||
oldPath := filepath.Join(wd, curr.Name())
|
||||
|
||||
newPath := filepath.Clean(s)
|
||||
newPath := filepath.Clean(replaceTilde(s))
|
||||
if !filepath.IsAbs(newPath) {
|
||||
newPath = filepath.Join(wd, newPath)
|
||||
}
|
||||
@@ -1480,12 +1654,9 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
return
|
||||
}
|
||||
cmd := app.cmdHistory[len(app.cmdHistory)-app.cmdHistoryInd]
|
||||
normal(app)
|
||||
app.ui.cmdPrefix = cmd.prefix
|
||||
app.ui.cmdAccLeft = []rune(cmd.value)
|
||||
app.ui.cmdAccRight = nil
|
||||
app.ui.cmdTmp = nil
|
||||
app.ui.menuBuf = nil
|
||||
app.ui.menuSelected = -2
|
||||
case "cmd-history-prev":
|
||||
if app.ui.cmdPrefix == ">" {
|
||||
return
|
||||
@@ -1498,12 +1669,9 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
}
|
||||
app.cmdHistoryInd++
|
||||
cmd := app.cmdHistory[len(app.cmdHistory)-app.cmdHistoryInd]
|
||||
normal(app)
|
||||
app.ui.cmdPrefix = cmd.prefix
|
||||
app.ui.cmdAccLeft = []rune(cmd.value)
|
||||
app.ui.cmdAccRight = nil
|
||||
app.ui.cmdTmp = nil
|
||||
app.ui.menuBuf = nil
|
||||
app.ui.menuSelected = -2
|
||||
case "cmd-delete":
|
||||
if len(app.ui.cmdAccRight) == 0 {
|
||||
return
|
||||
|
||||
+1
-1
@@ -218,7 +218,7 @@ var gEvalTests = []struct {
|
||||
{
|
||||
"cmap <c-g> cmd-escape",
|
||||
[]string{"cmap", "<c-g>", "cmd-escape", "\n"},
|
||||
[]expr{&cmapExpr{"<c-g>", "cmd-escape"}},
|
||||
[]expr{&cmapExpr{"<c-g>", &callExpr{"cmd-escape", nil, 1}}},
|
||||
},
|
||||
|
||||
{
|
||||
|
||||
@@ -77,6 +77,8 @@ The following commands are provided by lf:
|
||||
search-back (modal) (default '?')
|
||||
search-next (default 'n')
|
||||
search-prev (default 'N')
|
||||
filter (modal)
|
||||
setfilter
|
||||
mark-save (modal) (default 'm')
|
||||
mark-load (modal) (default "'")
|
||||
mark-remove (modal) (default `"`)
|
||||
@@ -118,8 +120,10 @@ The following options can be used to customize the behavior of lf:
|
||||
.EX
|
||||
anchorfind bool (default on)
|
||||
autoquit bool (default off)
|
||||
dircache bool (default on)
|
||||
dircounts bool (default off)
|
||||
dirfirst bool (default on)
|
||||
dironly bool (default off)
|
||||
drawbox bool (default off)
|
||||
errorfmt string (default "\e033[7;31;47m%s\e033[0m")
|
||||
filesep string (default "\en")
|
||||
@@ -131,6 +135,7 @@ The following options can be used to customize the behavior of lf:
|
||||
ifs string (default '')
|
||||
ignorecase bool (default on)
|
||||
ignoredia bool (default on)
|
||||
incfilter bool (default off)
|
||||
incsearch bool (default off)
|
||||
info []string (default '')
|
||||
mouse bool (default off)
|
||||
@@ -455,7 +460,7 @@ Read a shell command to execute and wait for a key press in the end.
|
||||
shell-async (modal) (default '&')
|
||||
.EE
|
||||
.PP
|
||||
Read a shell command to execute synchronously without standard I/O.
|
||||
Read a shell command to execute asynchronously without standard I/O.
|
||||
.PP
|
||||
.EX
|
||||
find (modal) (default 'f')
|
||||
@@ -479,6 +484,15 @@ Read a pattern to search for a file name match in the forward/backward direction
|
||||
.PP
|
||||
(See also 'globsearch', 'incsearch', 'wrapscan', 'ignorecase', 'smartcase', 'ignoredia', and 'smartdia' options and 'Searching Files' section)
|
||||
.PP
|
||||
.EX
|
||||
filter (modal)
|
||||
setfilter
|
||||
.EE
|
||||
.PP
|
||||
Read a pattern to filter out and only view files matching the pattern. setfilter does the same but uses an argument to set the filter immediatly. You can supply an argument to filter, in order to use that as the starting prompt.
|
||||
.PP
|
||||
(See also 'globsearch', 'incfilter', 'ignorecase', 'smartcase', 'ignoredia', and 'smartdia' options)
|
||||
.PP
|
||||
.EX
|
||||
mark-save (modal) (default 'm')
|
||||
.EE
|
||||
@@ -624,6 +638,12 @@ When this option is enabled, find command starts matching patterns from the begi
|
||||
.PP
|
||||
Automatically quit server when there are no clients left connected.
|
||||
.PP
|
||||
.EX
|
||||
dircache bool (default on)
|
||||
.EE
|
||||
.PP
|
||||
Cache directory contents.
|
||||
.PP
|
||||
.EX
|
||||
dircounts bool (default off)
|
||||
.EE
|
||||
@@ -636,6 +656,12 @@ When this option is enabled, directory sizes show the number of items inside ins
|
||||
.PP
|
||||
Show directories first above regular files.
|
||||
.PP
|
||||
.EX
|
||||
dironly bool (default off)
|
||||
.EE
|
||||
.PP
|
||||
Show only directories.
|
||||
.PP
|
||||
.EX
|
||||
drawbox bool (default off)
|
||||
.EE
|
||||
@@ -708,6 +734,12 @@ Ignore diacritics in sorting and search patterns.
|
||||
.PP
|
||||
Jump to the first match after each keystroke during searching.
|
||||
.PP
|
||||
.EX
|
||||
incfilter bool (default off)
|
||||
.EE
|
||||
.PP
|
||||
Apply filter pattern after each keystroke during filtering.
|
||||
.PP
|
||||
.EX
|
||||
info []string (default '')
|
||||
.EE
|
||||
@@ -754,7 +786,7 @@ Set the path of a cleaner file. This file will be called if previewing is enable
|
||||
promptfmt string (default "\e033[32;1m%u@%h\e033[0m:\e033[34;1m%d\e033[0m\e033[1m%f\e033[0m")
|
||||
.EE
|
||||
.PP
|
||||
Format string of the prompt shown in the top line. Special expansions are provided, '%u' as the user name, '%h' as the host name, '%w' as the working directory, '%d' as the working directory with a trailing path separator, and '%f' as the file name. Home folder is shown as '~' in the working directory expansion. Directory names are automatically shortened to a single character starting from the left most parent when the prompt does not fit to the screen.
|
||||
Format string of the prompt shown in the top line. Special expansions are provided, '%u' as the user name, '%h' as the host name, '%w' as the working directory, '%d' as the working directory with a trailing path separator, '%f' as the file name, and '%F' as the current filter. Home folder is shown as '~' in the working directory expansion. Directory names are automatically shortened to a single character starting from the left most parent when the prompt does not fit to the screen.
|
||||
.PP
|
||||
.EX
|
||||
ratios []int (default '1:2:3')
|
||||
@@ -1367,6 +1399,8 @@ This command runs whenever you change directory but not on startup. You can add
|
||||
.EE
|
||||
.PP
|
||||
Note that all shell commands are possible but `%` and `&` are usually more appropriate as `$` and `!` causes flickers and pauses respectively.
|
||||
.PP
|
||||
There is also a 'pre-cd' command, that works like 'on-cd', but is run before the directory is actually changed. It is generally a bad idea, to put movement commands (like 'up' / 'top' etc.) here.
|
||||
.SH COLORS
|
||||
lf tries to automatically adapt its colors to the environment. It starts with a default colorscheme and updates colors using values of existing environment variables possibly by overwriting its previous values. Colors are set in the following order:
|
||||
.PP
|
||||
|
||||
@@ -113,7 +113,9 @@ type dir struct {
|
||||
files []*file // displayed files in directory including or excluding hidden ones
|
||||
allFiles []*file // all files in directory including hidden ones (same array as files)
|
||||
sortType sortType // sort method and options from last sort
|
||||
dironly bool // dironly value from last sort
|
||||
hiddenfiles []string // hiddenfiles value from last sort
|
||||
filter []string // last filter for this directory
|
||||
ignorecase bool // ignorecase value from last sort
|
||||
ignoredia bool // ignoredia value from last sort
|
||||
noPerm bool // whether lf has no permission to open the directory
|
||||
@@ -150,6 +152,7 @@ func normalize(s1, s2 string, ignorecase, ignoredia bool) (string, string) {
|
||||
|
||||
func (dir *dir) sort() {
|
||||
dir.sortType = gOpts.sortType
|
||||
dir.dironly = gOpts.dironly
|
||||
dir.hiddenfiles = gOpts.hiddenfiles
|
||||
dir.ignorecase = gOpts.ignorecase
|
||||
dir.ignoredia = gOpts.ignoredia
|
||||
@@ -219,6 +222,26 @@ func (dir *dir) sort() {
|
||||
})
|
||||
}
|
||||
|
||||
// when dironly option is enabled, we move files to the beginning of our file
|
||||
// list and then set the beginning of displayed files to the first directory
|
||||
// in the list
|
||||
if dir.dironly {
|
||||
sort.SliceStable(dir.files, func(i, j int) bool {
|
||||
if !dir.files[i].IsDir() && !dir.files[j].IsDir() {
|
||||
return i < j
|
||||
}
|
||||
return !dir.files[i].IsDir()
|
||||
})
|
||||
dir.files = func() []*file {
|
||||
for i, f := range dir.files {
|
||||
if f.IsDir() {
|
||||
return dir.files[i:]
|
||||
}
|
||||
}
|
||||
return dir.files[len(dir.files):]
|
||||
}()
|
||||
}
|
||||
|
||||
// when hidden option is disabled, we move hidden files to the
|
||||
// beginning of our file list and then set the beginning of displayed
|
||||
// files to the first non-hidden file in the list
|
||||
@@ -232,11 +255,34 @@ func (dir *dir) sort() {
|
||||
for i, f := range dir.files {
|
||||
if !isHidden(f, dir.path, dir.hiddenfiles) {
|
||||
dir.files = dir.files[i:]
|
||||
return
|
||||
break
|
||||
}
|
||||
}
|
||||
dir.files = dir.files[len(dir.files):]
|
||||
if len(dir.files) > 0 && isHidden(dir.files[len(dir.files)-1], dir.path, dir.hiddenfiles) {
|
||||
dir.files = dir.files[len(dir.files):]
|
||||
}
|
||||
}
|
||||
|
||||
if len(dir.filter) != 0 {
|
||||
sort.SliceStable(dir.files, func(i, j int) bool {
|
||||
if isFiltered(dir.files[i], dir.filter) && isFiltered(dir.files[j], dir.filter) {
|
||||
return i < j
|
||||
}
|
||||
return isFiltered(dir.files[i], dir.filter)
|
||||
})
|
||||
for i, f := range dir.files {
|
||||
if !isFiltered(f, dir.filter) {
|
||||
dir.files = dir.files[i:]
|
||||
break
|
||||
}
|
||||
}
|
||||
if len(dir.files) > 0 && isFiltered(dir.files[len(dir.files)-1], dir.filter) {
|
||||
dir.files = dir.files[len(dir.files):]
|
||||
}
|
||||
}
|
||||
|
||||
dir.ind = max(dir.ind, 0)
|
||||
dir.ind = min(dir.ind, len(dir.files)-1)
|
||||
}
|
||||
|
||||
func (dir *dir) name() string {
|
||||
@@ -244,9 +290,6 @@ func (dir *dir) name() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
dir.ind = max(dir.ind, 0)
|
||||
dir.ind = min(dir.ind, len(dir.files)-1)
|
||||
|
||||
return dir.files[dir.ind].Name()
|
||||
}
|
||||
|
||||
@@ -307,36 +350,46 @@ type nav struct {
|
||||
searchBack bool
|
||||
searchInd int
|
||||
searchPos int
|
||||
prevFilter []string
|
||||
volatilePreview bool
|
||||
}
|
||||
|
||||
func (nav *nav) loadDir(path string) *dir {
|
||||
d, ok := nav.dirCache[path]
|
||||
if !ok {
|
||||
d := &dir{
|
||||
loading: true,
|
||||
loadTime: time.Now(),
|
||||
path: path,
|
||||
sortType: gOpts.sortType,
|
||||
hiddenfiles: gOpts.hiddenfiles,
|
||||
ignorecase: gOpts.ignorecase,
|
||||
ignoredia: gOpts.ignoredia,
|
||||
}
|
||||
nav.dirCache[path] = d
|
||||
go func() {
|
||||
d := newDir(path)
|
||||
d.sort()
|
||||
d.ind, d.pos = 0, 0
|
||||
nav.dirChan <- d
|
||||
}()
|
||||
return d
|
||||
func (nav *nav) loadDirInternal(path string) *dir {
|
||||
d := &dir{
|
||||
loading: true,
|
||||
loadTime: time.Now(),
|
||||
path: path,
|
||||
sortType: gOpts.sortType,
|
||||
hiddenfiles: gOpts.hiddenfiles,
|
||||
ignorecase: gOpts.ignorecase,
|
||||
ignoredia: gOpts.ignoredia,
|
||||
}
|
||||
|
||||
nav.checkDir(d)
|
||||
|
||||
go func() {
|
||||
d := newDir(path)
|
||||
d.sort()
|
||||
d.ind, d.pos = 0, 0
|
||||
nav.dirChan <- d
|
||||
}()
|
||||
return d
|
||||
}
|
||||
|
||||
func (nav *nav) loadDir(path string) *dir {
|
||||
if gOpts.dircache {
|
||||
d, ok := nav.dirCache[path]
|
||||
if !ok {
|
||||
d = nav.loadDirInternal(path)
|
||||
nav.dirCache[path] = d
|
||||
return d
|
||||
}
|
||||
|
||||
nav.checkDir(d)
|
||||
|
||||
return d
|
||||
} else {
|
||||
return nav.loadDirInternal(path)
|
||||
}
|
||||
}
|
||||
|
||||
func (nav *nav) checkDir(dir *dir) {
|
||||
s, err := os.Stat(dir.path)
|
||||
if err != nil {
|
||||
@@ -358,10 +411,12 @@ func (nav *nav) checkDir(dir *dir) {
|
||||
dir.loadTime = now
|
||||
go func() {
|
||||
nd := newDir(dir.path)
|
||||
nd.filter = dir.filter
|
||||
nd.sort()
|
||||
nav.dirChan <- nd
|
||||
}()
|
||||
case dir.sortType != gOpts.sortType ||
|
||||
dir.dironly != gOpts.dironly ||
|
||||
!reflect.DeepEqual(dir.hiddenfiles, gOpts.hiddenfiles) ||
|
||||
dir.ignorecase != gOpts.ignorecase ||
|
||||
dir.ignoredia != gOpts.ignoredia:
|
||||
@@ -601,6 +656,27 @@ func (nav *nav) sort() {
|
||||
}
|
||||
}
|
||||
|
||||
func (nav *nav) setFilter(filter []string) error {
|
||||
newfilter := []string{}
|
||||
for _, tok := range filter {
|
||||
_, err := filepath.Match(tok, "a")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if tok != "" {
|
||||
newfilter = append(newfilter, tok)
|
||||
}
|
||||
}
|
||||
dir := nav.currDir()
|
||||
dir.filter = newfilter
|
||||
|
||||
// Apply filter, by sorting current dir (see nav.sort())
|
||||
name := dir.name()
|
||||
dir.sort()
|
||||
dir.sel(name, nav.height)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (nav *nav) up(dist int) bool {
|
||||
dir := nav.currDir()
|
||||
|
||||
@@ -1251,6 +1327,22 @@ func (nav *nav) searchPrev() (bool, error) {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
func isFiltered(f os.FileInfo, filter []string) bool {
|
||||
for _, pattern := range filter {
|
||||
matched, err := searchMatch(f.Name(), strings.TrimPrefix(pattern, "!"))
|
||||
if err != nil {
|
||||
log.Printf("Filter Error: %s", err)
|
||||
return false
|
||||
}
|
||||
if strings.HasPrefix(pattern, "!") && matched {
|
||||
return true
|
||||
} else if !strings.HasPrefix(pattern, "!") && !matched {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (nav *nav) removeMark(mark string) error {
|
||||
if _, ok := nav.marks[mark]; ok {
|
||||
delete(nav.marks, mark)
|
||||
@@ -1322,6 +1414,7 @@ func (nav *nav) currFile() (*file, error) {
|
||||
if len(dir.files) == 0 {
|
||||
return nil, fmt.Errorf("empty directory")
|
||||
}
|
||||
|
||||
return dir.files[dir.ind], nil
|
||||
}
|
||||
|
||||
|
||||
@@ -30,12 +30,15 @@ type sortType struct {
|
||||
var gOpts struct {
|
||||
anchorfind bool
|
||||
autoquit bool
|
||||
dircache bool
|
||||
dircounts bool
|
||||
dironly bool
|
||||
drawbox bool
|
||||
globsearch bool
|
||||
icons bool
|
||||
ignorecase bool
|
||||
ignoredia bool
|
||||
incfilter bool
|
||||
incsearch bool
|
||||
mouse bool
|
||||
number bool
|
||||
@@ -73,12 +76,15 @@ var gOpts struct {
|
||||
func init() {
|
||||
gOpts.anchorfind = true
|
||||
gOpts.autoquit = false
|
||||
gOpts.dircache = true
|
||||
gOpts.dircounts = false
|
||||
gOpts.dironly = false
|
||||
gOpts.drawbox = false
|
||||
gOpts.globsearch = false
|
||||
gOpts.icons = false
|
||||
gOpts.ignorecase = true
|
||||
gOpts.ignoredia = true
|
||||
gOpts.incfilter = false
|
||||
gOpts.incsearch = false
|
||||
gOpts.mouse = false
|
||||
gOpts.number = false
|
||||
|
||||
@@ -14,7 +14,7 @@ package main
|
||||
//
|
||||
// MapExpr = 'map' <keys> Expr
|
||||
//
|
||||
// CMapExpr = 'cmap' <key> <cmd> ';'
|
||||
// CMapExpr = 'cmap' <key> Expr
|
||||
//
|
||||
// CmdExpr = 'cmd' <name> Expr
|
||||
//
|
||||
@@ -58,11 +58,11 @@ type mapExpr struct {
|
||||
func (e *mapExpr) String() string { return fmt.Sprintf("map %s %s", e.keys, e.expr) }
|
||||
|
||||
type cmapExpr struct {
|
||||
key string
|
||||
cmd string
|
||||
key string
|
||||
expr expr
|
||||
}
|
||||
|
||||
func (e *cmapExpr) String() string { return fmt.Sprintf("cmap %s %s", e.key, e.cmd) }
|
||||
func (e *cmapExpr) String() string { return fmt.Sprintf("cmap %s %s", e.key, e.expr) }
|
||||
|
||||
type cmdExpr struct {
|
||||
name string
|
||||
@@ -191,23 +191,19 @@ func (p *parser) parseExpr() expr {
|
||||
|
||||
result = &mapExpr{keys, expr}
|
||||
case "cmap":
|
||||
var cmd string
|
||||
var expr expr
|
||||
|
||||
s.scan()
|
||||
key := s.tok
|
||||
|
||||
s.scan()
|
||||
if s.typ != tokenSemicolon {
|
||||
if s.typ != tokenIdent {
|
||||
p.err = fmt.Errorf("expected command: %s", s.tok)
|
||||
}
|
||||
cmd = s.tok
|
||||
expr = p.parseExpr()
|
||||
} else {
|
||||
s.scan()
|
||||
}
|
||||
|
||||
s.scan()
|
||||
|
||||
result = &cmapExpr{key, cmd}
|
||||
result = &cmapExpr{key, expr}
|
||||
case "cmd":
|
||||
var expr expr
|
||||
|
||||
|
||||
@@ -103,8 +103,10 @@ Loop:
|
||||
fmt.Fprintln(c, rest)
|
||||
}
|
||||
} else {
|
||||
if c, ok := gConnList[id]; ok {
|
||||
fmt.Fprintln(c, rest2)
|
||||
if c2, ok := gConnList[id]; ok {
|
||||
fmt.Fprintln(c2, rest2)
|
||||
} else {
|
||||
echoerr(c, "listen: send: no such client id is connected")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -676,7 +676,8 @@ func (ui *ui) loadFileInfo(nav *nav) {
|
||||
func (ui *ui) drawPromptLine(nav *nav) {
|
||||
st := tcell.StyleDefault
|
||||
|
||||
pwd := nav.currDir().path
|
||||
dir := nav.currDir()
|
||||
pwd := dir.path
|
||||
|
||||
if strings.HasPrefix(pwd, gUser.HomeDir) {
|
||||
pwd = filepath.Join("~", strings.TrimPrefix(pwd, gUser.HomeDir))
|
||||
@@ -717,6 +718,12 @@ func (ui *ui) drawPromptLine(nav *nav) {
|
||||
}
|
||||
prompt = strings.Replace(prompt, "%d", pwd, -1)
|
||||
|
||||
if len(dir.filter) != 0 {
|
||||
prompt = strings.Replace(prompt, "%F", fmt.Sprint(dir.filter), -1)
|
||||
} else {
|
||||
prompt = strings.Replace(prompt, "%F", "", -1)
|
||||
}
|
||||
|
||||
ui.promptWin.print(ui.screen, 0, 0, st, prompt)
|
||||
}
|
||||
|
||||
@@ -755,6 +762,10 @@ func (ui *ui) drawStatLine(nav *nav) {
|
||||
selection += fmt.Sprintf(" \033[35;7m %d \033[0m", len(nav.selections))
|
||||
}
|
||||
|
||||
if len(dir.filter) != 0 {
|
||||
selection += " \033[34;7m F \033[0m"
|
||||
}
|
||||
|
||||
var progress string
|
||||
|
||||
if nav.copyTotal > 0 {
|
||||
@@ -836,22 +847,24 @@ func (ui *ui) draw(nav *nav) {
|
||||
ui.drawStatLine(nav)
|
||||
ui.screen.HideCursor()
|
||||
case ">":
|
||||
pos := min(runeSliceWidth(ui.cmdAccLeft), ui.msgWin.w-len(ui.cmdPrefix)-1)
|
||||
prefix := ui.cmdPrefix[:min(ui.msgWin.w-1, len(ui.cmdPrefix))]
|
||||
pos := min(runeSliceWidth(ui.cmdAccLeft), ui.msgWin.w-len(prefix)-1)
|
||||
left := ui.cmdAccLeft[runeSliceWidth(ui.cmdAccLeft)-pos:]
|
||||
right := ui.cmdAccRight
|
||||
ui.msgWin.printLine(ui.screen, 0, 0, st, ui.cmdPrefix)
|
||||
ui.msgWin.print(ui.screen, len(ui.cmdPrefix), 0, st, ui.msg)
|
||||
ui.msgWin.print(ui.screen, len(ui.cmdPrefix)+printLength(ui.msg), 0, st, string(left))
|
||||
ui.msgWin.print(ui.screen, len(ui.cmdPrefix)+printLength(ui.msg)+runeSliceWidth(left), 0, st, string(right))
|
||||
ui.screen.ShowCursor(ui.msgWin.x+len(ui.cmdPrefix)+printLength(ui.msg)+runeSliceWidth(left), ui.msgWin.y)
|
||||
ui.msgWin.printLine(ui.screen, 0, 0, st, prefix)
|
||||
ui.msgWin.print(ui.screen, len(prefix), 0, st, ui.msg)
|
||||
ui.msgWin.print(ui.screen, len(prefix)+printLength(ui.msg), 0, st, string(left))
|
||||
ui.msgWin.print(ui.screen, len(prefix)+printLength(ui.msg)+runeSliceWidth(left), 0, st, string(right))
|
||||
ui.screen.ShowCursor(ui.msgWin.x+len(prefix)+printLength(ui.msg)+runeSliceWidth(left), ui.msgWin.y)
|
||||
default:
|
||||
pos := min(runeSliceWidth(ui.cmdAccLeft), ui.msgWin.w-len(ui.cmdPrefix)-1)
|
||||
prefix := ui.cmdPrefix[:min(ui.msgWin.w-1, len(ui.cmdPrefix))]
|
||||
pos := min(runeSliceWidth(ui.cmdAccLeft), ui.msgWin.w-len(prefix)-1)
|
||||
left := ui.cmdAccLeft[runeSliceWidth(ui.cmdAccLeft)-pos:]
|
||||
right := ui.cmdAccRight
|
||||
ui.msgWin.printLine(ui.screen, 0, 0, st, ui.cmdPrefix)
|
||||
ui.msgWin.print(ui.screen, len(ui.cmdPrefix), 0, st, string(left))
|
||||
ui.msgWin.print(ui.screen, len(ui.cmdPrefix)+runeSliceWidth(left), 0, st, string(right))
|
||||
ui.screen.ShowCursor(ui.msgWin.x+len(ui.cmdPrefix)+runeSliceWidth(left), ui.msgWin.y)
|
||||
ui.msgWin.printLine(ui.screen, 0, 0, st, prefix)
|
||||
ui.msgWin.print(ui.screen, len(prefix), 0, st, string(left))
|
||||
ui.msgWin.print(ui.screen, len(prefix)+runeSliceWidth(left), 0, st, string(right))
|
||||
ui.screen.ShowCursor(ui.msgWin.x+len(prefix)+runeSliceWidth(left), ui.msgWin.y)
|
||||
}
|
||||
|
||||
if gOpts.preview {
|
||||
|
||||
Reference in new issue
Block a user