Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4438721488 | ||
|
|
9e5d386304 | ||
|
|
ed5104cfdb | ||
|
|
fd688c675b | ||
|
|
851e079a82 | ||
|
|
cae9ada56c | ||
|
|
6f525ba047 | ||
|
|
f9382f72d4 | ||
|
|
c1814c8a4e | ||
|
|
90b3b166e1 | ||
|
|
73d1a81d85 | ||
|
|
5d204a1331 | ||
|
|
654a14ea7d | ||
|
|
ce5c5845e7 | ||
|
|
c629b3d4ce | ||
|
|
8dd4be0ddb | ||
|
|
3db3445822 | ||
|
|
fa5623fca8 | ||
|
|
65e593b68f | ||
|
|
70ec01fc3b | ||
|
|
8eb596c670 | ||
|
|
d46ccfc805 | ||
|
|
e8f115848f | ||
|
|
f68406b93c | ||
|
|
c2f2d54cee | ||
|
|
24489924b7 | ||
|
|
f877960661 | ||
|
|
279b0cf250 | ||
|
|
f69c24e357 | ||
|
|
e1cabfbf56 | ||
|
|
6fa6137124 | ||
|
|
17ed724e67 | ||
|
|
228a20ffd1 | ||
|
|
8979e2b260 | ||
|
|
6a286673ce | ||
|
|
4c89535e18 | ||
|
|
88749a3da1 | ||
|
|
cf79726d21 | ||
|
|
50dd374f77 | ||
|
|
1460f49b3e | ||
|
|
969dee3621 | ||
|
|
36798b4c24 | ||
|
|
7a3bd15903 | ||
|
|
76c85d9459 | ||
|
|
355075cf75 | ||
|
|
1186bf6382 | ||
|
|
61442f8880 | ||
|
|
ec512dfe31 | ||
|
|
f248ce77a1 | ||
|
|
3c8b5a5630 | ||
|
|
b608682580 | ||
|
|
ab6549679b | ||
|
|
5e9580500c | ||
|
|
ebf3bcc76b | ||
|
|
f1f28018a6 | ||
|
|
b40ebdcb33 | ||
|
|
4f5b4e6dbf | ||
|
|
4f02cf47c7 | ||
|
|
eab7b61846 | ||
|
|
658af50006 | ||
|
|
bc0000f274 | ||
|
|
24f01f4988 | ||
|
|
d25faf7186 | ||
|
|
e36b1b0484 | ||
|
|
1d95991054 | ||
|
|
fa45a8b649 | ||
|
|
1c8def356d | ||
|
|
25c2f037cb | ||
|
|
143de6e7eb |
No files matched your search
+5
-3
@@ -1,9 +1,11 @@
|
|||||||
language: go
|
language: go
|
||||||
install:
|
|
||||||
- go get github.com/doronbehar/termbox-go
|
go:
|
||||||
- go get gopkg.in/djherbis/times.v1
|
- 1.15.x
|
||||||
|
|
||||||
before_deploy:
|
before_deploy:
|
||||||
- gen/xbuild.sh
|
- gen/xbuild.sh
|
||||||
|
|
||||||
deploy:
|
deploy:
|
||||||
provider: releases
|
provider: releases
|
||||||
api_key:
|
api_key:
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
[](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://godoc.org/github.com/gokcehan/lf)
|
||||||
[](https://gitter.im/lf-fm/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
|
||||||
|
|
||||||
> This is a work in progress. Use at your own risk.
|
> This is a work in progress. Use at your own risk.
|
||||||
|
|
||||||
@@ -42,13 +41,25 @@ See [faq](https://github.com/gokcehan/lf/wiki/FAQ) for more information and [tut
|
|||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
|
See [packages](https://github.com/gokcehan/lf/wiki/Packages) for community maintained packages.
|
||||||
|
|
||||||
See [releases](https://github.com/gokcehan/lf/releases) for pre-built binaries.
|
See [releases](https://github.com/gokcehan/lf/releases) for pre-built binaries.
|
||||||
|
|
||||||
If you like to build from the source:
|
If you like to build from the source on unix:
|
||||||
|
|
||||||
go get -u github.com/gokcehan/lf
|
env CGO_ENABLED=0 GO111MODULE=on go get -u -ldflags="-s -w" github.com/gokcehan/lf
|
||||||
|
|
||||||
See [packages](https://github.com/gokcehan/lf/wiki/Packages) for community maintained packages.
|
On windows `cmd`:
|
||||||
|
|
||||||
|
set CGO_ENABLED=0
|
||||||
|
set GO111MODULE=on
|
||||||
|
go get -u -ldflags="-s -w" github.com/gokcehan/lf
|
||||||
|
|
||||||
|
On windows `powershell`:
|
||||||
|
|
||||||
|
$env:CGO_ENABLED = '0'
|
||||||
|
$env:GO111MODULE = 'on'
|
||||||
|
go get -u -ldflags="-s -w" github.com/gokcehan/lf
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/gdamore/tcell/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
type cmdItem struct {
|
type cmdItem struct {
|
||||||
@@ -32,29 +34,34 @@ type app struct {
|
|||||||
cmdHistoryInd int
|
cmdHistoryInd int
|
||||||
}
|
}
|
||||||
|
|
||||||
func newApp() *app {
|
func newApp(screen tcell.Screen) *app {
|
||||||
ui := newUI()
|
ui := newUI(screen)
|
||||||
nav := newNav(ui.wins[0].h)
|
nav := newNav(ui.wins[0].h)
|
||||||
|
|
||||||
quitChan := make(chan bool, 1)
|
quitChan := make(chan bool, 1)
|
||||||
|
|
||||||
osChan := make(chan os.Signal, 1)
|
app := &app{
|
||||||
signal.Notify(osChan, os.Interrupt, syscall.SIGHUP, syscall.SIGTERM)
|
|
||||||
go func() {
|
|
||||||
<-osChan
|
|
||||||
nav.copyTotalChan <- -nav.copyTotal
|
|
||||||
nav.moveTotalChan <- -nav.moveTotal
|
|
||||||
nav.deleteTotalChan <- -nav.deleteTotal
|
|
||||||
quitChan <- true
|
|
||||||
return
|
|
||||||
}()
|
|
||||||
|
|
||||||
return &app{
|
|
||||||
ui: ui,
|
ui: ui,
|
||||||
nav: nav,
|
nav: nav,
|
||||||
ticker: new(time.Ticker),
|
ticker: new(time.Ticker),
|
||||||
quitChan: quitChan,
|
quitChan: quitChan,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sigChan := make(chan os.Signal, 1)
|
||||||
|
signal.Notify(sigChan, os.Interrupt, syscall.SIGHUP, syscall.SIGQUIT, syscall.SIGTERM)
|
||||||
|
go func() {
|
||||||
|
switch <-sigChan {
|
||||||
|
case os.Interrupt:
|
||||||
|
return
|
||||||
|
case syscall.SIGHUP, syscall.SIGQUIT, syscall.SIGTERM:
|
||||||
|
app.writeHistory()
|
||||||
|
os.Remove(gLogPath)
|
||||||
|
os.Exit(3)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
return app
|
||||||
}
|
}
|
||||||
|
|
||||||
func (app *app) readFile(path string) {
|
func (app *app) readFile(path string) {
|
||||||
@@ -91,6 +98,12 @@ func (app *app) readHistory() error {
|
|||||||
scanner := bufio.NewScanner(f)
|
scanner := bufio.NewScanner(f)
|
||||||
for scanner.Scan() {
|
for scanner.Scan() {
|
||||||
toks := strings.SplitN(scanner.Text(), " ", 2)
|
toks := strings.SplitN(scanner.Text(), " ", 2)
|
||||||
|
if toks[0] != ":" && toks[0] != "$" && toks[0] != "%" && toks[0] != "!" && toks[0] != "&" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if len(toks) < 2 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
app.cmdHistory = append(app.cmdHistory, cmdItem{toks[0], toks[1]})
|
app.cmdHistory = append(app.cmdHistory, cmdItem{toks[0], toks[1]})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -147,9 +160,10 @@ 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() {
|
||||||
clientChan := app.ui.readExpr()
|
|
||||||
serverChan := readExpr()
|
serverChan := readExpr()
|
||||||
|
|
||||||
|
app.ui.readExpr()
|
||||||
|
|
||||||
if gSelect != "" {
|
if gSelect != "" {
|
||||||
go func() {
|
go func() {
|
||||||
lstat, err := os.Lstat(gSelect)
|
lstat, err := os.Lstat(gSelect)
|
||||||
@@ -308,7 +322,27 @@ func (app *app) loop() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
app.ui.draw(app.nav)
|
app.ui.draw(app.nav)
|
||||||
case e := <-clientChan:
|
case ev := <-app.ui.evChan:
|
||||||
|
e := app.ui.readEvent(ev)
|
||||||
|
if e == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
e.eval(app, nil)
|
||||||
|
loop:
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
case ev := <-app.ui.evChan:
|
||||||
|
e = app.ui.readEvent(ev)
|
||||||
|
if e == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
e.eval(app, nil)
|
||||||
|
default:
|
||||||
|
break loop
|
||||||
|
}
|
||||||
|
}
|
||||||
|
app.ui.draw(app.nav)
|
||||||
|
case e := <-app.ui.exprChan:
|
||||||
e.eval(app, nil)
|
e.eval(app, nil)
|
||||||
app.ui.draw(app.nav)
|
app.ui.draw(app.nav)
|
||||||
case e := <-serverChan:
|
case e := <-serverChan:
|
||||||
@@ -356,6 +390,7 @@ func waitKey() error {
|
|||||||
// & No Yes No No No Do nothing
|
// & No Yes No No No Do nothing
|
||||||
func (app *app) runShell(s string, args []string, prefix string) {
|
func (app *app) runShell(s string, args []string, prefix string) {
|
||||||
app.exportFiles()
|
app.exportFiles()
|
||||||
|
exportOpts()
|
||||||
|
|
||||||
cmd := shellCommand(s, args)
|
cmd := shellCommand(s, args)
|
||||||
|
|
||||||
@@ -401,7 +436,6 @@ func (app *app) runShell(s string, args []string, prefix string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
app.ui.loadFile(app.nav)
|
app.ui.loadFile(app.nav)
|
||||||
app.ui.loadFileInfo(app.nav)
|
|
||||||
|
|
||||||
switch prefix {
|
switch prefix {
|
||||||
case "%":
|
case "%":
|
||||||
@@ -411,17 +445,25 @@ func (app *app) runShell(s string, args []string, prefix string) {
|
|||||||
app.ui.cmdPrefix = ">"
|
app.ui.cmdPrefix = ">"
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
|
eol := false
|
||||||
reader := bufio.NewReader(out)
|
reader := bufio.NewReader(out)
|
||||||
for {
|
for {
|
||||||
b, err := reader.ReadByte()
|
b, err := reader.ReadByte()
|
||||||
if err == io.EOF {
|
if err == io.EOF {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
app.cmdOutBuf = append(app.cmdOutBuf, b)
|
if eol {
|
||||||
app.ui.exprChan <- &callExpr{"echo", []string{string(app.cmdOutBuf)}, 1}
|
eol = false
|
||||||
if b == '\n' || b == '\r' {
|
|
||||||
app.cmdOutBuf = nil
|
app.cmdOutBuf = nil
|
||||||
}
|
}
|
||||||
|
app.cmdOutBuf = append(app.cmdOutBuf, b)
|
||||||
|
if b == '\n' || b == '\r' {
|
||||||
|
eol = true
|
||||||
|
}
|
||||||
|
if reader.Buffered() > 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
app.ui.exprChan <- &callExpr{"echo", []string{string(app.cmdOutBuf)}, 1}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := cmd.Wait(); err != nil {
|
if err := cmd.Wait(); err != nil {
|
||||||
|
|||||||
@@ -10,16 +10,17 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/doronbehar/termbox-go"
|
"github.com/gdamore/tcell/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
func run() {
|
func run() {
|
||||||
if err := termbox.Init(); err != nil {
|
var screen tcell.Screen
|
||||||
log.Fatalf("initializing termbox: %s", err)
|
var err error
|
||||||
|
if screen, err = tcell.NewScreen(); err != nil {
|
||||||
|
log.Fatalf("creating screen: %s", err)
|
||||||
|
} else if err = screen.Init(); err != nil {
|
||||||
|
log.Fatalf("initializing screen: %s", err)
|
||||||
}
|
}
|
||||||
defer termbox.Close()
|
|
||||||
|
|
||||||
setColorMode()
|
|
||||||
|
|
||||||
f, err := os.Create(gLogPath)
|
f, err := os.Create(gLogPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -31,7 +32,7 @@ func run() {
|
|||||||
|
|
||||||
log.Print("hi!")
|
log.Print("hi!")
|
||||||
|
|
||||||
app := newApp()
|
app := newApp(screen)
|
||||||
|
|
||||||
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)
|
||||||
@@ -42,6 +43,7 @@ func run() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
app.loop()
|
app.loop()
|
||||||
|
app.ui.screen.Fini()
|
||||||
}
|
}
|
||||||
|
|
||||||
func readExpr() <-chan expr {
|
func readExpr() <-chan expr {
|
||||||
|
|||||||
@@ -7,48 +7,18 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/doronbehar/termbox-go"
|
"github.com/gdamore/tcell/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
const gAnsiColorResetMask = termbox.AttrBold | termbox.AttrUnderline | termbox.AttrReverse
|
type styleMap map[string]tcell.Style
|
||||||
|
|
||||||
var gAnsiCodes = map[int]termbox.Attribute{
|
func parseStyles() styleMap {
|
||||||
0: termbox.ColorDefault,
|
|
||||||
1: termbox.AttrBold,
|
|
||||||
4: termbox.AttrUnderline,
|
|
||||||
7: termbox.AttrReverse,
|
|
||||||
30: termbox.ColorBlack,
|
|
||||||
31: termbox.ColorRed,
|
|
||||||
32: termbox.ColorGreen,
|
|
||||||
33: termbox.ColorYellow,
|
|
||||||
34: termbox.ColorBlue,
|
|
||||||
35: termbox.ColorMagenta,
|
|
||||||
36: termbox.ColorCyan,
|
|
||||||
37: termbox.ColorWhite,
|
|
||||||
40: termbox.ColorBlack,
|
|
||||||
41: termbox.ColorRed,
|
|
||||||
42: termbox.ColorGreen,
|
|
||||||
43: termbox.ColorYellow,
|
|
||||||
44: termbox.ColorBlue,
|
|
||||||
45: termbox.ColorMagenta,
|
|
||||||
46: termbox.ColorCyan,
|
|
||||||
47: termbox.ColorWhite,
|
|
||||||
}
|
|
||||||
|
|
||||||
type colorEntry struct {
|
|
||||||
fg termbox.Attribute
|
|
||||||
bg termbox.Attribute
|
|
||||||
}
|
|
||||||
|
|
||||||
type colorMap map[string]colorEntry
|
|
||||||
|
|
||||||
func parseColors() colorMap {
|
|
||||||
if env := os.Getenv("LS_COLORS"); env != "" {
|
if env := os.Getenv("LS_COLORS"); env != "" {
|
||||||
return parseColorsGNU(env)
|
return parseStylesGNU(env)
|
||||||
}
|
}
|
||||||
|
|
||||||
if env := os.Getenv("LSCOLORS"); env != "" {
|
if env := os.Getenv("LSCOLORS"); env != "" {
|
||||||
return parseColorsBSD(env)
|
return parseStylesBSD(env)
|
||||||
}
|
}
|
||||||
|
|
||||||
// default values from dircolors with removed background colors
|
// default values from dircolors with removed background colors
|
||||||
@@ -73,10 +43,10 @@ func parseColors() colorMap {
|
|||||||
"ex=01;32",
|
"ex=01;32",
|
||||||
}
|
}
|
||||||
|
|
||||||
return parseColorsGNU(strings.Join(defaultColors, ":"))
|
return parseStylesGNU(strings.Join(defaultColors, ":"))
|
||||||
}
|
}
|
||||||
|
|
||||||
func applyAnsiCodes(s string, fg, bg termbox.Attribute) (termbox.Attribute, termbox.Attribute) {
|
func applyAnsiCodes(s string, st tcell.Style) tcell.Style {
|
||||||
toks := strings.Split(s, ";")
|
toks := strings.Split(s, ";")
|
||||||
|
|
||||||
var nums []int
|
var nums []int
|
||||||
@@ -93,43 +63,71 @@ func applyAnsiCodes(s string, fg, bg termbox.Attribute) (termbox.Attribute, term
|
|||||||
nums = append(nums, n)
|
nums = append(nums, n)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ECMA-48 details the standard
|
||||||
|
// TODO: should we support turning off attributes?
|
||||||
|
// Probably because this is used for previewers too
|
||||||
for i := 0; i < len(nums); i++ {
|
for i := 0; i < len(nums); i++ {
|
||||||
n := nums[i]
|
n := nums[i]
|
||||||
switch {
|
switch {
|
||||||
case n == 38 && i+2 < len(nums) && nums[i+1] == 5:
|
|
||||||
fg &= gAnsiColorResetMask
|
|
||||||
fg |= termbox.Attribute(nums[i+2] + 1)
|
|
||||||
i += 2
|
|
||||||
continue
|
|
||||||
case n == 48 && i+2 < len(nums) && nums[i+1] == 5:
|
|
||||||
bg = termbox.Attribute(nums[i+2] + 1)
|
|
||||||
i += 2
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
attr, ok := gAnsiCodes[n]
|
|
||||||
if !ok {
|
|
||||||
log.Printf("unknown ansi code: %d", n)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
switch {
|
|
||||||
case n == 0:
|
case n == 0:
|
||||||
fg, bg = attr, attr
|
st = tcell.StyleDefault
|
||||||
case n == 1 || n == 4 || n == 7:
|
case n == 1:
|
||||||
fg |= attr
|
st = st.Bold(true)
|
||||||
case 30 <= n && n <= 37:
|
case n == 2:
|
||||||
fg &= gAnsiColorResetMask
|
st = st.Dim(true)
|
||||||
fg |= attr
|
case n == 4:
|
||||||
case 40 <= n && n <= 47:
|
st = st.Underline(true)
|
||||||
bg = attr
|
case n == 5 || n == 6:
|
||||||
|
st = st.Blink(true)
|
||||||
|
case n == 7:
|
||||||
|
st = st.Reverse(true)
|
||||||
|
case n == 8:
|
||||||
|
// TODO: tcell PR for proper conceal
|
||||||
|
_, bg, _ := st.Decompose()
|
||||||
|
st = st.Foreground(bg)
|
||||||
|
case n == 9:
|
||||||
|
st = st.StrikeThrough(true)
|
||||||
|
case n >= 30 && n <= 37:
|
||||||
|
st = st.Foreground(tcell.PaletteColor(n - 30))
|
||||||
|
case n == 38:
|
||||||
|
if i+3 <= len(nums) && nums[i+1] == 5 {
|
||||||
|
st = st.Foreground(tcell.PaletteColor(nums[i+2]))
|
||||||
|
i += 2
|
||||||
|
} else if i+5 <= len(nums) && nums[i+1] == 2 {
|
||||||
|
st = st.Foreground(tcell.NewRGBColor(
|
||||||
|
int32(nums[i+2]),
|
||||||
|
int32(nums[i+3]),
|
||||||
|
int32(nums[i+4])))
|
||||||
|
i += 4
|
||||||
|
} else {
|
||||||
|
log.Printf("unknown ansi code or incorrect form: %d", n)
|
||||||
|
}
|
||||||
|
case n >= 40 && n <= 47:
|
||||||
|
st = st.Background(tcell.PaletteColor(n - 40))
|
||||||
|
case n == 48:
|
||||||
|
if i+3 <= len(nums) && nums[i+1] == 5 {
|
||||||
|
st = st.Background(tcell.PaletteColor(nums[i+2]))
|
||||||
|
i += 2
|
||||||
|
} else if i+5 <= len(nums) && nums[i+1] == 2 {
|
||||||
|
st = st.Background(tcell.NewRGBColor(
|
||||||
|
int32(nums[i+2]),
|
||||||
|
int32(nums[i+3]),
|
||||||
|
int32(nums[i+4])))
|
||||||
|
i += 4
|
||||||
|
} else {
|
||||||
|
log.Printf("unknown ansi code or incorrect form: %d", n)
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
log.Printf("unknown ansi code: %d", n)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return fg, bg
|
return st
|
||||||
}
|
}
|
||||||
|
|
||||||
// This function parses $LS_COLORS environment variable.
|
// This function parses $LS_COLORS environment variable.
|
||||||
func parseColorsGNU(env string) colorMap {
|
func parseStylesGNU(env string) styleMap {
|
||||||
colors := make(colorMap)
|
styles := make(styleMap)
|
||||||
|
|
||||||
entries := strings.Split(env, ":")
|
entries := strings.Split(env, ":")
|
||||||
for _, entry := range entries {
|
for _, entry := range entries {
|
||||||
@@ -139,63 +137,62 @@ func parseColorsGNU(env string) colorMap {
|
|||||||
pair := strings.Split(entry, "=")
|
pair := strings.Split(entry, "=")
|
||||||
if len(pair) != 2 {
|
if len(pair) != 2 {
|
||||||
log.Printf("invalid $LS_COLORS entry: %s", entry)
|
log.Printf("invalid $LS_COLORS entry: %s", entry)
|
||||||
return colors
|
return styles
|
||||||
}
|
}
|
||||||
key, val := pair[0], pair[1]
|
key, val := pair[0], pair[1]
|
||||||
fg, bg := applyAnsiCodes(val, termbox.ColorDefault, termbox.ColorDefault)
|
styles[key] = applyAnsiCodes(val, tcell.StyleDefault)
|
||||||
colors[key] = colorEntry{fg: fg, bg: bg}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return colors
|
return styles
|
||||||
}
|
}
|
||||||
|
|
||||||
// This function parses $LSCOLORS environment variable.
|
// This function parses $LSCOLORS environment variable.
|
||||||
func parseColorsBSD(env string) colorMap {
|
func parseStylesBSD(env string) styleMap {
|
||||||
colors := make(colorMap)
|
styles := make(styleMap)
|
||||||
|
|
||||||
if len(env) != 22 {
|
if len(env) != 22 {
|
||||||
log.Printf("invalid $LSCOLORS variable: %s", env)
|
log.Printf("invalid $LSCOLORS variable: %s", env)
|
||||||
return colors
|
return styles
|
||||||
}
|
}
|
||||||
|
|
||||||
colorNames := []string{"di", "ln", "so", "pi", "ex", "bd", "cd", "su", "sg", "tw", "ow"}
|
colorNames := []string{"di", "ln", "so", "pi", "ex", "bd", "cd", "su", "sg", "tw", "ow"}
|
||||||
colorCodes := map[byte]termbox.Attribute{
|
|
||||||
'a': termbox.ColorBlack,
|
|
||||||
'b': termbox.ColorRed,
|
|
||||||
'c': termbox.ColorGreen,
|
|
||||||
'd': termbox.ColorYellow, // brown
|
|
||||||
'e': termbox.ColorBlue,
|
|
||||||
'f': termbox.ColorMagenta,
|
|
||||||
'g': termbox.ColorCyan,
|
|
||||||
'h': termbox.ColorWhite, // light grey
|
|
||||||
'A': termbox.AttrBold | termbox.ColorBlack,
|
|
||||||
'B': termbox.AttrBold | termbox.ColorRed,
|
|
||||||
'C': termbox.AttrBold | termbox.ColorGreen,
|
|
||||||
'D': termbox.AttrBold | termbox.ColorYellow, // brown
|
|
||||||
'E': termbox.AttrBold | termbox.ColorBlue,
|
|
||||||
'F': termbox.AttrBold | termbox.ColorMagenta,
|
|
||||||
'G': termbox.AttrBold | termbox.ColorCyan,
|
|
||||||
'H': termbox.AttrBold | termbox.ColorWhite, // light grey
|
|
||||||
'x': termbox.ColorDefault,
|
|
||||||
}
|
|
||||||
|
|
||||||
getColor := func(r byte) termbox.Attribute {
|
getStyle := func(r1, r2 byte) tcell.Style {
|
||||||
if color, ok := colorCodes[r]; ok {
|
st := tcell.StyleDefault
|
||||||
return color
|
|
||||||
|
switch {
|
||||||
|
case r1 == 'x':
|
||||||
|
st = st.Foreground(tcell.ColorDefault)
|
||||||
|
case 'A' <= r1 && r1 <= 'H':
|
||||||
|
st = st.Foreground(tcell.PaletteColor(int(r1 - 'A'))).Bold(true)
|
||||||
|
case 'a' <= r1 && r1 <= 'h':
|
||||||
|
st = st.Foreground(tcell.PaletteColor(int(r1 - 'a')))
|
||||||
|
default:
|
||||||
|
log.Printf("invalid $LSCOLORS entry: %c", r1)
|
||||||
|
return tcell.StyleDefault
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("invalid $LSCOLORS entry: %c", r)
|
switch {
|
||||||
return termbox.ColorDefault
|
case r2 == 'x':
|
||||||
|
st = st.Background(tcell.ColorDefault)
|
||||||
|
case 'a' <= r2 && r2 <= 'h':
|
||||||
|
st = st.Background(tcell.PaletteColor(int(r2 - 'a')))
|
||||||
|
default:
|
||||||
|
log.Printf("invalid $LSCOLORS entry: %c", r2)
|
||||||
|
return tcell.StyleDefault
|
||||||
|
}
|
||||||
|
|
||||||
|
return st
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, key := range colorNames {
|
for i, key := range colorNames {
|
||||||
colors[key] = colorEntry{fg: getColor(env[i*2]), bg: getColor(env[i*2+1])}
|
styles[key] = getStyle(env[i*2], env[i*2+1])
|
||||||
}
|
}
|
||||||
|
|
||||||
return colors
|
return styles
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cm colorMap) get(f *file) (termbox.Attribute, termbox.Attribute) {
|
func (cm styleMap) get(f *file) tcell.Style {
|
||||||
var key string
|
var key string
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
@@ -230,12 +227,12 @@ func (cm colorMap) get(f *file) (termbox.Attribute, termbox.Attribute) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if val, ok := cm[key]; ok {
|
if val, ok := cm[key]; ok {
|
||||||
return val.fg, val.bg
|
return val
|
||||||
}
|
}
|
||||||
|
|
||||||
if val, ok := cm["fi"]; ok {
|
if val, ok := cm["fi"]; ok {
|
||||||
return val.fg, val.bg
|
return val
|
||||||
}
|
}
|
||||||
|
|
||||||
return termbox.ColorDefault, termbox.ColorDefault
|
return tcell.StyleDefault
|
||||||
}
|
}
|
||||||
+51
-47
@@ -3,75 +3,79 @@ package main
|
|||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/doronbehar/termbox-go"
|
"github.com/gdamore/tcell/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestApplyAnsiCodes(t *testing.T) {
|
func TestApplyAnsiCodes(t *testing.T) {
|
||||||
none := termbox.ColorDefault
|
none := tcell.StyleDefault
|
||||||
|
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
s string
|
s string
|
||||||
fg termbox.Attribute
|
st tcell.Style
|
||||||
bg termbox.Attribute
|
stExp tcell.Style
|
||||||
fgExp termbox.Attribute
|
|
||||||
bgExp termbox.Attribute
|
|
||||||
}{
|
}{
|
||||||
{"", none, none, none, none},
|
{"", none, none},
|
||||||
{"", termbox.ColorRed, termbox.ColorRed, none, none},
|
{"", none.Foreground(tcell.ColorMaroon).Background(tcell.ColorMaroon), none},
|
||||||
{"", termbox.AttrBold, none, none, none},
|
{"", none.Bold(true), none},
|
||||||
{"", termbox.ColorRed | termbox.AttrBold, none, none, none},
|
{"", none.Foreground(tcell.ColorMaroon).Bold(true), none},
|
||||||
|
|
||||||
{"0", none, none, none, none},
|
{"0", none, none},
|
||||||
{"0", termbox.ColorRed, termbox.ColorRed, none, none},
|
{"0", none.Foreground(tcell.ColorMaroon).Background(tcell.ColorMaroon), none},
|
||||||
{"0", termbox.AttrBold, none, none, none},
|
{"0", none.Bold(true), none},
|
||||||
{"0", termbox.ColorRed | termbox.AttrBold, none, none, none},
|
{"0", none.Foreground(tcell.ColorMaroon).Bold(true), none},
|
||||||
|
|
||||||
{"1", none, none, termbox.AttrBold, none},
|
{"1", none, none.Bold(true)},
|
||||||
{"4", none, none, termbox.AttrUnderline, none},
|
{"4", none, none.Underline(true)},
|
||||||
{"7", none, none, termbox.AttrReverse, none},
|
{"7", none, none.Reverse(true)},
|
||||||
|
|
||||||
{"1", termbox.ColorRed, none, termbox.ColorRed | termbox.AttrBold, none},
|
{"1", none.Foreground(tcell.ColorMaroon), none.Foreground(tcell.ColorMaroon).Bold(true)},
|
||||||
{"4", termbox.ColorRed, none, termbox.ColorRed | termbox.AttrUnderline, none},
|
{"4", none.Foreground(tcell.ColorMaroon), none.Foreground(tcell.ColorMaroon).Underline(true)},
|
||||||
{"7", termbox.ColorRed, none, termbox.ColorRed | termbox.AttrReverse, none},
|
{"7", none.Foreground(tcell.ColorMaroon), none.Foreground(tcell.ColorMaroon).Reverse(true)},
|
||||||
|
|
||||||
{"4", termbox.AttrBold, none, termbox.AttrBold | termbox.AttrUnderline, none},
|
{"4", none.Bold(true), none.Bold(true).Underline(true)},
|
||||||
{"4", termbox.ColorRed | termbox.AttrBold, none, termbox.ColorRed | termbox.AttrBold | termbox.AttrUnderline, none},
|
{"4", none.Foreground(tcell.ColorMaroon).Bold(true), none.Foreground(tcell.ColorMaroon).Bold(true).Underline(true)},
|
||||||
|
|
||||||
{"31", none, none, termbox.ColorRed, none},
|
{"31", none, none.Foreground(tcell.ColorMaroon)},
|
||||||
{"31", termbox.ColorGreen, none, termbox.ColorRed, none},
|
{"31", none.Foreground(tcell.ColorGreen), none.Foreground(tcell.ColorMaroon)},
|
||||||
{"31", termbox.ColorGreen | termbox.AttrBold, none, termbox.ColorRed | termbox.AttrBold, none},
|
{"31", none.Foreground(tcell.ColorGreen).Bold(true), none.Foreground(tcell.ColorMaroon).Bold(true)},
|
||||||
|
|
||||||
{"41", none, none, none, termbox.ColorRed},
|
{"41", none, none.Background(tcell.ColorMaroon)},
|
||||||
{"41", none, termbox.ColorGreen, none, termbox.ColorRed},
|
{"41", none.Background(tcell.ColorGreen), none.Background(tcell.ColorMaroon)},
|
||||||
|
|
||||||
{"1;31", none, none, termbox.ColorRed | termbox.AttrBold, none},
|
{"1;31", none, none.Foreground(tcell.ColorMaroon).Bold(true)},
|
||||||
{"1;31", termbox.ColorGreen, none, termbox.ColorRed | termbox.AttrBold, none},
|
{"1;31", none.Foreground(tcell.ColorGreen), none.Foreground(tcell.ColorMaroon).Bold(true)},
|
||||||
|
|
||||||
{"38;5;0", none, none, termbox.ColorBlack, none},
|
{"38;5;0", none, none.Foreground(tcell.ColorBlack)},
|
||||||
{"38;5;1", none, none, termbox.ColorRed, none},
|
{"38;5;1", none, none.Foreground(tcell.ColorMaroon)},
|
||||||
{"38;5;8", none, none, termbox.Attribute(9), none},
|
{"38;5;8", none, none.Foreground(tcell.ColorGray)},
|
||||||
{"38;5;16", none, none, termbox.Attribute(17), none},
|
{"38;5;16", none, none.Foreground(tcell.Color16)},
|
||||||
{"38;5;232", none, none, termbox.Attribute(233), none},
|
{"38;5;232", none, none.Foreground(tcell.Color232)},
|
||||||
|
|
||||||
{"38;5;1", termbox.ColorGreen, none, termbox.ColorRed, none},
|
{"38;5;1", none.Foreground(tcell.ColorGreen), none.Foreground(tcell.ColorMaroon)},
|
||||||
{"38;5;1", termbox.ColorGreen | termbox.AttrBold, none, termbox.ColorRed | termbox.AttrBold, none},
|
{"38;5;1", none.Foreground(tcell.ColorGreen).Bold(true), none.Foreground(tcell.ColorMaroon).Bold(true)},
|
||||||
|
|
||||||
{"48;5;0", none, none, none, termbox.ColorBlack},
|
{"48;5;0", none, none.Background(tcell.ColorBlack)},
|
||||||
{"48;5;1", none, none, none, termbox.ColorRed},
|
{"48;5;1", none, none.Background(tcell.ColorMaroon)},
|
||||||
{"48;5;8", none, none, none, termbox.Attribute(9)},
|
{"48;5;8", none, none.Background(tcell.ColorGray)},
|
||||||
{"48;5;16", none, none, none, termbox.Attribute(17)},
|
{"48;5;16", none, none.Background(tcell.Color16)},
|
||||||
{"48;5;232", none, none, none, termbox.Attribute(233)},
|
{"48;5;232", none, none.Background(tcell.Color232)},
|
||||||
|
|
||||||
{"48;5;1", none, termbox.ColorGreen, none, termbox.ColorRed},
|
{"48;5;1", none.Background(tcell.ColorGreen), none.Background(tcell.ColorMaroon)},
|
||||||
|
|
||||||
{"1;38;5;1", none, none, termbox.ColorRed | termbox.AttrBold, none},
|
{"1;38;5;1", none, none.Foreground(tcell.ColorMaroon).Bold(true)},
|
||||||
{"1;38;5;1", termbox.ColorGreen, none, termbox.ColorRed | termbox.AttrBold, none},
|
{"1;38;5;1", none.Foreground(tcell.ColorGreen), none.Foreground(tcell.ColorMaroon).Bold(true)},
|
||||||
|
|
||||||
|
{"38;2;5;102;8", none, none.Foreground(tcell.NewRGBColor(5, 102, 8))},
|
||||||
|
{"48;2;0;48;143", none, none.Background(tcell.NewRGBColor(0, 48, 143))},
|
||||||
|
|
||||||
|
// Fixes color construction issue: https://github.com/gokcehan/lf/pull/439#issuecomment-674409446
|
||||||
|
{"38;5;34;1", none, none.Foreground(tcell.Color34).Bold(true)},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
if fgGot, bgGot := applyAnsiCodes(test.s, test.fg, test.bg); fgGot != test.fgExp || bgGot != test.bgExp {
|
if stGot := applyAnsiCodes(test.s, test.st); stGot != test.stExp {
|
||||||
t.Errorf("at input '%s' with '%d' and '%d' expected '%d' and '%d' but got '%d' and '%d'",
|
t.Errorf("at input '%s' with '%d' expected '%d' but got '%d'",
|
||||||
test.s, test.fg, test.bg, test.fgExp, test.bgExp, fgGot, bgGot)
|
test.s, test.st, test.stExp, stGot)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -70,9 +70,6 @@ var (
|
|||||||
"anchorfind",
|
"anchorfind",
|
||||||
"noanchorfind",
|
"noanchorfind",
|
||||||
"anchorfind!",
|
"anchorfind!",
|
||||||
"color256",
|
|
||||||
"nocolor256",
|
|
||||||
"color256!",
|
|
||||||
"dircounts",
|
"dircounts",
|
||||||
"nodircounts",
|
"nodircounts",
|
||||||
"dircounts!",
|
"dircounts!",
|
||||||
|
|||||||
+676
-121
@@ -15,10 +15,11 @@ command (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.
|
||||||
|
|
||||||
|
|
||||||
Reference
|
Quick Reference
|
||||||
|
|
||||||
The following commands are provided by lf with default keybindings:
|
The following commands are provided by lf:
|
||||||
|
|
||||||
|
quit (default 'q')
|
||||||
up (default 'k' and '<up>')
|
up (default 'k' and '<up>')
|
||||||
half-up (default '<c-u>')
|
half-up (default '<c-u>')
|
||||||
page-up (default '<c-b>' and '<pgup>')
|
page-up (default '<c-b>' and '<pgup>')
|
||||||
@@ -27,146 +28,134 @@ The following commands are provided by lf with default keybindings:
|
|||||||
page-down (default '<c-f>' and '<pgdn>')
|
page-down (default '<c-f>' and '<pgdn>')
|
||||||
updir (default 'h' and '<left>')
|
updir (default 'h' and '<left>')
|
||||||
open (default 'l' and '<right>')
|
open (default 'l' and '<right>')
|
||||||
quit (default 'q')
|
|
||||||
top (default 'gg' and '<home>')
|
top (default 'gg' and '<home>')
|
||||||
bottom (default 'G' and '<end>')
|
bottom (default 'G' and '<end>')
|
||||||
|
toggle
|
||||||
invert (default 'v')
|
invert (default 'v')
|
||||||
unselect (default 'u')
|
unselect (default 'u')
|
||||||
|
glob-select
|
||||||
|
glob-unselect
|
||||||
copy (default 'y')
|
copy (default 'y')
|
||||||
cut (default 'd')
|
cut (default 'd')
|
||||||
paste (default 'p')
|
paste (default 'p')
|
||||||
clear (default 'c')
|
clear (default 'c')
|
||||||
|
sync
|
||||||
|
draw
|
||||||
redraw (default '<c-l>')
|
redraw (default '<c-l>')
|
||||||
|
load
|
||||||
reload (default '<c-r>')
|
reload (default '<c-r>')
|
||||||
read (default ':')
|
echo
|
||||||
rename (default 'r')
|
echomsg
|
||||||
shell (default '$')
|
echoerr
|
||||||
shell-pipe (default '%')
|
cd
|
||||||
shell-wait (default '!')
|
select
|
||||||
shell-async (default '&')
|
delete (modal)
|
||||||
find (default 'f')
|
rename (modal) (default 'r')
|
||||||
find-back (default 'F')
|
source
|
||||||
|
push
|
||||||
|
read (modal) (default ':')
|
||||||
|
shell (modal) (default '$')
|
||||||
|
shell-pipe (modal) (default '%')
|
||||||
|
shell-wait (modal) (default '!')
|
||||||
|
shell-async (modal) (default '&')
|
||||||
|
find (modal) (default 'f')
|
||||||
|
find-back (modal) (default 'F')
|
||||||
find-next (default ';')
|
find-next (default ';')
|
||||||
find-prev (default ',')
|
find-prev (default ',')
|
||||||
search (default '/')
|
search (modal) (default '/')
|
||||||
search-back (default '?')
|
search-back (modal) (default '?')
|
||||||
search-next (default 'n')
|
search-next (default 'n')
|
||||||
search-prev (default 'N')
|
search-prev (default 'N')
|
||||||
mark-save (default 'm')
|
mark-save (modal) (default 'm')
|
||||||
mark-load (default "'")
|
mark-load (modal) (default "'")
|
||||||
mark-remove (default '"')
|
mark-remove (modal) (default '"')
|
||||||
|
|
||||||
The following commands are provided by lf without default keybindings:
|
The following command line commands are provided by lf:
|
||||||
|
|
||||||
draw draw the ui
|
|
||||||
load load modified files and directories
|
|
||||||
sync synchronize copied/cut files with server
|
|
||||||
echo print arguments to the message line
|
|
||||||
echomsg same as echo but logging
|
|
||||||
echoerr same as echomsg but red color
|
|
||||||
cd change working directory to the argument
|
|
||||||
select change current file selection to the argument
|
|
||||||
toggle toggle the selection of the current file or its arguments
|
|
||||||
glob-select select files that match the given glob
|
|
||||||
glob-unselect unselect files that match the given glob
|
|
||||||
source read the configuration file in the argument
|
|
||||||
push simulate key pushes given in the argument
|
|
||||||
delete remove the current file or selected file(s)
|
|
||||||
|
|
||||||
The following command line commands are provided by lf with default
|
|
||||||
keybindings:
|
|
||||||
|
|
||||||
cmd-escape (default '<esc>')
|
cmd-escape (default '<esc>')
|
||||||
cmd-complete (default '<tab>')
|
cmd-complete (default '<tab>')
|
||||||
|
cmd-menu-complete
|
||||||
|
cmd-menu-complete-back
|
||||||
cmd-enter (default '<c-j>' and '<enter>')
|
cmd-enter (default '<c-j>' and '<enter>')
|
||||||
|
cmd-interrupt (default '<c-c>')
|
||||||
cmd-history-next (default '<c-n>')
|
cmd-history-next (default '<c-n>')
|
||||||
cmd-history-prev (default '<c-p>')
|
cmd-history-prev (default '<c-p>')
|
||||||
cmd-delete (default '<c-d>' and '<delete>')
|
|
||||||
cmd-delete-back (default '<bs>' and '<bs2>')
|
|
||||||
cmd-left (default '<c-b>' and '<left>')
|
cmd-left (default '<c-b>' and '<left>')
|
||||||
cmd-right (default '<c-f>' and '<right>')
|
cmd-right (default '<c-f>' and '<right>')
|
||||||
cmd-home (default '<c-a>' and '<home>')
|
cmd-home (default '<c-a>' and '<home>')
|
||||||
cmd-end (default '<c-e>' and '<end>')
|
cmd-end (default '<c-e>' and '<end>')
|
||||||
|
cmd-delete (default '<c-d>' and '<delete>')
|
||||||
|
cmd-delete-back (default '<backspace>' and '<backspace2>')
|
||||||
cmd-delete-home (default '<c-u>')
|
cmd-delete-home (default '<c-u>')
|
||||||
cmd-delete-end (default '<c-k>')
|
cmd-delete-end (default '<c-k>')
|
||||||
cmd-delete-unix-word (default '<c-w>')
|
cmd-delete-unix-word (default '<c-w>')
|
||||||
cmd-yank (default '<c-y>')
|
cmd-yank (default '<c-y>')
|
||||||
cmd-transpose (default '<c-t>')
|
cmd-transpose (default '<c-t>')
|
||||||
cmd-interrupt (default '<c-c>')
|
cmd-transpose-word (default '<a-t>')
|
||||||
cmd-word (default '<a-f>')
|
cmd-word (default '<a-f>')
|
||||||
cmd-word-back (default '<a-b>')
|
cmd-word-back (default '<a-b>')
|
||||||
cmd-capitalize-word (default '<a-c>')
|
|
||||||
cmd-delete-word (default '<a-d>')
|
cmd-delete-word (default '<a-d>')
|
||||||
|
cmd-capitalize-word (default '<a-c>')
|
||||||
cmd-uppercase-word (default '<a-u>')
|
cmd-uppercase-word (default '<a-u>')
|
||||||
cmd-lowercase-word (default '<a-l>')
|
cmd-lowercase-word (default '<a-l>')
|
||||||
cmd-transpose-word (default '<a-t>')
|
|
||||||
|
|
||||||
The following options can be used to customize the behavior of lf:
|
The following options can be used to customize the behavior of lf:
|
||||||
|
|
||||||
anchorfind boolean (default on)
|
anchorfind bool (default on)
|
||||||
color256 boolean (default off)
|
dircounts bool (default off)
|
||||||
dircounts boolean (default off)
|
dirfirst bool (default on)
|
||||||
dirfirst boolean (default on)
|
drawbox bool (default off)
|
||||||
drawbox boolean (default off)
|
errorfmt string (default "\033[7;31;47m%s\033[0m")
|
||||||
globsearch boolean (default off)
|
filesep string (default "\n")
|
||||||
hidden boolean (default off)
|
findlen int (default 1)
|
||||||
icons boolean (default off)
|
globsearch bool (default off)
|
||||||
ignorecase boolean (default on)
|
hidden bool (default off)
|
||||||
ignoredia boolean (default off)
|
hiddenfiles []string (default '.*')
|
||||||
incsearch boolean (default off)
|
icons bool (default off)
|
||||||
number boolean (default off)
|
ifs string (default '')
|
||||||
preview boolean (default on)
|
ignorecase bool (default on)
|
||||||
relativenumber boolean (default off)
|
ignoredia bool (default on)
|
||||||
reverse boolean (default off)
|
incsearch bool (default off)
|
||||||
smartcase boolean (default on)
|
info []string (default '')
|
||||||
smartdia boolean (default off)
|
number bool (default off)
|
||||||
wrapscan boolean (default on)
|
period int (default 0)
|
||||||
wrapscroll boolean (default off)
|
preview bool (default on)
|
||||||
findlen integer (default 1) (zero to prompt until single match)
|
previewer string (default '')
|
||||||
period integer (default 0) (zero to disable periodic loading)
|
promptfmt string (default "\033[32;1m%u@%h\033[0m:\033[34;1m%w\033[0m\033[1m%f\033[0m")
|
||||||
scrolloff integer (default 0)
|
ratios []int (default '1:2:3')
|
||||||
tabstop integer (default 8)
|
relativenumber bool (default off)
|
||||||
errorfmt string (default "\033[7;31;47m%s\033[0m")
|
reverse bool (default off)
|
||||||
filesep string (default "\n")
|
scrolloff int (default 0)
|
||||||
hiddenfiles string (default '.*')
|
shell string (default 'sh' for unix and 'cmd' for windows)
|
||||||
ifs string (default '') (not exported if empty)
|
shellopts []string (default '')
|
||||||
info string (default '')
|
smartcase bool (default on)
|
||||||
previewer string (default '') (not filtered if empty)
|
smartdia bool (default off)
|
||||||
promptfmt string (default "\033[32;1m%u@%h\033[0m:\033[34;1m%w/\033[0m\033[1m%f\033[0m")
|
sortby string (default 'natural')
|
||||||
ratios string (default '1:2:3')
|
tabstop int (default 8)
|
||||||
shell string (default 'sh')
|
timefmt string (default 'Mon Jan _2 15:04:05 2006')
|
||||||
shellopts string (default '')
|
truncatechar string (default '~')
|
||||||
sortby string (default 'natural')
|
wrapscan bool (default on)
|
||||||
timefmt string (default 'Mon Jan _2 15:04:05 2006')
|
wrapscroll bool (default off)
|
||||||
truncatechar string (default '~')
|
|
||||||
|
|
||||||
The following variables are exported for shell commands:
|
The following environment variables are exported for shell commands:
|
||||||
|
|
||||||
$f current file
|
f
|
||||||
$fs selected file(s) separated with 'filesep'
|
fs
|
||||||
$fx current file or selected file(s) if any
|
fx
|
||||||
$id id number of the client
|
id
|
||||||
|
LF_LEVEL
|
||||||
|
OPENER
|
||||||
|
EDITOR
|
||||||
|
PAGER
|
||||||
|
SHELL
|
||||||
|
|
||||||
The following variables are set to the corresponding values:
|
The following commands/keybindings are provided by default:
|
||||||
|
|
||||||
$LF_LEVEL current nesting level
|
unix windows
|
||||||
|
cmd open &$OPENER "$f" cmd open &%OPENER% %f%
|
||||||
The following default values are set to the environmental variables on unix
|
map e $$EDITOR "$f" map e $%EDITOR% %f%
|
||||||
when they are not set or empty:
|
map i $$PAGER "$f" map i !%PAGER% %f%
|
||||||
|
map w $$SHELL map w $%SHELL%
|
||||||
$OPENER open # macos
|
|
||||||
$OPENER xdg-open # others
|
|
||||||
$EDITOR vi
|
|
||||||
$PAGER less
|
|
||||||
$SHELL sh
|
|
||||||
|
|
||||||
The following default values are set to the environmental variables on
|
|
||||||
windows when they are not set or empty:
|
|
||||||
|
|
||||||
%OPENER% start
|
|
||||||
%EDITOR% notepad
|
|
||||||
%PAGER% more
|
|
||||||
%SHELL% cmd
|
|
||||||
|
|
||||||
The following additional keybindings are provided by default:
|
The following additional keybindings are provided by default:
|
||||||
|
|
||||||
@@ -185,12 +174,6 @@ The following additional keybindings are provided by default:
|
|||||||
map gh cd ~
|
map gh cd ~
|
||||||
map <space> :toggle; down
|
map <space> :toggle; down
|
||||||
|
|
||||||
The following keybindings to applications are provided by default:
|
|
||||||
|
|
||||||
map e $$EDITOR $f
|
|
||||||
map i $$PAGER $f
|
|
||||||
map w $$SHELL
|
|
||||||
|
|
||||||
|
|
||||||
Configuration
|
Configuration
|
||||||
|
|
||||||
@@ -222,6 +205,568 @@ A sample configuration file can be found at
|
|||||||
https://github.com/gokcehan/lf/blob/master/etc/lfrc.example.
|
https://github.com/gokcehan/lf/blob/master/etc/lfrc.example.
|
||||||
|
|
||||||
|
|
||||||
|
Commands
|
||||||
|
|
||||||
|
This section shows information about builtin commands. Modal commands do not
|
||||||
|
take any arguments, but instead change the operation mode to read their
|
||||||
|
input conveniently, and so they are meant to be assigned to keybindings.
|
||||||
|
|
||||||
|
quit (default 'q')
|
||||||
|
|
||||||
|
Quit lf and return to the shell.
|
||||||
|
|
||||||
|
up (default 'k' and '<up>')
|
||||||
|
half-up (default '<c-u>')
|
||||||
|
page-up (default '<c-b>' and '<pgup>')
|
||||||
|
down (default 'j' and '<down>')
|
||||||
|
half-down (default '<c-d>')
|
||||||
|
page-down (default '<c-f>' and '<pgdn>')
|
||||||
|
|
||||||
|
Move the current file selection upwards/downwards by one/half a page/full
|
||||||
|
page.
|
||||||
|
|
||||||
|
updir (default 'h' and '<left>')
|
||||||
|
|
||||||
|
Change the current working directory to the parent directory.
|
||||||
|
|
||||||
|
open (default 'l' and '<right>')
|
||||||
|
|
||||||
|
If the current file is a directory, then change the current directory to it,
|
||||||
|
otherwise, execute the 'open' command. A default 'open' command is provided
|
||||||
|
to call the default system opener asynchronously with the current file as
|
||||||
|
the argument. A custom 'open' command can be defined to override this
|
||||||
|
default.
|
||||||
|
|
||||||
|
(See also 'OPENER' variable and 'Opening Files' section)
|
||||||
|
|
||||||
|
top (default 'gg' and '<home>')
|
||||||
|
bottom (default 'G' and '<end>')
|
||||||
|
|
||||||
|
Move the current file selection to the top/bottom of the directory.
|
||||||
|
|
||||||
|
toggle
|
||||||
|
|
||||||
|
Toggle the selection of the current file or files given as arguments.
|
||||||
|
|
||||||
|
invert (default 'v')
|
||||||
|
|
||||||
|
Reverse the selection of all files in the current directory (i.e. 'toggle'
|
||||||
|
all files). Selections in other directories are not effected by this
|
||||||
|
command. You can define a new command to select all files in the directory
|
||||||
|
by combining 'invert' with 'unselect' (i.e. 'cmd select-all :unselect;
|
||||||
|
invert'), though this will also remove selections in other directories.
|
||||||
|
|
||||||
|
unselect (default 'u')
|
||||||
|
|
||||||
|
Remove the selection of all files in all directories.
|
||||||
|
|
||||||
|
glob-select
|
||||||
|
|
||||||
|
Select files that match the given glob.
|
||||||
|
|
||||||
|
glob-unselect
|
||||||
|
|
||||||
|
Unselect files that match the given glob.
|
||||||
|
|
||||||
|
copy (default 'y')
|
||||||
|
|
||||||
|
If there are no selections, save the path of the current file to the copy
|
||||||
|
buffer, otherwise, copy the paths of selected files.
|
||||||
|
|
||||||
|
cut (default 'd')
|
||||||
|
|
||||||
|
If there are no selections, save the path of the current file to the cut
|
||||||
|
buffer, otherwise, copy the paths of selected files.
|
||||||
|
|
||||||
|
paste (default 'p')
|
||||||
|
|
||||||
|
Copy/Move files in copy/cut buffer to the current working directory.
|
||||||
|
|
||||||
|
clear (default 'c')
|
||||||
|
|
||||||
|
Clear file paths in copy/cut buffer.
|
||||||
|
|
||||||
|
sync
|
||||||
|
|
||||||
|
Synchronize copied/cut files with server. This command is automatically
|
||||||
|
called when required.
|
||||||
|
|
||||||
|
draw
|
||||||
|
|
||||||
|
Draw the screen. This command is automatically called when required.
|
||||||
|
|
||||||
|
redraw (default '<c-l>')
|
||||||
|
|
||||||
|
Synchronize the terminal and redraw the screen.
|
||||||
|
|
||||||
|
load
|
||||||
|
|
||||||
|
Load modified files and directories. This command is automatically called
|
||||||
|
when required.
|
||||||
|
|
||||||
|
reload (default '<c-r>')
|
||||||
|
|
||||||
|
Flush the cache and reload all files and directories.
|
||||||
|
|
||||||
|
echo
|
||||||
|
|
||||||
|
Print given arguments to the message line at the bottom.
|
||||||
|
|
||||||
|
echomsg
|
||||||
|
|
||||||
|
Print given arguments to the message line at the bottom and also to the log
|
||||||
|
file.
|
||||||
|
|
||||||
|
echoerr
|
||||||
|
|
||||||
|
Print given arguments to the message line at the bottom in red color and
|
||||||
|
also to the log file.
|
||||||
|
|
||||||
|
cd
|
||||||
|
|
||||||
|
Change the working directory to the given argument.
|
||||||
|
|
||||||
|
select
|
||||||
|
|
||||||
|
Change the current file selection to the given argument.
|
||||||
|
|
||||||
|
delete (modal)
|
||||||
|
|
||||||
|
Remove the current file or selected file(s).
|
||||||
|
|
||||||
|
rename (modal) (default 'r')
|
||||||
|
|
||||||
|
Rename the current file using the builtin method. A custom 'rename' command
|
||||||
|
can be defined to override this default.
|
||||||
|
|
||||||
|
source
|
||||||
|
|
||||||
|
Read the configuration file given in the argument.
|
||||||
|
|
||||||
|
push
|
||||||
|
|
||||||
|
Simulate key pushes given in the argument.
|
||||||
|
|
||||||
|
read (modal) (default ':')
|
||||||
|
|
||||||
|
Read a command to evaluate.
|
||||||
|
|
||||||
|
shell (modal) (default '$')
|
||||||
|
|
||||||
|
Read a shell command to execute.
|
||||||
|
|
||||||
|
(See also 'Prefixes' and 'Shell Commands' sections)
|
||||||
|
|
||||||
|
shell-pipe (modal) (default '%')
|
||||||
|
|
||||||
|
Read a shell command to execute piping its standard I/O to the bottom
|
||||||
|
statline.
|
||||||
|
|
||||||
|
(See also 'Prefixes' and 'Piping Shell Commands' sections)
|
||||||
|
|
||||||
|
shell-wait (modal) (default '!')
|
||||||
|
|
||||||
|
Read a shell command to execute and wait for a key press in the end.
|
||||||
|
|
||||||
|
(See also 'Prefixes' and 'Waiting Shell Commands' sections)
|
||||||
|
|
||||||
|
shell-async (modal) (default '&')
|
||||||
|
|
||||||
|
Read a shell command to execute synchronously without standard I/O.
|
||||||
|
|
||||||
|
find (modal) (default 'f')
|
||||||
|
find-back (modal) (default 'F')
|
||||||
|
find-next (default ';')
|
||||||
|
find-prev (default ',')
|
||||||
|
|
||||||
|
Read key(s) to find the appropriate file name match in the forward/backward
|
||||||
|
direction and jump to the next/previous match.
|
||||||
|
|
||||||
|
(See also 'anchorfind', 'findlen', 'wrapscan', 'ignorecase', 'smartcase',
|
||||||
|
'ignoredia', and 'smartdia' options and 'Searching Files' section)
|
||||||
|
|
||||||
|
search (default '/')
|
||||||
|
search-back (default '?')
|
||||||
|
search-next (default 'n')
|
||||||
|
search-prev (default 'N')
|
||||||
|
|
||||||
|
Read a pattern to search for a file name match in the forward/backward
|
||||||
|
direction and jump to the next/previous match.
|
||||||
|
|
||||||
|
(See also 'globsearch', 'incsearch', 'wrapscan', 'ignorecase', 'smartcase',
|
||||||
|
'ignoredia', and 'smartdia' options and 'Searching Files' section)
|
||||||
|
|
||||||
|
mark-save (modal) (default 'm')
|
||||||
|
|
||||||
|
Save the current directory as a bookmark assigned to the given key.
|
||||||
|
|
||||||
|
mark-load (modal) (default "'")
|
||||||
|
|
||||||
|
Change the current directory to the bookmark assigned to the given key. A
|
||||||
|
special bookmark "'" holds the previous directory after a 'mark-load', 'cd',
|
||||||
|
or 'select' command.
|
||||||
|
|
||||||
|
mark-remove (modal) (default '"')
|
||||||
|
|
||||||
|
Remove a bookmark assigned to the given key.
|
||||||
|
|
||||||
|
|
||||||
|
Command Line Commands
|
||||||
|
|
||||||
|
This section shows information about command line commands. These should be
|
||||||
|
mostly compatible with readline keybindings. A character refers to a unicode
|
||||||
|
code point, a word consists of letters and digits, and a unix word consists
|
||||||
|
of any non-blank characters.
|
||||||
|
|
||||||
|
cmd-escape (default '<esc>')
|
||||||
|
|
||||||
|
Quit command line mode and return to normal mode.
|
||||||
|
|
||||||
|
cmd-complete (default '<tab>')
|
||||||
|
|
||||||
|
Autocomplete the current word.
|
||||||
|
|
||||||
|
cmd-menu-complete
|
||||||
|
|
||||||
|
Autocomplete the current word, then you can press the binded key/s again to
|
||||||
|
cycle completition options.
|
||||||
|
|
||||||
|
cmd-menu-complete-back
|
||||||
|
|
||||||
|
Autocomplete the current word, then you can press the binded key/s again to
|
||||||
|
cycle completition options backwards.
|
||||||
|
|
||||||
|
cmd-enter (default '<c-j>' and '<enter>')
|
||||||
|
|
||||||
|
Execute the current line.
|
||||||
|
|
||||||
|
cmd-interrupt (default '<c-c>')
|
||||||
|
|
||||||
|
Interrupt the current shell-pipe command and return to the normal mode.
|
||||||
|
|
||||||
|
cmd-history-next (default '<c-n>')
|
||||||
|
cmd-history-prev (default '<c-p>')
|
||||||
|
|
||||||
|
Go to next/previous item in the history.
|
||||||
|
|
||||||
|
cmd-left (default '<c-b>' and '<left>')
|
||||||
|
cmd-right (default '<c-f>' and '<right>')
|
||||||
|
|
||||||
|
Move the cursor to the left/right.
|
||||||
|
|
||||||
|
cmd-home (default '<c-a>' and '<home>')
|
||||||
|
cmd-end (default '<c-e>' and '<end>')
|
||||||
|
|
||||||
|
Move the cursor to the beginning/end of line.
|
||||||
|
|
||||||
|
cmd-delete (default '<c-d>' and '<delete>')
|
||||||
|
cmd-delete-back (default '<backspace>' and '<backspace2>')
|
||||||
|
|
||||||
|
Delete the next character in forward/backward direction.
|
||||||
|
|
||||||
|
cmd-delete-home (default '<c-u>')
|
||||||
|
cmd-delete-end (default '<c-k>')
|
||||||
|
|
||||||
|
Delete everything up to the beginning/end of line.
|
||||||
|
|
||||||
|
cmd-delete-unix-word (default '<c-w>')
|
||||||
|
|
||||||
|
Delete the previous unix word.
|
||||||
|
|
||||||
|
cmd-yank (default '<c-y>')
|
||||||
|
|
||||||
|
Paste the buffer content containing the last deleted item.
|
||||||
|
|
||||||
|
cmd-transpose (default '<c-t>')
|
||||||
|
cmd-transpose-word (default '<a-t>')
|
||||||
|
|
||||||
|
Transpose the positions of last two characters/words.
|
||||||
|
|
||||||
|
cmd-word (default '<a-f>')
|
||||||
|
cmd-word-back (default '<a-b>')
|
||||||
|
|
||||||
|
Move the cursor by one word in forward/backward direction.
|
||||||
|
|
||||||
|
cmd-delete-word (default '<a-d>')
|
||||||
|
|
||||||
|
Delete the next word in forward direction.
|
||||||
|
|
||||||
|
cmd-capitalize-word (default '<a-c>')
|
||||||
|
cmd-uppercase-word (default '<a-u>')
|
||||||
|
cmd-lowercase-word (default '<a-l>')
|
||||||
|
|
||||||
|
Capitalize/uppercase/lowercase the current word and jump to the next word.
|
||||||
|
|
||||||
|
|
||||||
|
Options
|
||||||
|
|
||||||
|
This section shows information about options to customize the behavior.
|
||||||
|
Character ':' is used as the separator for list options '[]int' and
|
||||||
|
'[]string'.
|
||||||
|
|
||||||
|
anchorfind bool (default on)
|
||||||
|
|
||||||
|
When this option is enabled, find command starts matching patterns from the
|
||||||
|
beginning of file names, otherwise, it can match at an arbitrary position.
|
||||||
|
|
||||||
|
dircounts bool (default off)
|
||||||
|
|
||||||
|
When this option is enabled, directory sizes show the number of items inside
|
||||||
|
instead of the size of directory file. The former needs to be calculated by
|
||||||
|
reading the directory and counting the items inside. The latter is directly
|
||||||
|
provided by the operating system and it does not require any calculation,
|
||||||
|
though it is non-intuitive and it can often be misleading. This option is
|
||||||
|
disabled by default for performance reasons. This option only has an effect
|
||||||
|
when 'info' has a 'size' field and the pane is wide enough to show the
|
||||||
|
information. A thousand items are counted per directory at most, and bigger
|
||||||
|
directories are shown as '999+'.
|
||||||
|
|
||||||
|
dirfirst bool (default on)
|
||||||
|
|
||||||
|
Show directories first above regular files.
|
||||||
|
|
||||||
|
drawbox bool (default off)
|
||||||
|
|
||||||
|
Draw boxes around panes with box drawing characters.
|
||||||
|
|
||||||
|
errorfmt string (default "\033[7;31;47m%s\033[0m")
|
||||||
|
|
||||||
|
Format string of error messages shown in the bottom message line.
|
||||||
|
|
||||||
|
filesep string (default "\n")
|
||||||
|
|
||||||
|
File separator used in environment variables 'fs' and 'fx'.
|
||||||
|
|
||||||
|
findlen int (default 1)
|
||||||
|
|
||||||
|
Number of characters prompted for the find command. When this value is set
|
||||||
|
to 0, find command prompts until there is only a single match left.
|
||||||
|
|
||||||
|
globsearch bool (default off)
|
||||||
|
|
||||||
|
When this option is enabled, search command patterns are considered as
|
||||||
|
globs, otherwise they are literals. With globbing, '*' matches any sequence,
|
||||||
|
'?' matches any character, and '[...]' or '[^...] matches character sets or
|
||||||
|
ranges. Otherwise, these characters are interpreted as they are.
|
||||||
|
|
||||||
|
hidden bool (default off)
|
||||||
|
|
||||||
|
Show hidden files. On unix systems, hidden files are determined by the value
|
||||||
|
of 'hiddenfiles'. On windows, only files with hidden attributes are
|
||||||
|
considered hidden files.
|
||||||
|
|
||||||
|
hiddenfiles []string (default '.*')
|
||||||
|
|
||||||
|
List of hidden file glob patterns. Patterns can be given as relative or
|
||||||
|
absolute paths. Globbing supports the usual special characters, '*' to match
|
||||||
|
any sequence, '?' to match any character, and '[...]' or '[^...] to match
|
||||||
|
character sets or ranges. In addition, if a pattern starts with '!', then
|
||||||
|
its matches are excluded from hidden files.
|
||||||
|
|
||||||
|
icons bool (default off)
|
||||||
|
|
||||||
|
Show icons before each item in the list. By default, only two icons, 🗀
|
||||||
|
(U+1F5C0) and 🗎 (U+1F5CE), are used for directories and files respectively,
|
||||||
|
as they are supported in the unicode standard. Icons can be configured with
|
||||||
|
an environment variable named 'LF_ICONS'. The syntax of this variable is
|
||||||
|
similar to 'LS_COLORS'. See the wiki page for an example icon configuration.
|
||||||
|
|
||||||
|
ifs string (default '')
|
||||||
|
|
||||||
|
Sets 'IFS' variable in shell commands. It works by adding the assignment to
|
||||||
|
the beginning of the command string as 'IFS='...'; ...'. The reason is that
|
||||||
|
'IFS' variable is not inherited by the shell for security reasons. This
|
||||||
|
method assumes a POSIX shell syntax and so it can fail for non-POSIX shells.
|
||||||
|
This option has no effect when the value is left empty. This option does not
|
||||||
|
have any effect on windows.
|
||||||
|
|
||||||
|
ignorecase bool (default on)
|
||||||
|
|
||||||
|
Ignore case in sorting and search patterns.
|
||||||
|
|
||||||
|
ignoredia bool (default on)
|
||||||
|
|
||||||
|
Ignore diacritics in sorting and search patterns.
|
||||||
|
|
||||||
|
incsearch bool (default off)
|
||||||
|
|
||||||
|
Jump to the first match after each keystroke during searching.
|
||||||
|
|
||||||
|
info []string (default '')
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
number bool (default off)
|
||||||
|
|
||||||
|
Show the position number for directory items at the left side of pane. When
|
||||||
|
'relativenumber' is enabled, only the current line shows the absolute
|
||||||
|
position and relative positions are shown for the rest.
|
||||||
|
|
||||||
|
period int (default 0)
|
||||||
|
|
||||||
|
Set the interval in seconds for periodic checks of directory updates. This
|
||||||
|
works by periodically calling the 'load' command. Note that directories are
|
||||||
|
already updated automatically in many cases. This option can be useful when
|
||||||
|
there is an external process changing the displayed directory and you are
|
||||||
|
not doing anything in lf. Periodic checks are disabled when the value of
|
||||||
|
this option is set to zero.
|
||||||
|
|
||||||
|
preview bool (default on)
|
||||||
|
|
||||||
|
Show previews of files and directories at the right most pane. If the file
|
||||||
|
has more lines than the preview pane, rest of the lines are not read. Files
|
||||||
|
containing the null character (U+0000) in the read portion are considered
|
||||||
|
binary files and displayed as 'binary'.
|
||||||
|
|
||||||
|
previewer string (default '') (not filtered if empty)
|
||||||
|
|
||||||
|
Set the path of a previewer file to filter the content of regular files for
|
||||||
|
previewing. The file should be executable. Two arguments are passed to the
|
||||||
|
file, first is the current file name, and second is the height of preview
|
||||||
|
pane. SIGPIPE signal is sent when enough lines are read. Preview filtering
|
||||||
|
is disabled and files are displayed as they are when the value of this
|
||||||
|
option is left empty.
|
||||||
|
|
||||||
|
promptfmt string (default "\033[32;1m%u@%h\033[0m:\033[34;1m%w/\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, 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.
|
||||||
|
|
||||||
|
ratios []int (default '1:2:3')
|
||||||
|
|
||||||
|
List of ratios of pane widths. Number of items in the list determines the
|
||||||
|
number of panes in the ui. When 'preview' option is enabled, the right most
|
||||||
|
number is used for the width of preview pane.
|
||||||
|
|
||||||
|
relativenumber bool (default off)
|
||||||
|
|
||||||
|
Show the position number relative to the current line. When 'number' is
|
||||||
|
enabled, current line shows the absolute position, otherwise nothing is
|
||||||
|
shown.
|
||||||
|
|
||||||
|
reverse bool (default off)
|
||||||
|
|
||||||
|
Reverse the direction of sort.
|
||||||
|
|
||||||
|
scrolloff int (default 0)
|
||||||
|
|
||||||
|
Minimum number of offset lines shown at all times in the top and the bottom
|
||||||
|
of the screen when scrolling. The current line is kept in the middle when
|
||||||
|
this option is set to a large value that is bigger than the half of number
|
||||||
|
of lines. A smaller offset can be used when the current file is close to the
|
||||||
|
beginning or end of the list to show the maximum number of items.
|
||||||
|
|
||||||
|
shell string (default 'sh' for unix and 'cmd' for windows)
|
||||||
|
|
||||||
|
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'.
|
||||||
|
|
||||||
|
shellopts []string (default '')
|
||||||
|
|
||||||
|
List of shell options to pass to the shell executable.
|
||||||
|
|
||||||
|
smartcase bool (default on)
|
||||||
|
|
||||||
|
Override 'ignorecase' option when the pattern contains an uppercase
|
||||||
|
character. This option has no effect when 'ignorecase' is disabled.
|
||||||
|
|
||||||
|
smartdia bool (default off)
|
||||||
|
|
||||||
|
Override 'ignoredia' option when the pattern contains a character with
|
||||||
|
diacritic. This option has no effect when 'ignoredia' is disabled.
|
||||||
|
|
||||||
|
sortby string (default 'natural')
|
||||||
|
|
||||||
|
Sort type for directories. Currently supported sort types are 'natural',
|
||||||
|
'name', 'size', 'time', 'ctime', 'atime', and 'ext'.
|
||||||
|
|
||||||
|
tabstop int (default 8)
|
||||||
|
|
||||||
|
Number of space characters to show for horizontal tabulation (U+0009)
|
||||||
|
character.
|
||||||
|
|
||||||
|
timefmt string (default 'Mon Jan _2 15:04:05 2006')
|
||||||
|
|
||||||
|
Format string of the file modification time shown in the bottom line.
|
||||||
|
|
||||||
|
truncatechar string (default '~')
|
||||||
|
|
||||||
|
Truncate character shown at the end when the file name does not fit to the
|
||||||
|
pane.
|
||||||
|
|
||||||
|
wrapscan bool (default on)
|
||||||
|
|
||||||
|
Searching can wrap around the file list.
|
||||||
|
|
||||||
|
wrapscroll bool (default off)
|
||||||
|
|
||||||
|
Scrolling can wrap around the file list.
|
||||||
|
|
||||||
|
|
||||||
|
Environment Variables
|
||||||
|
|
||||||
|
The following variables are exported for shell commands: These are referred
|
||||||
|
with a '$' prefix on POSIX shells (e.g. '$f'), between '%' characters on
|
||||||
|
Windows cmd (e.g. '%f%'), and with a '$env:' prefix on Windows powershell
|
||||||
|
(e.g. '$env:f').
|
||||||
|
|
||||||
|
f
|
||||||
|
|
||||||
|
Current file selection as a full path.
|
||||||
|
|
||||||
|
fs
|
||||||
|
|
||||||
|
Selected file(s) separated with the value of 'filesep' option as full
|
||||||
|
path(s).
|
||||||
|
|
||||||
|
fx
|
||||||
|
|
||||||
|
Selected file(s) (i.e. 'fs') if there are any selected files, otherwise
|
||||||
|
current file selection (i.e. 'f').
|
||||||
|
|
||||||
|
id
|
||||||
|
|
||||||
|
Id of the running client.
|
||||||
|
|
||||||
|
LF_LEVEL
|
||||||
|
|
||||||
|
The value of this variable is set to the current nesting level when you run
|
||||||
|
lf from a shell spawned inside lf. You can add the value of this variable to
|
||||||
|
your shell prompt to make it clear that your shell runs inside lf. For
|
||||||
|
example, with POSIX shells, you can use '[ -n "$LF_LEVEL" ] &&
|
||||||
|
PS1="$PS1""(lf level: $LF_LEVEL) "' in your shell configuration file (e.g.
|
||||||
|
'~/.bashrc').
|
||||||
|
|
||||||
|
OPENER
|
||||||
|
|
||||||
|
If this variable is set in the environment, use the same value, otherwise
|
||||||
|
set the value to 'start' in Windows, 'open' in MacOS, 'xdg-open' in others.
|
||||||
|
|
||||||
|
EDITOR
|
||||||
|
|
||||||
|
If this variable is set in the environment, use the same value, otherwise
|
||||||
|
set the value to 'vi' on unix, 'notepad' in Windows.
|
||||||
|
|
||||||
|
PAGER
|
||||||
|
|
||||||
|
If this variable is set in the environment, use the same value, otherwise
|
||||||
|
set the value to 'less' on unix, 'more' in Windows.
|
||||||
|
|
||||||
|
SHELL
|
||||||
|
|
||||||
|
If this variable is set in the environment, use the same value, otherwise
|
||||||
|
set the value to 'sh' on unix, 'cmd' in Windows.
|
||||||
|
|
||||||
|
|
||||||
Prefixes
|
Prefixes
|
||||||
|
|
||||||
The following command prefixes are used by lf:
|
The following command prefixes are used by lf:
|
||||||
@@ -451,9 +996,7 @@ statline. For example, an alternative rename command may look like this:
|
|||||||
|
|
||||||
cmd rename %[ -e $1 ] && printf "file exists" || mv $f $1
|
cmd rename %[ -e $1 ] && printf "file exists" || mv $f $1
|
||||||
|
|
||||||
One thing to be careful is that although input is still line buffered,
|
Note that input is line buffered and output and error are byte buffered.
|
||||||
output and error are byte buffered and verbose commands will be very slow to
|
|
||||||
display.
|
|
||||||
|
|
||||||
|
|
||||||
Waiting Shell Commands
|
Waiting Shell Commands
|
||||||
@@ -698,6 +1241,13 @@ any:
|
|||||||
set previewer ~/.config/lf/pv.sh
|
set previewer ~/.config/lf/pv.sh
|
||||||
map i $~/.config/lf/pv.sh $f | less -R
|
map i $~/.config/lf/pv.sh $f | less -R
|
||||||
|
|
||||||
|
For 'less' pager, you may instead utilize 'LESSOPEN' mechanism so that
|
||||||
|
useful information about the file such as the full path of the file can be
|
||||||
|
displayed in the statusline below:
|
||||||
|
|
||||||
|
set previewer ~/.config/lf/pv.sh
|
||||||
|
map i $LESSOPEN='| ~/.config/lf/pv.sh %s' less -R $f
|
||||||
|
|
||||||
Since this script is called for each file selection change it needs to be as
|
Since this script is called for each file selection change it needs to be as
|
||||||
efficient as possible and this responsibility is left to the user. You may
|
efficient as possible and this responsibility is left to the user. You may
|
||||||
use file extensions to determine the type of file more efficiently compared
|
use file extensions to determine the type of file more efficiently compared
|
||||||
@@ -725,6 +1275,11 @@ 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.
|
the first portion of the file to a program for preview.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
|
||||||
Changing Directory
|
Changing Directory
|
||||||
|
|
||||||
@@ -780,19 +1335,19 @@ If both of these environment variables are not set, then lf fallbacks to its
|
|||||||
default colorscheme. Default lf colors are taken from GNU dircolors
|
default colorscheme. Default lf colors are taken from GNU dircolors
|
||||||
defaults. These defaults use 8 basic colors and bold attribute.
|
defaults. These defaults use 8 basic colors and bold attribute.
|
||||||
|
|
||||||
You should also note that lf uses 8 color mode by default which uses sgr
|
It is worth noting that lf uses as many colors are advertised by your
|
||||||
3-bit color escapes (e.g. '\033[34m'). If you want to use 256 colors, you
|
terminal's entry in your systems terminfo or infocmp database, if this is
|
||||||
need to enable 'color256' option which then makes lf use sgr 8-bit color
|
not present lf will default to an internal database. For terminals
|
||||||
escapes (e.g. '\033[38;5;4m'). This option is intended to eliminate
|
supporting 24-bit (or "true") color that do not have a database entry (or
|
||||||
differences between default colors used by ls and lf since terminals may
|
one that does not advertise all capabilities), support can be enabled by
|
||||||
render 3-bit and 8-bit escapes differently even for the same color.
|
either setting the '$COLORTERM' variable to "truecolor" or ensuring '$TERM'
|
||||||
|
is set to a value that ends with "-truecolor".
|
||||||
|
|
||||||
Keeping this mechanism in mind, you can configure lf colors in two different
|
Keeping this in mind, you can configure lf colors in two different ways.
|
||||||
ways. First, you can configure 8 basic colors used by your terminal and lf
|
First, you can configure 8 basic colors used by your terminal and lf should
|
||||||
should pick up those colors automatically. Depending on your terminal, you
|
pick up those colors automatically. Depending on your terminal, you should
|
||||||
should be able to select your colors from a 24-bit palette. This is the
|
be able to select your colors from a 24-bit palette. This is the recommended
|
||||||
recommended approach as colors used by other programs will also match each
|
approach as colors used by other programs will also match each other.
|
||||||
other.
|
|
||||||
|
|
||||||
Second, you can set the values of environmental variables mentioned above
|
Second, you can set the values of environmental variables mentioned above
|
||||||
for fine grained customization. This is useful to change colors used for
|
for fine grained customization. This is useful to change colors used for
|
||||||
|
|||||||
+29
@@ -0,0 +1,29 @@
|
|||||||
|
# Autocompletion for bash shell.
|
||||||
|
#
|
||||||
|
# You may put this file to a directory used by bash-completion:
|
||||||
|
#
|
||||||
|
# mkdir -p ~/.local/share/bash-completion/completions
|
||||||
|
# ln -s "/path/to/lf.bash" ~/.local/share/bash-completion/completions
|
||||||
|
#
|
||||||
|
|
||||||
|
_lf () {
|
||||||
|
local -a opts=(
|
||||||
|
-command
|
||||||
|
-cpuprofile
|
||||||
|
-doc
|
||||||
|
-last-dir-path
|
||||||
|
-memprofile
|
||||||
|
-remote
|
||||||
|
-selection-path
|
||||||
|
-server
|
||||||
|
-version
|
||||||
|
-help
|
||||||
|
)
|
||||||
|
if [[ $2 == -* ]]; then
|
||||||
|
COMPREPLY=( $(compgen -W "${opts[*]}" -- "$2") )
|
||||||
|
else
|
||||||
|
COMPREPLY=( $(compgen -f -d -- "$2") )
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
complete -o filenames -F _lf lf lfcd
|
||||||
+2
-2
@@ -7,9 +7,9 @@
|
|||||||
#
|
#
|
||||||
# You may also like to assign a key to this command:
|
# You may also like to assign a key to this command:
|
||||||
#
|
#
|
||||||
# bind \co 'lfcd; commandline -f repaint'
|
# bind \co 'stty sane; lfcd; commandline -f repaint'
|
||||||
#
|
#
|
||||||
# You need to put this in a function called fish_user_key_bindings.
|
# You may put this in a function called fish_user_key_bindings.
|
||||||
|
|
||||||
function lfcd
|
function lfcd
|
||||||
set tmp (mktemp)
|
set tmp (mktemp)
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
# interpreter for shell commands
|
||||||
|
set shell cmd
|
||||||
|
|
||||||
|
# Shell commands with multiline definitions and/or positional arguments and/or
|
||||||
|
# quotes do not work in Windows. For anything but the simplest shell commands,
|
||||||
|
# it is recommended to create separate script files and simply call them here
|
||||||
|
# in commands or mappings.
|
||||||
|
|
||||||
|
# change the editor used in default editor keybinding
|
||||||
|
# There is no builtin terminal editor installed in Windows. The default editor
|
||||||
|
# mapping uses 'notepad' which launches in a separate GUI window. You may
|
||||||
|
# instead install a terminal editor of your choice and replace the default
|
||||||
|
# editor keybinding accordingly.
|
||||||
|
map e $vim %f%
|
||||||
|
|
||||||
|
# change the pager used in default pager keybinding
|
||||||
|
# The standard pager used in Windows is 'more' which is not a very capable
|
||||||
|
# pager. You may instead install a pager of your choice and replace the default
|
||||||
|
# pager keybinding accordingly.
|
||||||
|
map i $less %f%
|
||||||
|
|
||||||
|
# change the shell used in default shell keybinding
|
||||||
|
map w $powershell
|
||||||
|
|
||||||
|
# change 'doc' command to use a different pager
|
||||||
|
cmd doc $lf -doc | less
|
||||||
|
|
||||||
|
# leave some space at the top and the bottom of the screen
|
||||||
|
set scrolloff 10
|
||||||
|
|
||||||
|
# use enter for shell commands
|
||||||
|
map <enter> shell
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
# interpreter for shell commands
|
||||||
|
set shell powershell
|
||||||
|
|
||||||
|
# Shell commands with multiline definitions and/or positional arguments and/or
|
||||||
|
# quotes do not work in Windows. For anything but the simplest shell commands,
|
||||||
|
# it is recommended to create separate script files and simply call them here
|
||||||
|
# in commands or mappings.
|
||||||
|
#
|
||||||
|
# Also, the default keybindings are defined using cmd syntax (i.e. '%EDITOR%')
|
||||||
|
# which does not work with powershell. Therefore, you need to override these
|
||||||
|
# keybindings with explicit choices accordingly.
|
||||||
|
|
||||||
|
# change the editor used in default editor keybinding
|
||||||
|
# There is no builtin terminal editor installed in Windows. The default editor
|
||||||
|
# mapping uses 'notepad' which launches in a separate GUI window. You may
|
||||||
|
# instead install a terminal editor of your choice and replace the default
|
||||||
|
# editor keybinding accordingly.
|
||||||
|
map e $vim $Env:f
|
||||||
|
|
||||||
|
# change the pager used in default pager keybinding
|
||||||
|
# The standard pager used in Windows is 'more' which is not a very capable
|
||||||
|
# pager. You may instead install a pager of your choice and replace the default
|
||||||
|
# pager keybinding accordingly.
|
||||||
|
map i $less $Env:f
|
||||||
|
|
||||||
|
# change the shell used in default shell keybinding
|
||||||
|
map w $powershell
|
||||||
|
|
||||||
|
# change 'doc' command to use a different pager
|
||||||
|
cmd doc $lf -doc | less
|
||||||
|
|
||||||
|
# leave some space at the top and the bottom of the screen
|
||||||
|
set scrolloff 10
|
||||||
|
|
||||||
|
# use enter for shell commands
|
||||||
|
map <enter> shell
|
||||||
@@ -20,21 +20,6 @@ func (e *setExpr) eval(app *app, args []string) {
|
|||||||
gOpts.anchorfind = false
|
gOpts.anchorfind = false
|
||||||
case "anchorfind!":
|
case "anchorfind!":
|
||||||
gOpts.anchorfind = !gOpts.anchorfind
|
gOpts.anchorfind = !gOpts.anchorfind
|
||||||
case "color256":
|
|
||||||
gOpts.color256 = true
|
|
||||||
setColorMode()
|
|
||||||
app.ui.pause()
|
|
||||||
app.ui.resume()
|
|
||||||
case "nocolor256":
|
|
||||||
gOpts.color256 = false
|
|
||||||
setColorMode()
|
|
||||||
app.ui.pause()
|
|
||||||
app.ui.resume()
|
|
||||||
case "color256!":
|
|
||||||
gOpts.color256 = !gOpts.color256
|
|
||||||
setColorMode()
|
|
||||||
app.ui.pause()
|
|
||||||
app.ui.resume()
|
|
||||||
case "dircounts":
|
case "dircounts":
|
||||||
gOpts.dircounts = true
|
gOpts.dircounts = true
|
||||||
case "nodircounts":
|
case "nodircounts":
|
||||||
@@ -97,16 +82,28 @@ func (e *setExpr) eval(app *app, args []string) {
|
|||||||
gOpts.icons = !gOpts.icons
|
gOpts.icons = !gOpts.icons
|
||||||
case "ignorecase":
|
case "ignorecase":
|
||||||
gOpts.ignorecase = true
|
gOpts.ignorecase = true
|
||||||
|
app.nav.sort()
|
||||||
|
app.ui.sort()
|
||||||
case "noignorecase":
|
case "noignorecase":
|
||||||
gOpts.ignorecase = false
|
gOpts.ignorecase = false
|
||||||
|
app.nav.sort()
|
||||||
|
app.ui.sort()
|
||||||
case "ignorecase!":
|
case "ignorecase!":
|
||||||
gOpts.ignorecase = !gOpts.ignorecase
|
gOpts.ignorecase = !gOpts.ignorecase
|
||||||
|
app.nav.sort()
|
||||||
|
app.ui.sort()
|
||||||
case "ignoredia":
|
case "ignoredia":
|
||||||
gOpts.ignoredia = true
|
gOpts.ignoredia = true
|
||||||
|
app.nav.sort()
|
||||||
|
app.ui.sort()
|
||||||
case "noignoredia":
|
case "noignoredia":
|
||||||
gOpts.ignoredia = false
|
gOpts.ignoredia = false
|
||||||
|
app.nav.sort()
|
||||||
|
app.ui.sort()
|
||||||
case "ignoredia!":
|
case "ignoredia!":
|
||||||
gOpts.ignoredia = !gOpts.ignoredia
|
gOpts.ignoredia = !gOpts.ignoredia
|
||||||
|
app.nav.sort()
|
||||||
|
app.ui.sort()
|
||||||
case "incsearch":
|
case "incsearch":
|
||||||
gOpts.incsearch = true
|
gOpts.incsearch = true
|
||||||
case "noincsearch":
|
case "noincsearch":
|
||||||
@@ -250,10 +247,14 @@ func (e *setExpr) eval(app *app, args []string) {
|
|||||||
case "ifs":
|
case "ifs":
|
||||||
gOpts.ifs = e.val
|
gOpts.ifs = e.val
|
||||||
case "info":
|
case "info":
|
||||||
|
if e.val == "" {
|
||||||
|
gOpts.info = nil
|
||||||
|
return
|
||||||
|
}
|
||||||
toks := strings.Split(e.val, ":")
|
toks := strings.Split(e.val, ":")
|
||||||
for _, s := range toks {
|
for _, s := range toks {
|
||||||
switch s {
|
switch s {
|
||||||
case "", "size", "time", "atime", "ctime":
|
case "size", "time", "atime", "ctime":
|
||||||
default:
|
default:
|
||||||
app.ui.echoerr("info: should consist of 'size', 'time', 'atime' or 'ctime' separated with colon")
|
app.ui.echoerr("info: should consist of 'size', 'time', 'atime' or 'ctime' separated with colon")
|
||||||
return
|
return
|
||||||
@@ -284,7 +285,7 @@ func (e *setExpr) eval(app *app, args []string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
gOpts.ratios = rats
|
gOpts.ratios = rats
|
||||||
app.ui.wins = getWins()
|
app.ui.wins = getWins(app.ui.screen)
|
||||||
app.ui.loadFile(app.nav)
|
app.ui.loadFile(app.nav)
|
||||||
case "shell":
|
case "shell":
|
||||||
gOpts.shell = e.val
|
gOpts.shell = e.val
|
||||||
@@ -381,6 +382,10 @@ func splitKeys(s string) (keys []string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func update(app *app) {
|
func update(app *app) {
|
||||||
|
// Remove the current menu buffer
|
||||||
|
app.ui.menuBuf = nil
|
||||||
|
app.ui.menuSelected = -2
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
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)
|
||||||
@@ -415,8 +420,11 @@ func update(app *app) {
|
|||||||
|
|
||||||
func normal(app *app) {
|
func normal(app *app) {
|
||||||
app.ui.menuBuf = nil
|
app.ui.menuBuf = nil
|
||||||
|
app.ui.menuSelected = -2
|
||||||
|
|
||||||
app.ui.cmdAccLeft = nil
|
app.ui.cmdAccLeft = nil
|
||||||
app.ui.cmdAccRight = nil
|
app.ui.cmdAccRight = nil
|
||||||
|
app.ui.cmdTmp = nil
|
||||||
app.ui.cmdPrefix = ""
|
app.ui.cmdPrefix = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -793,13 +801,13 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
app.ui.loadFileInfo(app.nav)
|
app.ui.loadFileInfo(app.nav)
|
||||||
case "draw":
|
case "draw":
|
||||||
case "redraw":
|
case "redraw":
|
||||||
app.ui.sync()
|
|
||||||
app.ui.renew()
|
app.ui.renew()
|
||||||
|
app.ui.screen.Sync()
|
||||||
app.nav.height = app.ui.wins[0].h
|
app.nav.height = app.ui.wins[0].h
|
||||||
app.ui.loadFile(app.nav)
|
app.ui.loadFile(app.nav)
|
||||||
app.ui.loadFileInfo(app.nav)
|
|
||||||
case "load":
|
case "load":
|
||||||
app.nav.renew()
|
app.nav.renew()
|
||||||
|
app.ui.loadFile(app.nav)
|
||||||
case "reload":
|
case "reload":
|
||||||
if err := app.nav.reload(); err != nil {
|
if err := app.nav.reload(); err != nil {
|
||||||
app.ui.echoerrf("reload: %s", err)
|
app.ui.echoerrf("reload: %s", err)
|
||||||
@@ -1021,13 +1029,21 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.Println("pushing keys", e.args[0])
|
log.Println("pushing keys", e.args[0])
|
||||||
for _, key := range splitKeys(e.args[0]) {
|
for _, val := range splitKeys(e.args[0]) {
|
||||||
app.ui.keyChan <- key
|
app.ui.keyChan <- val
|
||||||
}
|
}
|
||||||
case "cmd-insert":
|
case "cmd-insert":
|
||||||
if len(e.args) == 0 {
|
if len(e.args) == 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Reset the completition menu as in bash/vim
|
||||||
|
// and update the pertinent variables
|
||||||
|
if app.ui.menuBuf != nil {
|
||||||
|
app.ui.menuBuf = nil
|
||||||
|
app.ui.menuSelected = -2
|
||||||
|
}
|
||||||
|
|
||||||
insert(app, e.args[0])
|
insert(app, e.args[0])
|
||||||
case "cmd-escape":
|
case "cmd-escape":
|
||||||
if app.ui.cmdPrefix == ">" {
|
if app.ui.cmdPrefix == ">" {
|
||||||
@@ -1054,20 +1070,120 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
default:
|
default:
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
app.ui.draw(app.nav)
|
app.ui.draw(app.nav)
|
||||||
|
|
||||||
|
// If there are no multiple matches
|
||||||
|
// we do not need to show the list of matches
|
||||||
|
if len(matches) <= 1 {
|
||||||
|
app.ui.menuBuf = nil
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if b, err := listMatches(app.ui.screen, matches); err != nil {
|
||||||
|
app.ui.echoerrf("cmd-complete: %s", err)
|
||||||
|
} else {
|
||||||
|
app.ui.menuBuf = b
|
||||||
|
}
|
||||||
|
case "cmd-menu-complete":
|
||||||
|
var target []rune
|
||||||
|
|
||||||
|
// target will store the current menu query
|
||||||
|
// note that, as we will store the current selected value
|
||||||
|
// in cmdAccLeft, we can not call the complete function with its
|
||||||
|
// value, as it is already a final completition result
|
||||||
|
if app.ui.menuBuf == nil {
|
||||||
|
target = app.ui.cmdAccLeft
|
||||||
|
app.ui.cmdTmp = app.ui.cmdAccLeft
|
||||||
|
} else {
|
||||||
|
target = app.ui.cmdTmp
|
||||||
|
}
|
||||||
|
|
||||||
|
var matches []string
|
||||||
|
switch app.ui.cmdPrefix {
|
||||||
|
case ":":
|
||||||
|
matches, app.ui.cmdAccLeft = completeCmd(target)
|
||||||
|
case "/", "?":
|
||||||
|
matches, app.ui.cmdAccLeft = completeFile(target)
|
||||||
|
case "$", "%", "!", "&":
|
||||||
|
matches, app.ui.cmdAccLeft = completeShell(target)
|
||||||
|
default:
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
app.ui.draw(app.nav)
|
||||||
|
|
||||||
if len(matches) > 1 {
|
if len(matches) > 1 {
|
||||||
app.ui.menuBuf = listMatches(matches)
|
step := 1
|
||||||
|
|
||||||
|
// Check if the tab-selecttion was inited
|
||||||
|
if app.ui.menuSelected == -2 {
|
||||||
|
app.ui.menuSelected = -1
|
||||||
|
} else {
|
||||||
|
app.ui.menuSelected = mod(app.ui.menuSelected+step, len(matches))
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := listMatchesMenu(app.ui, matches); err != nil {
|
||||||
|
app.ui.echoerrf("cmd-menu-complete: %s", err)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
app.ui.menuBuf = nil
|
app.ui.menuBuf = nil
|
||||||
|
app.ui.menuSelected = -2
|
||||||
|
}
|
||||||
|
case "cmd-menu-complete-back":
|
||||||
|
var target []rune
|
||||||
|
|
||||||
|
if app.ui.menuBuf == nil {
|
||||||
|
target = app.ui.cmdAccLeft
|
||||||
|
app.ui.cmdTmp = app.ui.cmdAccLeft
|
||||||
|
} else {
|
||||||
|
target = app.ui.cmdTmp
|
||||||
|
}
|
||||||
|
|
||||||
|
var matches []string
|
||||||
|
switch app.ui.cmdPrefix {
|
||||||
|
case ":":
|
||||||
|
matches, app.ui.cmdAccLeft = completeCmd(target)
|
||||||
|
case "/", "?":
|
||||||
|
matches, app.ui.cmdAccLeft = completeFile(target)
|
||||||
|
case "$", "%", "!", "&":
|
||||||
|
matches, app.ui.cmdAccLeft = completeShell(target)
|
||||||
|
default:
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
app.ui.draw(app.nav)
|
||||||
|
|
||||||
|
if len(matches) > 1 {
|
||||||
|
step := -1
|
||||||
|
|
||||||
|
// Check if the tab-selecttion was inited
|
||||||
|
if app.ui.menuSelected == -2 {
|
||||||
|
app.ui.menuSelected = -1
|
||||||
|
} else {
|
||||||
|
app.ui.menuSelected = mod(app.ui.menuSelected+step, len(matches))
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := listMatchesMenu(app.ui, matches); err != nil {
|
||||||
|
app.ui.echoerrf("cmd-menu-complete-back: %s", err)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
app.ui.menuBuf = nil
|
||||||
|
app.ui.menuSelected = -2
|
||||||
}
|
}
|
||||||
case "cmd-enter":
|
case "cmd-enter":
|
||||||
s := string(append(app.ui.cmdAccLeft, app.ui.cmdAccRight...))
|
s := string(append(app.ui.cmdAccLeft, app.ui.cmdAccRight...))
|
||||||
if len(s) == 0 {
|
if len(s) == 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
app.ui.menuBuf = nil
|
app.ui.menuBuf = nil
|
||||||
|
app.ui.menuSelected = -2
|
||||||
|
|
||||||
app.ui.cmdAccLeft = nil
|
app.ui.cmdAccLeft = nil
|
||||||
app.ui.cmdAccRight = nil
|
app.ui.cmdAccRight = nil
|
||||||
|
app.ui.cmdTmp = nil
|
||||||
|
|
||||||
switch app.ui.cmdPrefix {
|
switch app.ui.cmdPrefix {
|
||||||
case ":":
|
case ":":
|
||||||
log.Printf("command: %s", s)
|
log.Printf("command: %s", s)
|
||||||
@@ -1199,8 +1315,10 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
}
|
}
|
||||||
if app.cmdHistoryInd == 0 {
|
if app.cmdHistoryInd == 0 {
|
||||||
app.ui.menuBuf = nil
|
app.ui.menuBuf = nil
|
||||||
|
app.ui.menuSelected = -2
|
||||||
app.ui.cmdAccLeft = nil
|
app.ui.cmdAccLeft = nil
|
||||||
app.ui.cmdAccRight = nil
|
app.ui.cmdAccRight = nil
|
||||||
|
app.ui.cmdTmp = nil
|
||||||
app.ui.cmdPrefix = ":"
|
app.ui.cmdPrefix = ":"
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -1208,7 +1326,9 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
app.ui.cmdPrefix = cmd.prefix
|
app.ui.cmdPrefix = cmd.prefix
|
||||||
app.ui.cmdAccLeft = []rune(cmd.value)
|
app.ui.cmdAccLeft = []rune(cmd.value)
|
||||||
app.ui.cmdAccRight = nil
|
app.ui.cmdAccRight = nil
|
||||||
|
app.ui.cmdTmp = nil
|
||||||
app.ui.menuBuf = nil
|
app.ui.menuBuf = nil
|
||||||
|
app.ui.menuSelected = -2
|
||||||
case "cmd-history-prev":
|
case "cmd-history-prev":
|
||||||
if app.ui.cmdPrefix == ">" {
|
if app.ui.cmdPrefix == ">" {
|
||||||
return
|
return
|
||||||
@@ -1224,7 +1344,9 @@ func (e *callExpr) eval(app *app, args []string) {
|
|||||||
app.ui.cmdPrefix = cmd.prefix
|
app.ui.cmdPrefix = cmd.prefix
|
||||||
app.ui.cmdAccLeft = []rune(cmd.value)
|
app.ui.cmdAccLeft = []rune(cmd.value)
|
||||||
app.ui.cmdAccRight = nil
|
app.ui.cmdAccRight = nil
|
||||||
|
app.ui.cmdTmp = nil
|
||||||
app.ui.menuBuf = nil
|
app.ui.menuBuf = nil
|
||||||
|
app.ui.menuSelected = -2
|
||||||
case "cmd-delete":
|
case "cmd-delete":
|
||||||
if len(app.ui.cmdAccRight) == 0 {
|
if len(app.ui.cmdAccRight) == 0 {
|
||||||
return
|
return
|
||||||
|
|||||||
+41
-24
@@ -14,28 +14,45 @@ set -o verbose
|
|||||||
|
|
||||||
mkdir -p dist
|
mkdir -p dist
|
||||||
|
|
||||||
CGO_ENABLED=0 GOOS=darwin GOARCH=386 go build -ldflags="-s -w -X main.gVersion=$version" && sync && tar czf dist/lf-darwin-386.tar.gz lf --remove-files
|
# https://golang.org/doc/install/source#environment
|
||||||
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags="-s -w -X main.gVersion=$version" && sync && tar czf dist/lf-darwin-amd64.tar.gz lf --remove-files
|
|
||||||
CGO_ENABLED=0 GOOS=dragonfly GOARCH=amd64 go build -ldflags="-s -w -X main.gVersion=$version" && sync && tar czf dist/lf-dragonfly-amd64.tar.gz lf --remove-files
|
|
||||||
CGO_ENABLED=0 GOOS=freebsd GOARCH=386 go build -ldflags="-s -w -X main.gVersion=$version" && sync && tar czf dist/lf-freebsd-386.tar.gz lf --remove-files
|
|
||||||
CGO_ENABLED=0 GOOS=freebsd GOARCH=amd64 go build -ldflags="-s -w -X main.gVersion=$version" && sync && tar czf dist/lf-freebsd-amd64.tar.gz lf --remove-files
|
|
||||||
CGO_ENABLED=0 GOOS=freebsd GOARCH=arm go build -ldflags="-s -w -X main.gVersion=$version" && sync && tar czf dist/lf-freebsd-arm.tar.gz lf --remove-files
|
|
||||||
CGO_ENABLED=0 GOOS=linux GOARCH=386 go build -ldflags="-s -w -X main.gVersion=$version" && sync && tar czf dist/lf-linux-386.tar.gz lf --remove-files
|
|
||||||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w -X main.gVersion=$version" && sync && tar czf dist/lf-linux-amd64.tar.gz lf --remove-files
|
|
||||||
CGO_ENABLED=0 GOOS=linux GOARCH=arm go build -ldflags="-s -w -X main.gVersion=$version" && sync && tar czf dist/lf-linux-arm.tar.gz lf --remove-files
|
|
||||||
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags="-s -w -X main.gVersion=$version" && sync && tar czf dist/lf-linux-arm64.tar.gz lf --remove-files
|
|
||||||
CGO_ENABLED=0 GOOS=linux GOARCH=ppc64 go build -ldflags="-s -w -X main.gVersion=$version" && sync && tar czf dist/lf-linux-ppc64.tar.gz lf --remove-files
|
|
||||||
CGO_ENABLED=0 GOOS=linux GOARCH=ppc64le go build -ldflags="-s -w -X main.gVersion=$version" && sync && tar czf dist/lf-linux-ppc64le.tar.gz lf --remove-files
|
|
||||||
CGO_ENABLED=0 GOOS=linux GOARCH=mips go build -ldflags="-s -w -X main.gVersion=$version" && sync && tar czf dist/lf-linux-mips.tar.gz lf --remove-files
|
|
||||||
CGO_ENABLED=0 GOOS=linux GOARCH=mipsle go build -ldflags="-s -w -X main.gVersion=$version" && sync && tar czf dist/lf-linux-mipsle.tar.gz lf --remove-files
|
|
||||||
CGO_ENABLED=0 GOOS=linux GOARCH=mips64 go build -ldflags="-s -w -X main.gVersion=$version" && sync && tar czf dist/lf-linux-mips64.tar.gz lf --remove-files
|
|
||||||
CGO_ENABLED=0 GOOS=linux GOARCH=mips64le go build -ldflags="-s -w -X main.gVersion=$version" && sync && tar czf dist/lf-linux-mips64le.tar.gz lf --remove-files
|
|
||||||
CGO_ENABLED=0 GOOS=netbsd GOARCH=386 go build -ldflags="-s -w -X main.gVersion=$version" && sync && tar czf dist/lf-netbsd-386.tar.gz lf --remove-files
|
|
||||||
CGO_ENABLED=0 GOOS=netbsd GOARCH=amd64 go build -ldflags="-s -w -X main.gVersion=$version" && sync && tar czf dist/lf-netbsd-amd64.tar.gz lf --remove-files
|
|
||||||
CGO_ENABLED=0 GOOS=netbsd GOARCH=arm go build -ldflags="-s -w -X main.gVersion=$version" && sync && tar czf dist/lf-netbsd-arm.tar.gz lf --remove-files
|
|
||||||
CGO_ENABLED=0 GOOS=openbsd GOARCH=386 go build -ldflags="-s -w -X main.gVersion=$version" && sync && tar czf dist/lf-openbsd-386.tar.gz lf --remove-files
|
|
||||||
CGO_ENABLED=0 GOOS=openbsd GOARCH=amd64 go build -ldflags="-s -w -X main.gVersion=$version" && sync && tar czf dist/lf-openbsd-amd64.tar.gz lf --remove-files
|
|
||||||
CGO_ENABLED=0 GOOS=openbsd GOARCH=arm go build -ldflags="-s -w -X main.gVersion=$version" && sync && tar czf dist/lf-openbsd-arm.tar.gz lf --remove-files
|
|
||||||
|
|
||||||
CGO_ENABLED=0 GOOS=windows GOARCH=386 go build -ldflags="-s -w -X main.gVersion=$version" && sync && zip dist/lf-windows-386.zip lf.exe --move
|
CGO_ENABLED=0 GOOS=android GOARCH=arm64 go build -ldflags="-s -w -X main.gVersion=$version" && tar czf dist/lf-android-arm64.tar.gz lf --remove-files
|
||||||
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags="-s -w -X main.gVersion=$version" && sync && zip dist/lf-windows-amd64.zip lf.exe --move
|
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags="-s -w -X main.gVersion=$version" && tar czf dist/lf-darwin-amd64.tar.gz lf --remove-files
|
||||||
|
CGO_ENABLED=0 GOOS=dragonfly GOARCH=amd64 go build -ldflags="-s -w -X main.gVersion=$version" && tar czf dist/lf-dragonfly-amd64.tar.gz lf --remove-files
|
||||||
|
CGO_ENABLED=0 GOOS=freebsd GOARCH=386 go build -ldflags="-s -w -X main.gVersion=$version" && tar czf dist/lf-freebsd-386.tar.gz lf --remove-files
|
||||||
|
CGO_ENABLED=0 GOOS=freebsd GOARCH=amd64 go build -ldflags="-s -w -X main.gVersion=$version" && tar czf dist/lf-freebsd-amd64.tar.gz lf --remove-files
|
||||||
|
CGO_ENABLED=0 GOOS=freebsd GOARCH=arm go build -ldflags="-s -w -X main.gVersion=$version" && tar czf dist/lf-freebsd-arm.tar.gz lf --remove-files
|
||||||
|
CGO_ENABLED=0 GOOS=illumos GOARCH=amd64 go build -ldflags="-s -w -X main.gVersion=$version" && tar czf dist/lf-illumos-amd64.tar.gz lf --remove-files
|
||||||
|
CGO_ENABLED=0 GOOS=linux GOARCH=386 go build -ldflags="-s -w -X main.gVersion=$version" && tar czf dist/lf-linux-386.tar.gz lf --remove-files
|
||||||
|
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w -X main.gVersion=$version" && tar czf dist/lf-linux-amd64.tar.gz lf --remove-files
|
||||||
|
CGO_ENABLED=0 GOOS=linux GOARCH=arm go build -ldflags="-s -w -X main.gVersion=$version" && tar czf dist/lf-linux-arm.tar.gz lf --remove-files
|
||||||
|
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -ldflags="-s -w -X main.gVersion=$version" && tar czf dist/lf-linux-arm64.tar.gz lf --remove-files
|
||||||
|
CGO_ENABLED=0 GOOS=linux GOARCH=ppc64 go build -ldflags="-s -w -X main.gVersion=$version" && tar czf dist/lf-linux-ppc64.tar.gz lf --remove-files
|
||||||
|
CGO_ENABLED=0 GOOS=linux GOARCH=ppc64le go build -ldflags="-s -w -X main.gVersion=$version" && tar czf dist/lf-linux-ppc64le.tar.gz lf --remove-files
|
||||||
|
CGO_ENABLED=0 GOOS=linux GOARCH=mips go build -ldflags="-s -w -X main.gVersion=$version" && tar czf dist/lf-linux-mips.tar.gz lf --remove-files
|
||||||
|
CGO_ENABLED=0 GOOS=linux GOARCH=mipsle go build -ldflags="-s -w -X main.gVersion=$version" && tar czf dist/lf-linux-mipsle.tar.gz lf --remove-files
|
||||||
|
CGO_ENABLED=0 GOOS=linux GOARCH=mips64 go build -ldflags="-s -w -X main.gVersion=$version" && tar czf dist/lf-linux-mips64.tar.gz lf --remove-files
|
||||||
|
CGO_ENABLED=0 GOOS=linux GOARCH=mips64le go build -ldflags="-s -w -X main.gVersion=$version" && tar czf dist/lf-linux-mips64le.tar.gz lf --remove-files
|
||||||
|
CGO_ENABLED=0 GOOS=linux GOARCH=s390x go build -ldflags="-s -w -X main.gVersion=$version" && tar czf dist/lf-linux-s390x.tar.gz lf --remove-files
|
||||||
|
CGO_ENABLED=0 GOOS=netbsd GOARCH=386 go build -ldflags="-s -w -X main.gVersion=$version" && tar czf dist/lf-netbsd-386.tar.gz lf --remove-files
|
||||||
|
CGO_ENABLED=0 GOOS=netbsd GOARCH=amd64 go build -ldflags="-s -w -X main.gVersion=$version" && tar czf dist/lf-netbsd-amd64.tar.gz lf --remove-files
|
||||||
|
CGO_ENABLED=0 GOOS=netbsd GOARCH=arm go build -ldflags="-s -w -X main.gVersion=$version" && tar czf dist/lf-netbsd-arm.tar.gz lf --remove-files
|
||||||
|
CGO_ENABLED=0 GOOS=openbsd GOARCH=386 go build -ldflags="-s -w -X main.gVersion=$version" && tar czf dist/lf-openbsd-386.tar.gz lf --remove-files
|
||||||
|
CGO_ENABLED=0 GOOS=openbsd GOARCH=amd64 go build -ldflags="-s -w -X main.gVersion=$version" && tar czf dist/lf-openbsd-amd64.tar.gz lf --remove-files
|
||||||
|
CGO_ENABLED=0 GOOS=openbsd GOARCH=arm go build -ldflags="-s -w -X main.gVersion=$version" && tar czf dist/lf-openbsd-arm.tar.gz lf --remove-files
|
||||||
|
CGO_ENABLED=0 GOOS=openbsd GOARCH=arm64 go build -ldflags="-s -w -X main.gVersion=$version" && tar czf dist/lf-openbsd-arm64.tar.gz lf --remove-files
|
||||||
|
CGO_ENABLED=0 GOOS=solaris GOARCH=amd64 go build -ldflags="-s -w -X main.gVersion=$version" && tar czf dist/lf-solaris-amd64.tar.gz lf --remove-files
|
||||||
|
|
||||||
|
CGO_ENABLED=0 GOOS=windows GOARCH=386 go build -ldflags="-s -w -X main.gVersion=$version" && zip dist/lf-windows-386.zip lf.exe --move
|
||||||
|
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags="-s -w -X main.gVersion=$version" && zip dist/lf-windows-amd64.zip lf.exe --move
|
||||||
|
|
||||||
|
# not supported
|
||||||
|
# CGO_ENABLED=0 GOOS=aix GOARCH=ppc64 go build -ldflags="-s -w -X main.gVersion=$version" && tar czf dist/lf-aix-ppc64.tar.gz lf --remove-files
|
||||||
|
# CGO_ENABLED=0 GOOS=android GOARCH=386 go build -ldflags="-s -w -X main.gVersion=$version" && tar czf dist/lf-android-386.tar.gz lf --remove-files
|
||||||
|
# CGO_ENABLED=0 GOOS=android GOARCH=amd64 go build -ldflags="-s -w -X main.gVersion=$version" && tar czf dist/lf-android-amd64.tar.gz lf --remove-files
|
||||||
|
# CGO_ENABLED=0 GOOS=android GOARCH=arm go build -ldflags="-s -w -X main.gVersion=$version" && tar czf dist/lf-android-arm.tar.gz lf --remove-files
|
||||||
|
# CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -ldflags="-s -w -X main.gVersion=$version" && tar czf dist/lf-darwin-arm64.tar.gz lf --remove-files
|
||||||
|
# CGO_ENABLED=0 GOOS=js GOARCH=wasm go build -ldflags="-s -w -X main.gVersion=$version" && tar czf dist/lf-js-wasm.tar.gz lf --remove-files
|
||||||
|
# CGO_ENABLED=0 GOOS=plan9 GOARCH=386 go build -ldflags="-s -w -X main.gVersion=$version" && tar czf dist/lf-plan9-386.tar.gz lf --remove-files
|
||||||
|
# CGO_ENABLED=0 GOOS=plan9 GOARCH=amd64 go build -ldflags="-s -w -X main.gVersion=$version" && tar czf dist/lf-plan9-amd64.tar.gz lf --remove-files
|
||||||
|
# CGO_ENABLED=0 GOOS=plan9 GOARCH=arm go build -ldflags="-s -w -X main.gVersion=$version" && tar czf dist/lf-plan9-arm.tar.gz lf --remove-files
|
||||||
@@ -3,7 +3,7 @@ module github.com/gokcehan/lf
|
|||||||
go 1.12
|
go 1.12
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/doronbehar/termbox-go v0.0.0-20200711071547-71407e3bfa14
|
github.com/gdamore/tcell/v2 v2.0.0
|
||||||
github.com/mattn/go-runewidth v0.0.9
|
github.com/mattn/go-runewidth v0.0.9
|
||||||
gopkg.in/djherbis/times.v1 v1.2.0
|
gopkg.in/djherbis/times.v1 v1.2.0
|
||||||
)
|
)
|
||||||
@@ -1,14 +1,15 @@
|
|||||||
github.com/doronbehar/termbox-go v0.0.0-20190817171036-93860e161317 h1:mdOm+1RdYwVwC4Wjb53M5L96fRwWJ8gI7YXwwiCsHTk=
|
github.com/gdamore/encoding v1.0.0 h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdko=
|
||||||
github.com/doronbehar/termbox-go v0.0.0-20190817171036-93860e161317/go.mod h1:cHYbFQiZNC8LPG6clYoLMKAl0xx7KR75RPsHtG/f1Hk=
|
github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg=
|
||||||
github.com/doronbehar/termbox-go v0.0.0-20191006140624-aa2cdd26fb8c h1:qvLYQAhDCaMq+XiQ+t4YLaTJtUyHC1r20odd6ryKYIk=
|
github.com/gdamore/tcell/v2 v2.0.0 h1:GRWG8aLfWAlekj9Q6W29bVvkHENc6hp79XOqG4AWDOs=
|
||||||
github.com/doronbehar/termbox-go v0.0.0-20191006140624-aa2cdd26fb8c/go.mod h1:cHYbFQiZNC8LPG6clYoLMKAl0xx7KR75RPsHtG/f1Hk=
|
github.com/gdamore/tcell/v2 v2.0.0/go.mod h1:vSVL/GV5mCSlPC6thFP5kfOFdM9MGZcalipmpTxTgQA=
|
||||||
github.com/doronbehar/termbox-go v0.0.0-20191006141301-8c9470559e05 h1:pmXx7j8+mmkFJB2+qoB1C/Mz8SWvMlHTxSWOptJrr7E=
|
github.com/lucasb-eyer/go-colorful v1.0.3 h1:QIbQXiugsb+q10B+MI+7DI1oQLdmnep86tWFlaaUAac=
|
||||||
github.com/doronbehar/termbox-go v0.0.0-20191006141301-8c9470559e05/go.mod h1:cHYbFQiZNC8LPG6clYoLMKAl0xx7KR75RPsHtG/f1Hk=
|
github.com/lucasb-eyer/go-colorful v1.0.3/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
|
||||||
github.com/doronbehar/termbox-go v0.0.0-20200711071547-71407e3bfa14 h1:KKPl27Vj3HRF384G7jW7K8uCRv0Ks+GuAOkGsz4qWAs=
|
github.com/mattn/go-runewidth v0.0.7/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
|
||||||
github.com/doronbehar/termbox-go v0.0.0-20200711071547-71407e3bfa14/go.mod h1:cHYbFQiZNC8LPG6clYoLMKAl0xx7KR75RPsHtG/f1Hk=
|
|
||||||
github.com/mattn/go-runewidth v0.0.4 h1:2BvfKmzob6Bmd4YsL0zygOqfdFnK7GR4QL06Do4/p7Y=
|
|
||||||
github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
|
|
||||||
github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=
|
github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0=
|
||||||
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
|
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
|
||||||
|
golang.org/x/sys v0.0.0-20190626150813-e07cf5db2756 h1:9nuHUbU8dRnRRfj9KjWUVrJeoexdbeMjttk6Oh1rD10=
|
||||||
|
golang.org/x/sys v0.0.0-20190626150813-e07cf5db2756/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
|
||||||
|
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=
|
||||||
gopkg.in/djherbis/times.v1 v1.2.0/go.mod h1:AQlg6unIsrsCEdQYhTzERy542dz6SFdQFZFv6mUY0P8=
|
gopkg.in/djherbis/times.v1 v1.2.0/go.mod h1:AQlg6unIsrsCEdQYhTzERy542dz6SFdQFZFv6mUY0P8=
|
||||||
@@ -22,10 +22,11 @@ Source code can be found in the repository at https://github.com/gokcehan/lf.
|
|||||||
This documentation can either be read from terminal using 'lf -doc' or online at https://godoc.org/github.com/gokcehan/lf. You can also use 'doc' command (default '<f-1>') inside lf to view the documentation in a pager.
|
This documentation can either be read from terminal using 'lf -doc' or online at https://godoc.org/github.com/gokcehan/lf. You can also use 'doc' command (default '<f-1>') inside lf to view the documentation in a pager.
|
||||||
.PP
|
.PP
|
||||||
You can run 'lf -help' to see descriptions of command line options.
|
You can run 'lf -help' to see descriptions of command line options.
|
||||||
.SH REFERENCE
|
.SH QUICK REFERENCE
|
||||||
The following commands are provided by lf with default keybindings:
|
The following commands are provided by lf:
|
||||||
.PP
|
.PP
|
||||||
.EX
|
.EX
|
||||||
|
quit (default 'q')
|
||||||
up (default 'k' and '<up>')
|
up (default 'k' and '<up>')
|
||||||
half-up (default '<c-u>')
|
half-up (default '<c-u>')
|
||||||
page-up (default '<c-b>' and '<pgup>')
|
page-up (default '<c-b>' and '<pgup>')
|
||||||
@@ -34,157 +35,142 @@ The following commands are provided by lf with default keybindings:
|
|||||||
page-down (default '<c-f>' and '<pgdn>')
|
page-down (default '<c-f>' and '<pgdn>')
|
||||||
updir (default 'h' and '<left>')
|
updir (default 'h' and '<left>')
|
||||||
open (default 'l' and '<right>')
|
open (default 'l' and '<right>')
|
||||||
quit (default 'q')
|
|
||||||
top (default 'gg' and '<home>')
|
top (default 'gg' and '<home>')
|
||||||
bottom (default 'G' and '<end>')
|
bottom (default 'G' and '<end>')
|
||||||
|
toggle
|
||||||
invert (default 'v')
|
invert (default 'v')
|
||||||
unselect (default 'u')
|
unselect (default 'u')
|
||||||
|
glob-select
|
||||||
|
glob-unselect
|
||||||
copy (default 'y')
|
copy (default 'y')
|
||||||
cut (default 'd')
|
cut (default 'd')
|
||||||
paste (default 'p')
|
paste (default 'p')
|
||||||
clear (default 'c')
|
clear (default 'c')
|
||||||
|
sync
|
||||||
|
draw
|
||||||
redraw (default '<c-l>')
|
redraw (default '<c-l>')
|
||||||
|
load
|
||||||
reload (default '<c-r>')
|
reload (default '<c-r>')
|
||||||
read (default ':')
|
echo
|
||||||
rename (default 'r')
|
echomsg
|
||||||
shell (default '$')
|
echoerr
|
||||||
shell-pipe (default '%')
|
cd
|
||||||
shell-wait (default '!')
|
select
|
||||||
shell-async (default '&')
|
delete (modal)
|
||||||
find (default 'f')
|
rename (modal) (default 'r')
|
||||||
find-back (default 'F')
|
source
|
||||||
|
push
|
||||||
|
read (modal) (default ':')
|
||||||
|
shell (modal) (default '$')
|
||||||
|
shell-pipe (modal) (default '%')
|
||||||
|
shell-wait (modal) (default '!')
|
||||||
|
shell-async (modal) (default '&')
|
||||||
|
find (modal) (default 'f')
|
||||||
|
find-back (modal) (default 'F')
|
||||||
find-next (default ';')
|
find-next (default ';')
|
||||||
find-prev (default ',')
|
find-prev (default ',')
|
||||||
search (default '/')
|
search (modal) (default '/')
|
||||||
search-back (default '?')
|
search-back (modal) (default '?')
|
||||||
search-next (default 'n')
|
search-next (default 'n')
|
||||||
search-prev (default 'N')
|
search-prev (default 'N')
|
||||||
mark-save (default 'm')
|
mark-save (modal) (default 'm')
|
||||||
mark-load (default "'")
|
mark-load (modal) (default "'")
|
||||||
mark-remove (default `"`)
|
mark-remove (modal) (default `"`)
|
||||||
.EE
|
.EE
|
||||||
.PP
|
.PP
|
||||||
The following commands are provided by lf without default keybindings:
|
The following command line commands are provided by lf:
|
||||||
.PP
|
|
||||||
.EX
|
|
||||||
draw draw the ui
|
|
||||||
load load modified files and directories
|
|
||||||
sync synchronize copied/cut files with server
|
|
||||||
echo print arguments to the message line
|
|
||||||
echomsg same as echo but logging
|
|
||||||
echoerr same as echomsg but red color
|
|
||||||
cd change working directory to the argument
|
|
||||||
select change current file selection to the argument
|
|
||||||
toggle toggle the selection of the current file or its arguments
|
|
||||||
glob-select select files that match the given glob
|
|
||||||
glob-unselect unselect files that match the given glob
|
|
||||||
source read the configuration file in the argument
|
|
||||||
push simulate key pushes given in the argument
|
|
||||||
delete remove the current file or selected file(s)
|
|
||||||
.EE
|
|
||||||
.PP
|
|
||||||
The following command line commands are provided by lf with default keybindings:
|
|
||||||
.PP
|
.PP
|
||||||
.EX
|
.EX
|
||||||
cmd-escape (default '<esc>')
|
cmd-escape (default '<esc>')
|
||||||
cmd-complete (default '<tab>')
|
cmd-complete (default '<tab>')
|
||||||
|
cmd-menu-complete
|
||||||
|
cmd-menu-complete-back
|
||||||
cmd-enter (default '<c-j>' and '<enter>')
|
cmd-enter (default '<c-j>' and '<enter>')
|
||||||
|
cmd-interrupt (default '<c-c>')
|
||||||
cmd-history-next (default '<c-n>')
|
cmd-history-next (default '<c-n>')
|
||||||
cmd-history-prev (default '<c-p>')
|
cmd-history-prev (default '<c-p>')
|
||||||
cmd-delete (default '<c-d>' and '<delete>')
|
|
||||||
cmd-delete-back (default '<bs>' and '<bs2>')
|
|
||||||
cmd-left (default '<c-b>' and '<left>')
|
cmd-left (default '<c-b>' and '<left>')
|
||||||
cmd-right (default '<c-f>' and '<right>')
|
cmd-right (default '<c-f>' and '<right>')
|
||||||
cmd-home (default '<c-a>' and '<home>')
|
cmd-home (default '<c-a>' and '<home>')
|
||||||
cmd-end (default '<c-e>' and '<end>')
|
cmd-end (default '<c-e>' and '<end>')
|
||||||
|
cmd-delete (default '<c-d>' and '<delete>')
|
||||||
|
cmd-delete-back (default '<backspace>' and '<backspace2>')
|
||||||
cmd-delete-home (default '<c-u>')
|
cmd-delete-home (default '<c-u>')
|
||||||
cmd-delete-end (default '<c-k>')
|
cmd-delete-end (default '<c-k>')
|
||||||
cmd-delete-unix-word (default '<c-w>')
|
cmd-delete-unix-word (default '<c-w>')
|
||||||
cmd-yank (default '<c-y>')
|
cmd-yank (default '<c-y>')
|
||||||
cmd-transpose (default '<c-t>')
|
cmd-transpose (default '<c-t>')
|
||||||
cmd-interrupt (default '<c-c>')
|
cmd-transpose-word (default '<a-t>')
|
||||||
cmd-word (default '<a-f>')
|
cmd-word (default '<a-f>')
|
||||||
cmd-word-back (default '<a-b>')
|
cmd-word-back (default '<a-b>')
|
||||||
cmd-capitalize-word (default '<a-c>')
|
|
||||||
cmd-delete-word (default '<a-d>')
|
cmd-delete-word (default '<a-d>')
|
||||||
|
cmd-capitalize-word (default '<a-c>')
|
||||||
cmd-uppercase-word (default '<a-u>')
|
cmd-uppercase-word (default '<a-u>')
|
||||||
cmd-lowercase-word (default '<a-l>')
|
cmd-lowercase-word (default '<a-l>')
|
||||||
cmd-transpose-word (default '<a-t>')
|
|
||||||
.EE
|
.EE
|
||||||
.PP
|
.PP
|
||||||
The following options can be used to customize the behavior of lf:
|
The following options can be used to customize the behavior of lf:
|
||||||
.PP
|
.PP
|
||||||
.EX
|
.EX
|
||||||
anchorfind boolean (default on)
|
anchorfind bool (default on)
|
||||||
color256 boolean (default off)
|
dircounts bool (default off)
|
||||||
dircounts boolean (default off)
|
dirfirst bool (default on)
|
||||||
dirfirst boolean (default on)
|
drawbox bool (default off)
|
||||||
drawbox boolean (default off)
|
errorfmt string (default "\e033[7;31;47m%s\e033[0m")
|
||||||
globsearch boolean (default off)
|
filesep string (default "\en")
|
||||||
hidden boolean (default off)
|
findlen int (default 1)
|
||||||
icons boolean (default off)
|
globsearch bool (default off)
|
||||||
ignorecase boolean (default on)
|
hidden bool (default off)
|
||||||
ignoredia boolean (default off)
|
hiddenfiles []string (default '.*')
|
||||||
incsearch boolean (default off)
|
icons bool (default off)
|
||||||
number boolean (default off)
|
ifs string (default '')
|
||||||
preview boolean (default on)
|
ignorecase bool (default on)
|
||||||
relativenumber boolean (default off)
|
ignoredia bool (default on)
|
||||||
reverse boolean (default off)
|
incsearch bool (default off)
|
||||||
smartcase boolean (default on)
|
info []string (default '')
|
||||||
smartdia boolean (default off)
|
number bool (default off)
|
||||||
wrapscan boolean (default on)
|
period int (default 0)
|
||||||
wrapscroll boolean (default off)
|
preview bool (default on)
|
||||||
findlen integer (default 1) (zero to prompt until single match)
|
previewer string (default '')
|
||||||
period integer (default 0) (zero to disable periodic loading)
|
promptfmt string (default "\e033[32;1m%u@%h\e033[0m:\e033[34;1m%w\e033[0m\e033[1m%f\e033[0m")
|
||||||
scrolloff integer (default 0)
|
ratios []int (default '1:2:3')
|
||||||
tabstop integer (default 8)
|
relativenumber bool (default off)
|
||||||
errorfmt string (default "\e033[7;31;47m%s\e033[0m")
|
reverse bool (default off)
|
||||||
filesep string (default "\en")
|
scrolloff int (default 0)
|
||||||
hiddenfiles string (default '.*')
|
shell string (default 'sh' for unix and 'cmd' for windows)
|
||||||
ifs string (default '') (not exported if empty)
|
shellopts []string (default '')
|
||||||
info string (default '')
|
smartcase bool (default on)
|
||||||
previewer string (default '') (not filtered if empty)
|
smartdia bool (default off)
|
||||||
promptfmt string (default "\e033[32;1m%u@%h\e033[0m:\e033[34;1m%w/\e033[0m\e033[1m%f\e033[0m")
|
sortby string (default 'natural')
|
||||||
ratios string (default '1:2:3')
|
tabstop int (default 8)
|
||||||
shell string (default 'sh')
|
timefmt string (default 'Mon Jan _2 15:04:05 2006')
|
||||||
shellopts string (default '')
|
truncatechar string (default '~')
|
||||||
sortby string (default 'natural')
|
wrapscan bool (default on)
|
||||||
timefmt string (default 'Mon Jan _2 15:04:05 2006')
|
wrapscroll bool (default off)
|
||||||
truncatechar string (default '~')
|
|
||||||
.EE
|
.EE
|
||||||
.PP
|
.PP
|
||||||
The following variables are exported for shell commands:
|
The following environment variables are exported for shell commands:
|
||||||
.PP
|
.PP
|
||||||
.EX
|
.EX
|
||||||
$f current file
|
f
|
||||||
$fs selected file(s) separated with 'filesep'
|
fs
|
||||||
$fx current file or selected file(s) if any
|
fx
|
||||||
$id id number of the client
|
id
|
||||||
|
LF_LEVEL
|
||||||
|
OPENER
|
||||||
|
EDITOR
|
||||||
|
PAGER
|
||||||
|
SHELL
|
||||||
.EE
|
.EE
|
||||||
.PP
|
.PP
|
||||||
The following variables are set to the corresponding values:
|
The following commands/keybindings are provided by default:
|
||||||
.PP
|
.PP
|
||||||
.EX
|
.EX
|
||||||
$LF_LEVEL current nesting level
|
unix windows
|
||||||
.EE
|
cmd open &$OPENER "$f" cmd open &%OPENER% %f%
|
||||||
.PP
|
map e $$EDITOR "$f" map e $%EDITOR% %f%
|
||||||
The following default values are set to the environmental variables on unix when they are not set or empty:
|
map i $$PAGER "$f" map i !%PAGER% %f%
|
||||||
.PP
|
map w $$SHELL map w $%SHELL%
|
||||||
.EX
|
|
||||||
$OPENER open # macos
|
|
||||||
$OPENER xdg-open # others
|
|
||||||
$EDITOR vi
|
|
||||||
$PAGER less
|
|
||||||
$SHELL sh
|
|
||||||
.EE
|
|
||||||
.PP
|
|
||||||
The following default values are set to the environmental variables on windows when they are not set or empty:
|
|
||||||
.PP
|
|
||||||
.EX
|
|
||||||
%OPENER% start
|
|
||||||
%EDITOR% notepad
|
|
||||||
%PAGER% more
|
|
||||||
%SHELL% cmd
|
|
||||||
.EE
|
.EE
|
||||||
.PP
|
.PP
|
||||||
The following additional keybindings are provided by default:
|
The following additional keybindings are provided by default:
|
||||||
@@ -205,14 +191,6 @@ The following additional keybindings are provided by default:
|
|||||||
map gh cd ~
|
map gh cd ~
|
||||||
map <space> :toggle; down
|
map <space> :toggle; down
|
||||||
.EE
|
.EE
|
||||||
.PP
|
|
||||||
The following keybindings to applications are provided by default:
|
|
||||||
.PP
|
|
||||||
.EX
|
|
||||||
map e $$EDITOR $f
|
|
||||||
map i $$PAGER $f
|
|
||||||
map w $$SHELL
|
|
||||||
.EE
|
|
||||||
.SH CONFIGURATION
|
.SH CONFIGURATION
|
||||||
Configuration files should be located at:
|
Configuration files should be located at:
|
||||||
.PP
|
.PP
|
||||||
@@ -246,6 +224,641 @@ You can configure the default values of following variables to change these loca
|
|||||||
.EE
|
.EE
|
||||||
.PP
|
.PP
|
||||||
A sample configuration file can be found at https://github.com/gokcehan/lf/blob/master/etc/lfrc.example.
|
A sample configuration file can be found at https://github.com/gokcehan/lf/blob/master/etc/lfrc.example.
|
||||||
|
.SH COMMANDS
|
||||||
|
This section shows information about builtin commands. Modal commands do not take any arguments, but instead change the operation mode to read their input conveniently, and so they are meant to be assigned to keybindings.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
quit (default 'q')
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Quit lf and return to the shell.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
up (default 'k' and '<up>')
|
||||||
|
half-up (default '<c-u>')
|
||||||
|
page-up (default '<c-b>' and '<pgup>')
|
||||||
|
down (default 'j' and '<down>')
|
||||||
|
half-down (default '<c-d>')
|
||||||
|
page-down (default '<c-f>' and '<pgdn>')
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Move the current file selection upwards/downwards by one/half a page/full page.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
updir (default 'h' and '<left>')
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Change the current working directory to the parent directory.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
open (default 'l' and '<right>')
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
If the current file is a directory, then change the current directory to it, otherwise, execute the 'open' command. A default 'open' command is provided to call the default system opener asynchronously with the current file as the argument. A custom 'open' command can be defined to override this default.
|
||||||
|
.PP
|
||||||
|
(See also 'OPENER' variable and 'Opening Files' section)
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
top (default 'gg' and '<home>')
|
||||||
|
bottom (default 'G' and '<end>')
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Move the current file selection to the top/bottom of the directory.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
toggle
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Toggle the selection of the current file or files given as arguments.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
invert (default 'v')
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Reverse the selection of all files in the current directory (i.e. 'toggle' all files). Selections in other directories are not effected by this command. You can define a new command to select all files in the directory by combining 'invert' with 'unselect' (i.e. `cmd select-all :unselect; invert`), though this will also remove selections in other directories.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
unselect (default 'u')
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Remove the selection of all files in all directories.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
glob-select
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Select files that match the given glob.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
glob-unselect
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Unselect files that match the given glob.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
copy (default 'y')
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
If there are no selections, save the path of the current file to the copy buffer, otherwise, copy the paths of selected files.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
cut (default 'd')
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
If there are no selections, save the path of the current file to the cut buffer, otherwise, copy the paths of selected files.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
paste (default 'p')
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Copy/Move files in copy/cut buffer to the current working directory.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
clear (default 'c')
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Clear file paths in copy/cut buffer.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
sync
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Synchronize copied/cut files with server. This command is automatically called when required.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
draw
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Draw the screen. This command is automatically called when required.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
redraw (default '<c-l>')
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Synchronize the terminal and redraw the screen.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
load
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Load modified files and directories. This command is automatically called when required.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
reload (default '<c-r>')
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Flush the cache and reload all files and directories.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
echo
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Print given arguments to the message line at the bottom.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
echomsg
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Print given arguments to the message line at the bottom and also to the log file.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
echoerr
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Print given arguments to the message line at the bottom in red color and also to the log file.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
cd
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Change the working directory to the given argument.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
select
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Change the current file selection to the given argument.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
delete (modal)
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Remove the current file or selected file(s).
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
rename (modal) (default 'r')
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Rename the current file using the builtin method. A custom 'rename' command can be defined to override this default.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
source
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Read the configuration file given in the argument.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
push
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Simulate key pushes given in the argument.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
read (modal) (default ':')
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Read a command to evaluate.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
shell (modal) (default '$')
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Read a shell command to execute.
|
||||||
|
.PP
|
||||||
|
(See also 'Prefixes' and 'Shell Commands' sections)
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
shell-pipe (modal) (default '%')
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Read a shell command to execute piping its standard I/O to the bottom statline.
|
||||||
|
.PP
|
||||||
|
(See also 'Prefixes' and 'Piping Shell Commands' sections)
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
shell-wait (modal) (default '!')
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Read a shell command to execute and wait for a key press in the end.
|
||||||
|
.PP
|
||||||
|
(See also 'Prefixes' and 'Waiting Shell Commands' sections)
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
shell-async (modal) (default '&')
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Read a shell command to execute synchronously without standard I/O.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
find (modal) (default 'f')
|
||||||
|
find-back (modal) (default 'F')
|
||||||
|
find-next (default ';')
|
||||||
|
find-prev (default ',')
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Read key(s) to find the appropriate file name match in the forward/backward direction and jump to the next/previous match.
|
||||||
|
.PP
|
||||||
|
(See also 'anchorfind', 'findlen', 'wrapscan', 'ignorecase', 'smartcase', 'ignoredia', and 'smartdia' options and 'Searching Files' section)
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
search (default '/')
|
||||||
|
search-back (default '?')
|
||||||
|
search-next (default 'n')
|
||||||
|
search-prev (default 'N')
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Read a pattern to search for a file name match in the forward/backward direction and jump to the next/previous match.
|
||||||
|
.PP
|
||||||
|
(See also 'globsearch', 'incsearch', 'wrapscan', 'ignorecase', 'smartcase', 'ignoredia', and 'smartdia' options and 'Searching Files' section)
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
mark-save (modal) (default 'm')
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Save the current directory as a bookmark assigned to the given key.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
mark-load (modal) (default "'")
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Change the current directory to the bookmark assigned to the given key. A special bookmark "'" holds the previous directory after a 'mark-load', 'cd', or 'select' command.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
mark-remove (modal) (default `"`)
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Remove a bookmark assigned to the given key.
|
||||||
|
.SH COMMAND LINE COMMANDS
|
||||||
|
This section shows information about command line commands. These should be mostly compatible with readline keybindings. A character refers to a unicode code point, a word consists of letters and digits, and a unix word consists of any non-blank characters.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
cmd-escape (default '<esc>')
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Quit command line mode and return to normal mode.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
cmd-complete (default '<tab>')
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Autocomplete the current word.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
cmd-menu-complete
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Autocomplete the current word, then you can press the binded key/s again to cycle completition options.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
cmd-menu-complete-back
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Autocomplete the current word, then you can press the binded key/s again to cycle completition options backwards.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
cmd-enter (default '<c-j>' and '<enter>')
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Execute the current line.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
cmd-interrupt (default '<c-c>')
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Interrupt the current shell-pipe command and return to the normal mode.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
cmd-history-next (default '<c-n>')
|
||||||
|
cmd-history-prev (default '<c-p>')
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Go to next/previous item in the history.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
cmd-left (default '<c-b>' and '<left>')
|
||||||
|
cmd-right (default '<c-f>' and '<right>')
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Move the cursor to the left/right.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
cmd-home (default '<c-a>' and '<home>')
|
||||||
|
cmd-end (default '<c-e>' and '<end>')
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Move the cursor to the beginning/end of line.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
cmd-delete (default '<c-d>' and '<delete>')
|
||||||
|
cmd-delete-back (default '<backspace>' and '<backspace2>')
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Delete the next character in forward/backward direction.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
cmd-delete-home (default '<c-u>')
|
||||||
|
cmd-delete-end (default '<c-k>')
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Delete everything up to the beginning/end of line.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
cmd-delete-unix-word (default '<c-w>')
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Delete the previous unix word.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
cmd-yank (default '<c-y>')
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Paste the buffer content containing the last deleted item.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
cmd-transpose (default '<c-t>')
|
||||||
|
cmd-transpose-word (default '<a-t>')
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Transpose the positions of last two characters/words.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
cmd-word (default '<a-f>')
|
||||||
|
cmd-word-back (default '<a-b>')
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Move the cursor by one word in forward/backward direction.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
cmd-delete-word (default '<a-d>')
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Delete the next word in forward direction.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
cmd-capitalize-word (default '<a-c>')
|
||||||
|
cmd-uppercase-word (default '<a-u>')
|
||||||
|
cmd-lowercase-word (default '<a-l>')
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Capitalize/uppercase/lowercase the current word and jump to the next word.
|
||||||
|
.SH OPTIONS
|
||||||
|
This section shows information about options to customize the behavior. Character ':' is used as the separator for list options '[]int' and '[]string'.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
anchorfind bool (default on)
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
When this option is enabled, find command starts matching patterns from the beginning of file names, otherwise, it can match at an arbitrary position.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
dircounts bool (default off)
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
When this option is enabled, directory sizes show the number of items inside instead of the size of directory file. The former needs to be calculated by reading the directory and counting the items inside. The latter is directly provided by the operating system and it does not require any calculation, though it is non-intuitive and it can often be misleading. This option is disabled by default for performance reasons. This option only has an effect when 'info' has a 'size' field and the pane is wide enough to show the information. A thousand items are counted per directory at most, and bigger directories are shown as '999+'.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
dirfirst bool (default on)
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Show directories first above regular files.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
drawbox bool (default off)
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Draw boxes around panes with box drawing characters.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
errorfmt string (default "\e033[7;31;47m%s\e033[0m")
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Format string of error messages shown in the bottom message line.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
filesep string (default "\en")
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
File separator used in environment variables 'fs' and 'fx'.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
findlen int (default 1)
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Number of characters prompted for the find command. When this value is set to 0, find command prompts until there is only a single match left.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
globsearch bool (default off)
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
When this option is enabled, search command patterns are considered as globs, otherwise they are literals. With globbing, '*' matches any sequence, '?' matches any character, and '[...]' or '[^...] matches character sets or ranges. Otherwise, these characters are interpreted as they are.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
hidden bool (default off)
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Show hidden files. On unix systems, hidden files are determined by the value of 'hiddenfiles'. On windows, only files with hidden attributes are considered hidden files.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
hiddenfiles []string (default '.*')
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
List of hidden file glob patterns. Patterns can be given as relative or absolute paths. Globbing supports the usual special characters, '*' to match any sequence, '?' to match any character, and '[...]' or '[^...] to match character sets or ranges. In addition, if a pattern starts with '!', then its matches are excluded from hidden files.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
icons bool (default off)
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Show icons before each item in the list. By default, only two icons, 🗀 (U+1F5C0) and 🗎 (U+1F5CE), are used for directories and files respectively, as they are supported in the unicode standard. Icons can be configured with an environment variable named 'LF_ICONS'. The syntax of this variable is similar to 'LS_COLORS'. See the wiki page for an example icon configuration.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
ifs string (default '')
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Sets 'IFS' variable in shell commands. It works by adding the assignment to the beginning of the command string as 'IFS='...'; ...'. The reason is that 'IFS' variable is not inherited by the shell for security reasons. This method assumes a POSIX shell syntax and so it can fail for non-POSIX shells. This option has no effect when the value is left empty. This option does not have any effect on windows.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
ignorecase bool (default on)
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Ignore case in sorting and search patterns.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
ignoredia bool (default on)
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Ignore diacritics in sorting and search patterns.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
incsearch bool (default off)
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Jump to the first match after each keystroke during searching.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
info []string (default '')
|
||||||
|
.EE
|
||||||
|
.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.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
number bool (default off)
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Show the position number for directory items at the left side of pane. When 'relativenumber' is enabled, only the current line shows the absolute position and relative positions are shown for the rest.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
period int (default 0)
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Set the interval in seconds for periodic checks of directory updates. This works by periodically calling the 'load' command. Note that directories are already updated automatically in many cases. This option can be useful when there is an external process changing the displayed directory and you are not doing anything in lf. Periodic checks are disabled when the value of this option is set to zero.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
preview bool (default on)
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Show previews of files and directories at the right most pane. If the file has more lines than the preview pane, rest of the lines are not read. Files containing the null character (U+0000) in the read portion are considered binary files and displayed as 'binary'.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
previewer string (default '') (not filtered if empty)
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Set the path of a previewer file to filter the content of regular files for previewing. The file should be executable. Two arguments are passed to the file, first is the current file name, and second is the height of preview pane. SIGPIPE signal is sent when enough lines are read. Preview filtering is disabled and files are displayed as they are when the value of this option is left empty.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
promptfmt string (default "\e033[32;1m%u@%h\e033[0m:\e033[34;1m%w/\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, 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.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
ratios []int (default '1:2:3')
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
List of ratios of pane widths. Number of items in the list determines the number of panes in the ui. When 'preview' option is enabled, the right most number is used for the width of preview pane.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
relativenumber bool (default off)
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Show the position number relative to the current line. When 'number' is enabled, current line shows the absolute position, otherwise nothing is shown.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
reverse bool (default off)
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Reverse the direction of sort.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
scrolloff int (default 0)
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Minimum number of offset lines shown at all times in the top and the bottom of the screen when scrolling. The current line is kept in the middle when this option is set to a large value that is bigger than the half of number of lines. A smaller offset can be used when the current file is close to the beginning or end of the list to show the maximum number of items.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
shell string (default 'sh' for unix and 'cmd' for windows)
|
||||||
|
.EE
|
||||||
|
.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'.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
shellopts []string (default '')
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
List of shell options to pass to the shell executable.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
smartcase bool (default on)
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Override 'ignorecase' option when the pattern contains an uppercase character. This option has no effect when 'ignorecase' is disabled.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
smartdia bool (default off)
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Override 'ignoredia' option when the pattern contains a character with diacritic. This option has no effect when 'ignoredia' is disabled.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
sortby string (default 'natural')
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Sort type for directories. Currently supported sort types are 'natural', 'name', 'size', 'time', 'ctime', 'atime', and 'ext'.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
tabstop int (default 8)
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Number of space characters to show for horizontal tabulation (U+0009) character.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
timefmt string (default 'Mon Jan _2 15:04:05 2006')
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Format string of the file modification time shown in the bottom line.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
truncatechar string (default '~')
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Truncate character shown at the end when the file name does not fit to the pane.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
wrapscan bool (default on)
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Searching can wrap around the file list.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
wrapscroll bool (default off)
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Scrolling can wrap around the file list.
|
||||||
|
.SH ENVIRONMENT VARIABLES
|
||||||
|
The following variables are exported for shell commands: These are referred with a '$' prefix on POSIX shells (e.g. '$f'), between '%' characters on Windows cmd (e.g. '%f%'), and with a '$env:' prefix on Windows powershell (e.g. '$env:f').
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
f
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Current file selection as a full path.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
fs
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Selected file(s) separated with the value of 'filesep' option as full path(s).
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
fx
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Selected file(s) (i.e. 'fs') if there are any selected files, otherwise current file selection (i.e. 'f').
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
id
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
Id of the running client.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
LF_LEVEL
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
The value of this variable is set to the current nesting level when you run lf from a shell spawned inside lf. You can add the value of this variable to your shell prompt to make it clear that your shell runs inside lf. For example, with POSIX shells, you can use '[ -n "$LF_LEVEL" ] && PS1="$PS1""(lf level: $LF_LEVEL) "' in your shell configuration file (e.g. '~/.bashrc').
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
OPENER
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
If this variable is set in the environment, use the same value, otherwise set the value to 'start' in Windows, 'open' in MacOS, 'xdg-open' in others.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
EDITOR
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
If this variable is set in the environment, use the same value, otherwise set the value to 'vi' on unix, 'notepad' in Windows.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
PAGER
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
If this variable is set in the environment, use the same value, otherwise set the value to 'less' on unix, 'more' in Windows.
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
SHELL
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
|
If this variable is set in the environment, use the same value, otherwise set the value to 'sh' on unix, 'cmd' in Windows.
|
||||||
.SH PREFIXES
|
.SH PREFIXES
|
||||||
The following command prefixes are used by lf:
|
The following command prefixes are used by lf:
|
||||||
.PP
|
.PP
|
||||||
@@ -467,7 +1080,7 @@ You can also output error messages in the command and it will show up in the sta
|
|||||||
cmd rename %[ -e $1 ] && printf "file exists" || mv $f $1
|
cmd rename %[ -e $1 ] && printf "file exists" || mv $f $1
|
||||||
.EE
|
.EE
|
||||||
.PP
|
.PP
|
||||||
One thing to be careful is that although input is still line buffered, output and error are byte buffered and verbose commands will be very slow to display.
|
Note that input is line buffered and output and error are byte buffered.
|
||||||
.SH WAITING SHELL COMMANDS
|
.SH WAITING SHELL COMMANDS
|
||||||
Waiting shell commands are similar to regular shell commands except that they wait for a key press when the command is finished. These can be useful to see the output of a program before the ui is resumed. Waiting shell commands are more appropriate than piping shell commands when the command is verbose and the output is best displayed as multiline.
|
Waiting shell commands are similar to regular shell commands except that they wait for a key press when the command is finished. These can be useful to see the output of a program before the ui is resumed. Waiting shell commands are more appropriate than piping shell commands when the command is verbose and the output is best displayed as multiline.
|
||||||
.SH ASYNCHRONOUS SHELL COMMANDS
|
.SH ASYNCHRONOUS SHELL COMMANDS
|
||||||
@@ -623,6 +1236,13 @@ In order to use this feature you need to set the value of 'previewer' option to
|
|||||||
map i $~/.config/lf/pv.sh $f | less -R
|
map i $~/.config/lf/pv.sh $f | less -R
|
||||||
.EE
|
.EE
|
||||||
.PP
|
.PP
|
||||||
|
For 'less' pager, you may instead utilize 'LESSOPEN' mechanism so that useful information about the file such as the full path of the file can be displayed in the statusline below:
|
||||||
|
.PP
|
||||||
|
.EX
|
||||||
|
set previewer ~/.config/lf/pv.sh
|
||||||
|
map i $LESSOPEN='| ~/.config/lf/pv.sh %s' less -R $f
|
||||||
|
.EE
|
||||||
|
.PP
|
||||||
Since this script is called for each file selection change it needs to be as efficient as possible and this responsibility is left to the user. You may use file extensions to determine the type of file more efficiently compared to obtaining mime types from 'file' command. Extensions can then be used to match cleanly within a conditional:
|
Since this script is called for each file selection change it needs to be as efficient as possible and this responsibility is left to the user. You may use file extensions to determine the type of file more efficiently compared to obtaining mime types from 'file' command. Extensions can then be used to match cleanly within a conditional:
|
||||||
.PP
|
.PP
|
||||||
.EX
|
.EX
|
||||||
@@ -641,6 +1261,8 @@ Since this script is called for each file selection change it needs to be as eff
|
|||||||
.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.
|
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.
|
||||||
|
.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.
|
||||||
.SH CHANGING DIRECTORY
|
.SH CHANGING DIRECTORY
|
||||||
lf changes the working directory of the process to the current directory so that shell commands always work in the displayed directory. After quitting, it returns to the original directory where it is first launched like all shell programs. If you want to stay in the current directory after quitting, you can use one of the example wrapper shell scripts provided in the repository.
|
lf changes the working directory of the process to the current directory so that shell commands always work in the displayed directory. After quitting, it returns to the original directory where it is first launched like all shell programs. If you want to stay in the current directory after quitting, you can use one of the example wrapper shell scripts provided in the repository.
|
||||||
.PP
|
.PP
|
||||||
@@ -675,9 +1297,9 @@ If '$LS_COLORS' variable is not set, '$LSCOLORS' variable is checked instead. Th
|
|||||||
.PP
|
.PP
|
||||||
If both of these environment variables are not set, then lf fallbacks to its default colorscheme. Default lf colors are taken from GNU dircolors defaults. These defaults use 8 basic colors and bold attribute.
|
If both of these environment variables are not set, then lf fallbacks to its default colorscheme. Default lf colors are taken from GNU dircolors defaults. These defaults use 8 basic colors and bold attribute.
|
||||||
.PP
|
.PP
|
||||||
You should also note that lf uses 8 color mode by default which uses sgr 3-bit color escapes (e.g. '\e033[34m'). If you want to use 256 colors, you need to enable 'color256' option which then makes lf use sgr 8-bit color escapes (e.g. '\e033[38;5;4m'). This option is intended to eliminate differences between default colors used by ls and lf since terminals may render 3-bit and 8-bit escapes differently even for the same color.
|
It is worth noting that lf uses as many colors are advertised by your terminal's entry in your systems terminfo or infocmp database, if this is not present lf will default to an internal database. For terminals supporting 24-bit (or "true") color that do not have a database entry (or one that does not advertise all capabilities), support can be enabled by either setting the '$COLORTERM' variable to "truecolor" or ensuring '$TERM' is set to a value that ends with "-truecolor".
|
||||||
.PP
|
.PP
|
||||||
Keeping this mechanism in mind, you can configure lf colors in two different ways. First, you can configure 8 basic colors used by your terminal and lf should pick up those colors automatically. Depending on your terminal, you should be able to select your colors from a 24-bit palette. This is the recommended approach as colors used by other programs will also match each other.
|
Keeping this in mind, you can configure lf colors in two different ways. First, you can configure 8 basic colors used by your terminal and lf should pick up those colors automatically. Depending on your terminal, you should be able to select your colors from a 24-bit palette. This is the recommended approach as colors used by other programs will also match each other.
|
||||||
.PP
|
.PP
|
||||||
Second, you can set the values of environmental variables mentioned above for fine grained customization. This is useful to change colors used for different file types and extensions. '$LS_COLORS' is more powerful than '$LSCOLORS' and it can be used even when GNU programs are not installed on the system. You can combine this second method with the first method for best results.
|
Second, you can set the values of environmental variables mentioned above for fine grained customization. This is useful to change colors used for different file types and extensions. '$LS_COLORS' is more powerful than '$LSCOLORS' and it can be used even when GNU programs are not installed on the system. You can combine this second method with the first method for best results.
|
||||||
.PP
|
.PP
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"reflect"
|
||||||
"runtime"
|
"runtime"
|
||||||
"runtime/pprof"
|
"runtime/pprof"
|
||||||
"strconv"
|
"strconv"
|
||||||
@@ -61,9 +62,88 @@ func exportEnvVars() {
|
|||||||
os.Setenv("LF_LEVEL", strconv.Itoa(level))
|
os.Setenv("LF_LEVEL", strconv.Itoa(level))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// used by exportOpts below
|
||||||
|
func fieldToString(field reflect.Value) string {
|
||||||
|
kind := field.Kind()
|
||||||
|
var value string
|
||||||
|
|
||||||
|
switch kind {
|
||||||
|
case reflect.Int:
|
||||||
|
value = strconv.Itoa(int(field.Int()))
|
||||||
|
case reflect.Bool:
|
||||||
|
value = strconv.FormatBool(field.Bool())
|
||||||
|
case reflect.Slice:
|
||||||
|
for i := 0; i < field.Len(); i++ {
|
||||||
|
element := field.Index(i)
|
||||||
|
|
||||||
|
if i == 0 {
|
||||||
|
value = fieldToString(element)
|
||||||
|
} else {
|
||||||
|
value += ":" + fieldToString(element)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
value = field.String()
|
||||||
|
}
|
||||||
|
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
|
||||||
|
func exportOpts() {
|
||||||
|
e := reflect.ValueOf(&gOpts).Elem()
|
||||||
|
|
||||||
|
for i := 0; i < e.NumField(); i++ {
|
||||||
|
// Get name and prefix it with lf_
|
||||||
|
name := e.Type().Field(i).Name
|
||||||
|
name = fmt.Sprintf("lf_%s", name)
|
||||||
|
|
||||||
|
// Skip maps
|
||||||
|
if name == "lf_keys" || name == "lf_cmdkeys" || name == "lf_cmds" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get string representation of the value
|
||||||
|
if name == "lf_sortType" {
|
||||||
|
var sortby string
|
||||||
|
|
||||||
|
switch gOpts.sortType.method {
|
||||||
|
case naturalSort:
|
||||||
|
sortby = "natural"
|
||||||
|
case nameSort:
|
||||||
|
sortby = "name"
|
||||||
|
case sizeSort:
|
||||||
|
sortby = "size"
|
||||||
|
case timeSort:
|
||||||
|
sortby = "time"
|
||||||
|
case ctimeSort:
|
||||||
|
sortby = "ctime"
|
||||||
|
case atimeSort:
|
||||||
|
sortby = "atime"
|
||||||
|
case extSort:
|
||||||
|
sortby = "ext"
|
||||||
|
}
|
||||||
|
|
||||||
|
os.Setenv("lf_sortby", sortby)
|
||||||
|
|
||||||
|
reverse := strconv.FormatBool(gOpts.sortType.option&reverseSort != 0)
|
||||||
|
os.Setenv("lf_reverse", reverse)
|
||||||
|
|
||||||
|
hidden := strconv.FormatBool(gOpts.sortType.option&hiddenSort != 0)
|
||||||
|
os.Setenv("lf_hidden", hidden)
|
||||||
|
|
||||||
|
dirfirst := strconv.FormatBool(gOpts.sortType.option&dirfirstSort != 0)
|
||||||
|
os.Setenv("lf_dirfirst", dirfirst)
|
||||||
|
} else {
|
||||||
|
field := e.Field(i)
|
||||||
|
value := fieldToString(field)
|
||||||
|
|
||||||
|
os.Setenv(name, value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func startServer() {
|
func startServer() {
|
||||||
cmd := detachedCommand(os.Args[0], "-server")
|
cmd := detachedCommand(os.Args[0], "-server")
|
||||||
cmd.Dir = gUser.HomeDir
|
|
||||||
if err := cmd.Start(); err != nil {
|
if err := cmd.Start(); err != nil {
|
||||||
log.Printf("starting server: %s", err)
|
log.Printf("starting server: %s", err)
|
||||||
}
|
}
|
||||||
@@ -156,6 +236,7 @@ func main() {
|
|||||||
log.Fatalf("remote command: %s", err)
|
log.Fatalf("remote command: %s", err)
|
||||||
}
|
}
|
||||||
case *serverMode:
|
case *serverMode:
|
||||||
|
os.Chdir(gUser.HomeDir)
|
||||||
gServerLogPath = filepath.Join(os.TempDir(), fmt.Sprintf("lf.%s.server.log", gUser.Username))
|
gServerLogPath = filepath.Join(os.TempDir(), fmt.Sprintf("lf.%s.server.log", gUser.Username))
|
||||||
serve()
|
serve()
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -166,32 +166,45 @@ func humanize(size int64) string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
// This regexp is used to partition a given string as numbers and non-numbers.
|
// This function compares two strings for natural sorting which takes into
|
||||||
// For instance, if your input is 'foo123bar456' you get a slice of 'foo',
|
// account values of numbers in strings. For example, '2' is less than '10',
|
||||||
// '123', 'bar', and '456'. This is useful for natural sorting which takes into
|
// and similarly 'foo2bar' is less than 'foo10bar', but 'bar2bar' is greater
|
||||||
// account values of numbers within strings.
|
// than 'foo10bar'.
|
||||||
var rePart = regexp.MustCompile(`\d+|\D+`)
|
|
||||||
|
|
||||||
func naturalLess(s1, s2 string) bool {
|
func naturalLess(s1, s2 string) bool {
|
||||||
parts1 := rePart.FindAllString(s1, -1)
|
lo1, lo2, hi1, hi2 := 0, 0, 0, 0
|
||||||
parts2 := rePart.FindAllString(s2, -1)
|
for {
|
||||||
|
if hi1 >= len(s1) {
|
||||||
|
return hi2 != len(s2)
|
||||||
|
}
|
||||||
|
|
||||||
for i := 0; i < len(parts1) && i < len(parts2); i++ {
|
if hi2 >= len(s2) {
|
||||||
if parts1[i] == parts2[i] {
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
isDigit1 := isDigit(s1[hi1])
|
||||||
|
isDigit2 := isDigit(s2[hi2])
|
||||||
|
|
||||||
|
for lo1 = hi1; hi1 < len(s1) && isDigit(s1[hi1]) == isDigit1; hi1++ {
|
||||||
|
}
|
||||||
|
|
||||||
|
for lo2 = hi2; hi2 < len(s2) && isDigit(s2[hi2]) == isDigit2; hi2++ {
|
||||||
|
}
|
||||||
|
|
||||||
|
if s1[lo1:hi1] == s2[lo2:hi2] {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
num1, err1 := strconv.Atoi(parts1[i])
|
if isDigit1 && isDigit2 {
|
||||||
num2, err2 := strconv.Atoi(parts2[i])
|
num1, err1 := strconv.Atoi(s1[lo1:hi1])
|
||||||
|
num2, err2 := strconv.Atoi(s2[lo2:hi2])
|
||||||
|
|
||||||
if err1 == nil && err2 == nil {
|
if err1 == nil && err2 == nil {
|
||||||
return num1 < num2
|
return num1 < num2
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return parts1[i] < parts2[i]
|
return s1[lo1:hi1] < s2[lo2:hi2]
|
||||||
}
|
}
|
||||||
|
|
||||||
return len(parts1) < len(parts2)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var reAltKey = regexp.MustCompile(`<a-(.)>`)
|
var reAltKey = regexp.MustCompile(`<a-(.)>`)
|
||||||
@@ -214,6 +227,10 @@ func max(a, b int) int {
|
|||||||
return b
|
return b
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func mod(a, b int) int {
|
||||||
|
return (a%b + b) % b
|
||||||
|
}
|
||||||
|
|
||||||
// We don't need no generic code
|
// We don't need no generic code
|
||||||
// We don't need no type control
|
// We don't need no type control
|
||||||
// No dark templates in compiler
|
// No dark templates in compiler
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"reflect"
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -69,7 +70,7 @@ func readdir(path string) ([]*file, error) {
|
|||||||
}
|
}
|
||||||
linkTarget, err = os.Readlink(fpath)
|
linkTarget, err = os.Readlink(fpath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return files, err
|
log.Printf("reading link target: %s", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,15 +105,18 @@ func readdir(path string) ([]*file, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type dir struct {
|
type dir struct {
|
||||||
loading bool // directory is loading from disk
|
loading bool // directory is loading from disk
|
||||||
loadTime time.Time // current loading or last load time
|
loadTime time.Time // current loading or last load time
|
||||||
ind int // index of current entry in files
|
ind int // index of current entry in files
|
||||||
pos int // position of current entry in ui
|
pos int // position of current entry in ui
|
||||||
path string // full path of directory
|
path string // full path of directory
|
||||||
files []*file // displayed files in directory including or excluding hidden ones
|
files []*file // displayed files in directory including or excluding hidden ones
|
||||||
allFiles []*file // all files in directory including hidden ones (same array as files)
|
allFiles []*file // all files in directory including hidden ones (same array as files)
|
||||||
sortType sortType // sort method and options from last sort
|
sortType sortType // sort method and options from last sort
|
||||||
noPerm bool // whether lf has no permission to open the directory
|
hiddenfiles []string // hiddenfiles value from last sort
|
||||||
|
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
|
||||||
}
|
}
|
||||||
|
|
||||||
func newDir(path string) *dir {
|
func newDir(path string) *dir {
|
||||||
@@ -132,19 +136,36 @@ func newDir(path string) *dir {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func normalize(s1, s2 string, ignorecase, ignoredia bool) (string, string) {
|
||||||
|
if gOpts.ignorecase {
|
||||||
|
s1 = strings.ToLower(s1)
|
||||||
|
s2 = strings.ToLower(s2)
|
||||||
|
}
|
||||||
|
if gOpts.ignoredia {
|
||||||
|
s1 = removeDiacritics(s1)
|
||||||
|
s2 = removeDiacritics(s2)
|
||||||
|
}
|
||||||
|
return s1, s2
|
||||||
|
}
|
||||||
|
|
||||||
func (dir *dir) sort() {
|
func (dir *dir) sort() {
|
||||||
dir.sortType = gOpts.sortType
|
dir.sortType = gOpts.sortType
|
||||||
|
dir.hiddenfiles = gOpts.hiddenfiles
|
||||||
|
dir.ignorecase = gOpts.ignorecase
|
||||||
|
dir.ignoredia = gOpts.ignoredia
|
||||||
|
|
||||||
dir.files = dir.allFiles
|
dir.files = dir.allFiles
|
||||||
|
|
||||||
switch gOpts.sortType.method {
|
switch dir.sortType.method {
|
||||||
case naturalSort:
|
case naturalSort:
|
||||||
sort.SliceStable(dir.files, func(i, j int) bool {
|
sort.SliceStable(dir.files, func(i, j int) bool {
|
||||||
return naturalLess(strings.ToLower(dir.files[i].Name()), strings.ToLower(dir.files[j].Name()))
|
s1, s2 := normalize(dir.files[i].Name(), dir.files[j].Name(), dir.ignorecase, dir.ignoredia)
|
||||||
|
return naturalLess(s1, s2)
|
||||||
})
|
})
|
||||||
case nameSort:
|
case nameSort:
|
||||||
sort.SliceStable(dir.files, func(i, j int) bool {
|
sort.SliceStable(dir.files, func(i, j int) bool {
|
||||||
return strings.ToLower(dir.files[i].Name()) < strings.ToLower(dir.files[j].Name())
|
s1, s2 := normalize(dir.files[i].Name(), dir.files[j].Name(), dir.ignorecase, dir.ignoredia)
|
||||||
|
return s1 < s2
|
||||||
})
|
})
|
||||||
case sizeSort:
|
case sizeSort:
|
||||||
sort.SliceStable(dir.files, func(i, j int) bool {
|
sort.SliceStable(dir.files, func(i, j int) bool {
|
||||||
@@ -164,33 +185,32 @@ func (dir *dir) sort() {
|
|||||||
})
|
})
|
||||||
case extSort:
|
case extSort:
|
||||||
sort.SliceStable(dir.files, func(i, j int) bool {
|
sort.SliceStable(dir.files, func(i, j int) bool {
|
||||||
leftExt := strings.ToLower(dir.files[i].ext)
|
ext1, ext2 := normalize(dir.files[i].ext, dir.files[j].ext, dir.ignorecase, dir.ignoredia)
|
||||||
rightExt := strings.ToLower(dir.files[j].ext)
|
|
||||||
|
|
||||||
// if the extension could not be determined (directories, files without)
|
// if the extension could not be determined (directories, files without)
|
||||||
// use a zero byte so that these files can be ranked higher
|
// use a zero byte so that these files can be ranked higher
|
||||||
if leftExt == "" {
|
if ext1 == "" {
|
||||||
leftExt = "\x00"
|
ext1 = "\x00"
|
||||||
}
|
}
|
||||||
if rightExt == "" {
|
if ext2 == "" {
|
||||||
rightExt = "\x00"
|
ext2 = "\x00"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
name1, name2 := normalize(dir.files[i].Name(), dir.files[j].Name(), dir.ignorecase, dir.ignoredia)
|
||||||
|
|
||||||
// in order to also have natural sorting with the filenames
|
// in order to also have natural sorting with the filenames
|
||||||
// combine the name with the ext but have the ext at the front
|
// combine the name with the ext but have the ext at the front
|
||||||
left := leftExt + strings.ToLower(dir.files[i].Name())
|
return (ext1 + name1) < (ext2 + name2)
|
||||||
right := rightExt + strings.ToLower(dir.files[j].Name())
|
|
||||||
return left < right
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if gOpts.sortType.option&reverseSort != 0 {
|
if dir.sortType.option&reverseSort != 0 {
|
||||||
for i, j := 0, len(dir.files)-1; i < j; i, j = i+1, j-1 {
|
for i, j := 0, len(dir.files)-1; i < j; i, j = i+1, j-1 {
|
||||||
dir.files[i], dir.files[j] = dir.files[j], dir.files[i]
|
dir.files[i], dir.files[j] = dir.files[j], dir.files[i]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if gOpts.sortType.option&dirfirstSort != 0 {
|
if dir.sortType.option&dirfirstSort != 0 {
|
||||||
sort.SliceStable(dir.files, func(i, j int) bool {
|
sort.SliceStable(dir.files, func(i, j int) bool {
|
||||||
if dir.files[i].IsDir() == dir.files[j].IsDir() {
|
if dir.files[i].IsDir() == dir.files[j].IsDir() {
|
||||||
return i < j
|
return i < j
|
||||||
@@ -202,15 +222,15 @@ func (dir *dir) sort() {
|
|||||||
// when hidden option is disabled, we move hidden files to the
|
// when hidden option is disabled, we move hidden files to the
|
||||||
// beginning of our file list and then set the beginning of displayed
|
// beginning of our file list and then set the beginning of displayed
|
||||||
// files to the first non-hidden file in the list
|
// files to the first non-hidden file in the list
|
||||||
if gOpts.sortType.option&hiddenSort == 0 {
|
if dir.sortType.option&hiddenSort == 0 {
|
||||||
sort.SliceStable(dir.files, func(i, j int) bool {
|
sort.SliceStable(dir.files, func(i, j int) bool {
|
||||||
if isHidden(dir.files[i], dir.path) && isHidden(dir.files[j], dir.path) {
|
if isHidden(dir.files[i], dir.path, dir.hiddenfiles) && isHidden(dir.files[j], dir.path, dir.hiddenfiles) {
|
||||||
return i < j
|
return i < j
|
||||||
}
|
}
|
||||||
return isHidden(dir.files[i], dir.path)
|
return isHidden(dir.files[i], dir.path, dir.hiddenfiles)
|
||||||
})
|
})
|
||||||
for i, f := range dir.files {
|
for i, f := range dir.files {
|
||||||
if !isHidden(f, dir.path) {
|
if !isHidden(f, dir.path, dir.hiddenfiles) {
|
||||||
dir.files = dir.files[i:]
|
dir.files = dir.files[i:]
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -232,6 +252,7 @@ func (dir *dir) sel(name string, height int) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dir.ind = max(dir.ind, 0)
|
||||||
dir.ind = min(dir.ind, len(dir.files)-1)
|
dir.ind = min(dir.ind, len(dir.files)-1)
|
||||||
|
|
||||||
if dir.files[dir.ind].Name() != name {
|
if dir.files[dir.ind].Name() != name {
|
||||||
@@ -286,7 +307,15 @@ type nav struct {
|
|||||||
func (nav *nav) loadDir(path string) *dir {
|
func (nav *nav) loadDir(path string) *dir {
|
||||||
d, ok := nav.dirCache[path]
|
d, ok := nav.dirCache[path]
|
||||||
if !ok {
|
if !ok {
|
||||||
d := &dir{loading: true, loadTime: time.Now(), path: path, sortType: gOpts.sortType}
|
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
|
nav.dirCache[path] = d
|
||||||
go func() {
|
go func() {
|
||||||
d := newDir(path)
|
d := newDir(path)
|
||||||
@@ -311,14 +340,25 @@ func (nav *nav) checkDir(dir *dir) {
|
|||||||
|
|
||||||
switch {
|
switch {
|
||||||
case s.ModTime().After(dir.loadTime):
|
case s.ModTime().After(dir.loadTime):
|
||||||
|
now := time.Now()
|
||||||
|
|
||||||
|
// XXX: Linux builtin exFAT drivers are able to predict modifications in the future
|
||||||
|
// https://bugs.launchpad.net/ubuntu/+source/ubuntu-meta/+bug/1872504
|
||||||
|
if s.ModTime().After(now) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
dir.loading = true
|
dir.loading = true
|
||||||
dir.loadTime = time.Now()
|
dir.loadTime = now
|
||||||
go func() {
|
go func() {
|
||||||
nd := newDir(dir.path)
|
nd := newDir(dir.path)
|
||||||
nd.sort()
|
nd.sort()
|
||||||
nav.dirChan <- nd
|
nav.dirChan <- nd
|
||||||
}()
|
}()
|
||||||
case dir.sortType != gOpts.sortType:
|
case dir.sortType != gOpts.sortType ||
|
||||||
|
!reflect.DeepEqual(dir.hiddenfiles, gOpts.hiddenfiles) ||
|
||||||
|
dir.ignorecase != gOpts.ignorecase ||
|
||||||
|
dir.ignoredia != gOpts.ignoredia:
|
||||||
dir.loading = true
|
dir.loading = true
|
||||||
go func() {
|
go func() {
|
||||||
dir.sort()
|
dir.sort()
|
||||||
@@ -416,18 +456,14 @@ func (nav *nav) position() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (nav *nav) preview() {
|
func (nav *nav) preview(path string) {
|
||||||
curr, err := nav.currFile()
|
reg := ®{loadTime: time.Now(), path: path}
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
reg := ®{loadTime: time.Now(), path: curr.path}
|
|
||||||
|
|
||||||
var reader io.Reader
|
var reader io.Reader
|
||||||
|
|
||||||
if len(gOpts.previewer) != 0 {
|
if len(gOpts.previewer) != 0 {
|
||||||
cmd := exec.Command(gOpts.previewer, curr.path, strconv.Itoa(nav.height))
|
exportOpts()
|
||||||
|
cmd := exec.Command(gOpts.previewer, path, strconv.Itoa(nav.height))
|
||||||
|
|
||||||
out, err := cmd.StdoutPipe()
|
out, err := cmd.StdoutPipe()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -442,7 +478,7 @@ func (nav *nav) preview() {
|
|||||||
defer out.Close()
|
defer out.Close()
|
||||||
reader = out
|
reader = out
|
||||||
} else {
|
} else {
|
||||||
f, err := os.Open(curr.path)
|
f, err := os.Open(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("opening file: %s", err)
|
log.Printf("opening file: %s", err)
|
||||||
}
|
}
|
||||||
@@ -476,7 +512,7 @@ func (nav *nav) loadReg(path string) *reg {
|
|||||||
if !ok {
|
if !ok {
|
||||||
r := ®{loading: true, loadTime: time.Now(), path: path}
|
r := ®{loading: true, loadTime: time.Now(), path: path}
|
||||||
nav.regCache[path] = r
|
nav.regCache[path] = r
|
||||||
go nav.preview()
|
go nav.preview(path)
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -491,9 +527,17 @@ func (nav *nav) checkReg(reg *reg) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
now := time.Now()
|
||||||
|
|
||||||
|
// XXX: Linux builtin exFAT drivers are able to predict modifications in the future
|
||||||
|
// https://bugs.launchpad.net/ubuntu/+source/ubuntu-meta/+bug/1872504
|
||||||
|
if s.ModTime().After(now) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if s.ModTime().After(reg.loadTime) {
|
if s.ModTime().After(reg.loadTime) {
|
||||||
reg.loadTime = time.Now()
|
reg.loadTime = now
|
||||||
go nav.preview()
|
go nav.preview(reg.path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ type sortType struct {
|
|||||||
|
|
||||||
var gOpts struct {
|
var gOpts struct {
|
||||||
anchorfind bool
|
anchorfind bool
|
||||||
color256 bool
|
|
||||||
dircounts bool
|
dircounts bool
|
||||||
drawbox bool
|
drawbox bool
|
||||||
globsearch bool
|
globsearch bool
|
||||||
@@ -68,13 +67,12 @@ var gOpts struct {
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
gOpts.anchorfind = true
|
gOpts.anchorfind = true
|
||||||
gOpts.color256 = false
|
|
||||||
gOpts.dircounts = false
|
gOpts.dircounts = false
|
||||||
gOpts.drawbox = false
|
gOpts.drawbox = false
|
||||||
gOpts.globsearch = false
|
gOpts.globsearch = false
|
||||||
gOpts.icons = false
|
gOpts.icons = false
|
||||||
gOpts.ignorecase = true
|
gOpts.ignorecase = true
|
||||||
gOpts.ignoredia = false
|
gOpts.ignoredia = true
|
||||||
gOpts.incsearch = false
|
gOpts.incsearch = false
|
||||||
gOpts.number = false
|
gOpts.number = false
|
||||||
gOpts.preview = true
|
gOpts.preview = true
|
||||||
@@ -176,8 +174,8 @@ func init() {
|
|||||||
gOpts.cmdkeys["<c-p>"] = &callExpr{"cmd-history-prev", nil, 1}
|
gOpts.cmdkeys["<c-p>"] = &callExpr{"cmd-history-prev", nil, 1}
|
||||||
gOpts.cmdkeys["<delete>"] = &callExpr{"cmd-delete", nil, 1}
|
gOpts.cmdkeys["<delete>"] = &callExpr{"cmd-delete", nil, 1}
|
||||||
gOpts.cmdkeys["<c-d>"] = &callExpr{"cmd-delete", nil, 1}
|
gOpts.cmdkeys["<c-d>"] = &callExpr{"cmd-delete", nil, 1}
|
||||||
gOpts.cmdkeys["<bs>"] = &callExpr{"cmd-delete-back", nil, 1}
|
gOpts.cmdkeys["<backspace>"] = &callExpr{"cmd-delete-back", nil, 1}
|
||||||
gOpts.cmdkeys["<bs2>"] = &callExpr{"cmd-delete-back", nil, 1}
|
gOpts.cmdkeys["<backspace2>"] = &callExpr{"cmd-delete-back", nil, 1}
|
||||||
gOpts.cmdkeys["<left>"] = &callExpr{"cmd-left", nil, 1}
|
gOpts.cmdkeys["<left>"] = &callExpr{"cmd-left", nil, 1}
|
||||||
gOpts.cmdkeys["<c-b>"] = &callExpr{"cmd-left", nil, 1}
|
gOpts.cmdkeys["<c-b>"] = &callExpr{"cmd-left", nil, 1}
|
||||||
gOpts.cmdkeys["<right>"] = &callExpr{"cmd-right", nil, 1}
|
gOpts.cmdkeys["<right>"] = &callExpr{"cmd-right", nil, 1}
|
||||||
|
|||||||
@@ -89,7 +89,9 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func detachedCommand(name string, arg ...string) *exec.Cmd {
|
func detachedCommand(name string, arg ...string) *exec.Cmd {
|
||||||
return exec.Command(name, arg...)
|
cmd := exec.Command(name, arg...)
|
||||||
|
cmd.SysProcAttr = &syscall.SysProcAttr{Setsid: true}
|
||||||
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
func pauseCommand() *exec.Cmd {
|
func pauseCommand() *exec.Cmd {
|
||||||
@@ -130,9 +132,9 @@ func isExecutable(f os.FileInfo) bool {
|
|||||||
return f.Mode()&0111 != 0
|
return f.Mode()&0111 != 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func isHidden(f os.FileInfo, path string) bool {
|
func isHidden(f os.FileInfo, path string, hiddenfiles []string) bool {
|
||||||
hidden := false
|
hidden := false
|
||||||
for _, pattern := range gOpts.hiddenfiles {
|
for _, pattern := range hiddenfiles {
|
||||||
matched := matchPattern(strings.TrimPrefix(pattern, "!"), f.Name(), path)
|
matched := matchPattern(strings.TrimPrefix(pattern, "!"), f.Name(), path)
|
||||||
if strings.HasPrefix(pattern, "!") && matched {
|
if strings.HasPrefix(pattern, "!") && matched {
|
||||||
hidden = false
|
hidden = false
|
||||||
|
|||||||
+2
-2
@@ -23,7 +23,7 @@ var envPathExt = os.Getenv("PATHEXT")
|
|||||||
var (
|
var (
|
||||||
gDefaultShell = "cmd"
|
gDefaultShell = "cmd"
|
||||||
gDefaultSocketProt = "tcp"
|
gDefaultSocketProt = "tcp"
|
||||||
gDefaultSocketPath = ":12345"
|
gDefaultSocketPath = "127.0.0.1:12345"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -109,7 +109,7 @@ func isExecutable(f os.FileInfo) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func isHidden(f os.FileInfo, path string) bool {
|
func isHidden(f os.FileInfo, path string, hiddenfiles []string) bool {
|
||||||
ptr, err := syscall.UTF16PtrFromString(filepath.Join(path, f.Name()))
|
ptr, err := syscall.UTF16PtrFromString(filepath.Join(path, f.Name()))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false
|
return false
|
||||||
|
|||||||
Reference in new issue
Block a user