Compare commits

14 Commits
Author SHA1 Message Date
Gokcehan 4601e74d66 export OLDPWD variable as the initial directory
cc #601
2021-04-13 23:48:49 +03:00
Gokcehan c8f60623f3 cleanup 2021-04-13 23:29:26 +03:00
Gokcehan fec767d11b dont change findlen to force find with cmd-enter
cc #605
2021-04-13 20:32:01 +03:00
gotroyb127 0dcfb3d4fe force find at cmd-enter (#605)
cc #559
2021-04-06 19:02:16 +03:00
gotroyb127 0cfd34f30d add 'waitmsg' option to configure the message after shell-wait commands (#604) 2021-04-06 18:57:23 +03:00
Gokcehan 229b7b1ade export PWD on windows to fix broken build
cc #591
2021-04-04 18:30:00 +03:00
Gokcehan ca0068514a add 'shellflag' option to customize shell flag
cc #597
2021-04-04 18:23:14 +03:00
Gokcehan aebff483a7 update tcell version to fix delete key on st
cc #486
2021-03-30 01:34:58 +03:00
Gokcehan 5166eef0b3 change to local tcell fork
cc #586
2021-03-30 01:12:58 +03:00
Gokcehan 73be81595e handle ui suspend/resume errors
cc #592
2021-03-28 18:54:40 +03:00
Gokcehan 06bf58851b update doc
cc #591
2021-03-19 14:00:00 +03:00
SeerLite b7aaa23bd0 Export $PWD to shell (#591)
Most shells use $PWD to show the right working directory when it's a
symlink. Without it, they'd fall back to the absolute path instead.
2021-03-19 13:58:10 +03:00
SPFab a9cb7156a3 added ability to use custom config file (#587) 2021-03-09 14:35:50 +03:00
Gokcehan 91f40b1f02 update example config 2021-03-03 18:06:44 +03:00
21 changed files with 174 additions and 38 deletions

No files matched your search

+23 -6
View File
@@ -174,9 +174,17 @@ func (app *app) loop() {
}() }()
} }
for _, path := range gConfigPaths { if gConfigPath != "" {
if _, err := os.Stat(path); !os.IsNotExist(err) { if _, err := os.Stat(gConfigPath); !os.IsNotExist(err) {
app.readFile(path) app.readFile(gConfigPath)
} else {
log.Printf("config file does not exist: %s", err)
}
} else {
for _, path := range gConfigPaths {
if _, err := os.Stat(path); !os.IsNotExist(err) {
app.readFile(path)
}
} }
} }
@@ -363,7 +371,7 @@ func (app *app) exportFiles() {
currSelections := app.nav.currSelections() currSelections := app.nav.currSelections()
exportFiles(currFile, currSelections) exportFiles(currFile, currSelections, app.nav.currDir().path)
} }
// This function is used to run a shell command. Modes are as follows: // This function is used to run a shell command. Modes are as follows:
@@ -388,8 +396,17 @@ func (app *app) runShell(s string, args []string, prefix string) {
cmd.Stderr = os.Stderr cmd.Stderr = os.Stderr
app.nav.previewChan <- "" app.nav.previewChan <- ""
app.ui.suspend() if err := app.ui.suspend(); err != nil {
defer app.ui.resume() log.Printf("suspend: %s", err)
}
defer func() {
if err := app.ui.resume(); err != nil {
app.writeHistory()
os.Remove(gLogPath)
os.Exit(3)
return
}
}()
defer app.nav.renew() defer app.nav.renew()
err = cmd.Run() err = cmd.Run()
+2
View File
@@ -118,6 +118,7 @@ var (
"smartdia", "smartdia",
"nosmartdia", "nosmartdia",
"smartdia!", "smartdia!",
"waitmsg",
"wrapscan", "wrapscan",
"nowrapscan", "nowrapscan",
"wrapscan!", "wrapscan!",
@@ -138,6 +139,7 @@ var (
"promptfmt", "promptfmt",
"ratios", "ratios",
"shell", "shell",
"shellflag",
"shellopts", "shellopts",
"sortby", "sortby",
"timefmt", "timefmt",
+23 -5
View File
@@ -6,9 +6,8 @@ lf is a terminal file manager.
Source code can be found in the repository at https://github.com/gokcehan/lf. Source code can be found in the repository at https://github.com/gokcehan/lf.
This documentation can either be read from terminal using 'lf -doc' or online This documentation can either be read from terminal using 'lf -doc' or online at https://godoc.org/github.com/gokcehan/lf.
at https://godoc.org/github.com/gokcehan/lf. You can also use 'doc' command You can also use 'doc' command (default '<f-1>') inside lf to view the documentation in a pager.
(default '<f-1>') inside lf to view the documentation in a pager.
You can run 'lf -help' to see descriptions of command line options. You can run 'lf -help' to see descriptions of command line options.
@@ -126,6 +125,7 @@ The following options can be used to customize the behavior of lf:
reverse bool (default off) reverse bool (default off)
scrolloff int (default 0) scrolloff int (default 0)
shell string (default 'sh' for unix and 'cmd' for windows) shell string (default 'sh' for unix and 'cmd' for windows)
shellflag string (default '-c' for unix and '/c' for windows)
shellopts []string (default '') shellopts []string (default '')
smartcase bool (default on) smartcase bool (default on)
smartdia bool (default off) smartdia bool (default off)
@@ -133,6 +133,7 @@ The following options can be used to customize the behavior of lf:
tabstop int (default 8) tabstop int (default 8)
timefmt string (default 'Mon Jan _2 15:04:05 2006') timefmt string (default 'Mon Jan _2 15:04:05 2006')
truncatechar string (default '~') truncatechar string (default '~')
waitmsg string (default 'Press any key to continue')
wrapscan bool (default on) wrapscan bool (default on)
wrapscroll bool (default off) wrapscroll bool (default off)
@@ -142,6 +143,8 @@ The following environment variables are exported for shell commands:
fs fs
fx fx
id id
PWD
OLDPWD
LF_LEVEL LF_LEVEL
OPENER OPENER
EDITOR EDITOR
@@ -640,8 +643,11 @@ A smaller offset can be used when the current file is close to the beginning or
shell string (default 'sh' for unix and 'cmd' for windows) shell string (default 'sh' for unix and 'cmd' for windows)
Shell executable to use for shell commands. Shell executable to use for shell commands.
Shell commands are executed as 'shell shellopts -c command -- arguments'. Shell commands are executed as 'shell shellopts shellflag command -- arguments'.
On windows, '/c' is used instead of '-c' which should work in 'cmd' and 'powershell'.
shellflag string (default '-c' for unix and '/c' for windows)
Command line flag used to pass shell commands.
shellopts []string (default '') shellopts []string (default '')
@@ -674,6 +680,10 @@ Format string of the file modification time shown in the bottom line.
Truncate character shown at the end when the file name does not fit to the pane. Truncate character shown at the end when the file name does not fit to the pane.
waitmsg string (default 'Press any key to continue')
String shown after commands of shell-wait type.
wrapscan bool (default on) wrapscan bool (default on)
Searching can wrap around the file list. Searching can wrap around the file list.
@@ -703,6 +713,14 @@ Selected file(s) (i.e. 'fs') if there are any selected files, otherwise current
Id of the running client. Id of the running client.
PWD
Present working directory.
OLDPWD
Initial working directory.
LF_LEVEL LF_LEVEL
The value of this variable is set to the current nesting level when you run lf from a shell spawned inside lf. The value of this variable is set to the current nesting level when you run lf from a shell spawned inside lf.
+21 -2
View File
@@ -129,6 +129,7 @@ The following options can be used to customize the behavior of lf:
reverse bool (default off) reverse bool (default off)
scrolloff int (default 0) scrolloff int (default 0)
shell string (default 'sh' for unix and 'cmd' for windows) shell string (default 'sh' for unix and 'cmd' for windows)
shellflag string (default '-c' for unix and '/c' for windows)
shellopts []string (default '') shellopts []string (default '')
smartcase bool (default on) smartcase bool (default on)
smartdia bool (default off) smartdia bool (default off)
@@ -136,6 +137,7 @@ The following options can be used to customize the behavior of lf:
tabstop int (default 8) tabstop int (default 8)
timefmt string (default 'Mon Jan _2 15:04:05 2006') timefmt string (default 'Mon Jan _2 15:04:05 2006')
truncatechar string (default '~') truncatechar string (default '~')
waitmsg string (default 'Press any key to continue')
wrapscan bool (default on) wrapscan bool (default on)
wrapscroll bool (default off) wrapscroll bool (default off)
@@ -145,6 +147,8 @@ The following environment variables are exported for shell commands:
fs fs
fx fx
id id
PWD
OLDPWD
LF_LEVEL LF_LEVEL
OPENER OPENER
EDITOR EDITOR
@@ -684,8 +688,11 @@ beginning or end of the list to show the maximum number of items.
shell string (default 'sh' for unix and 'cmd' for windows) shell string (default 'sh' for unix and 'cmd' for windows)
Shell executable to use for shell commands. Shell commands are executed as Shell executable to use for shell commands. Shell commands are executed as
'shell shellopts -c command -- arguments'. On windows, '/c' is used instead 'shell shellopts shellflag command -- arguments'.
of '-c' which should work in 'cmd' and 'powershell'.
shellflag string (default '-c' for unix and '/c' for windows)
Command line flag used to pass shell commands.
shellopts []string (default '') shellopts []string (default '')
@@ -720,6 +727,10 @@ Format string of the file modification time shown in the bottom line.
Truncate character shown at the end when the file name does not fit to the Truncate character shown at the end when the file name does not fit to the
pane. pane.
waitmsg string (default 'Press any key to continue')
String shown after commands of shell-wait type.
wrapscan bool (default on) wrapscan bool (default on)
Searching can wrap around the file list. Searching can wrap around the file list.
@@ -754,6 +765,14 @@ current file selection (i.e. 'f').
Id of the running client. Id of the running client.
PWD
Present working directory.
OLDPWD
Initial working directory.
LF_LEVEL LF_LEVEL
The value of this variable is set to the current nesting level when you run The value of this variable is set to the current nesting level when you run
+1
View File
@@ -9,6 +9,7 @@
_lf () { _lf () {
local -a opts=( local -a opts=(
-command -command
-config
-cpuprofile -cpuprofile
-doc -doc
-last-dir-path -last-dir-path
+1 -1
View File
@@ -9,7 +9,7 @@
# endif # endif
# #
set LF_ARGS = "-command -cpuprofile -doc -last-dir-path -memprofile -remote -selection-path -server -version -help " set LF_ARGS = "-command -config -cpuprofile -doc -last-dir-path -memprofile -remote -selection-path -server -version -help "
complete lf "C/-*/(${LF_ARGS})/" complete lf "C/-*/(${LF_ARGS})/"
complete lfcd "C/-*/(${LF_ARGS})/" complete lfcd "C/-*/(${LF_ARGS})/"
+1
View File
@@ -7,6 +7,7 @@
# #
complete -c lf -o command -r -d 'command to execute on client initialization' complete -c lf -o command -r -d 'command to execute on client initialization'
complete -c lf -o config -r -d 'path to the config file (instead of the usual paths)'
complete -c lf -o cpuprofile -r -d 'path to the file to write the CPU profile' complete -c lf -o cpuprofile -r -d 'path to the file to write the CPU profile'
complete -c lf -o doc -d 'show documentation' complete -c lf -o doc -d 'show documentation'
complete -c lf -o last-dir-path -r -d 'path to the file to write the last dir on exit (to use for cd)' complete -c lf -o last-dir-path -r -d 'path to the file to write the last dir on exit (to use for cd)'
+2
View File
@@ -10,6 +10,7 @@ Register-ArgumentCompleter -Native -CommandName 'lf' -ScriptBlock {
param($wordToComplete) param($wordToComplete)
$completions = @( $completions = @(
[CompletionResult]::new('-command ', '-command', [CompletionResultType]::ParameterName, 'command to execute on client initialization') [CompletionResult]::new('-command ', '-command', [CompletionResultType]::ParameterName, 'command to execute on client initialization')
[CompletionResult]::new('-config ', '-config', [CompletionResultType]::ParameterName, 'path to the config file (instead of the usual paths)')
[CompletionResult]::new('-cpuprofile ', '-cpuprofile', [CompletionResultType]::ParameterName, 'path to the file to write the CPU profile') [CompletionResult]::new('-cpuprofile ', '-cpuprofile', [CompletionResultType]::ParameterName, 'path to the file to write the CPU profile')
[CompletionResult]::new('-doc', '-doc', [CompletionResultType]::ParameterName, 'show documentation') [CompletionResult]::new('-doc', '-doc', [CompletionResultType]::ParameterName, 'show documentation')
[CompletionResult]::new('-last-dir-path ', '-last-dir-path', [CompletionResultType]::ParameterName, 'path to the file to write the last dir on exit (to use for cd)') [CompletionResult]::new('-last-dir-path ', '-last-dir-path', [CompletionResultType]::ParameterName, 'path to the file to write the last dir on exit (to use for cd)')
@@ -18,6 +19,7 @@ Register-ArgumentCompleter -Native -CommandName 'lf' -ScriptBlock {
[CompletionResult]::new('-selection-path ', '-selection-path', [CompletionResultType]::ParameterName, 'path to the file to write selected files on open (to use as open file dialog)') [CompletionResult]::new('-selection-path ', '-selection-path', [CompletionResultType]::ParameterName, 'path to the file to write selected files on open (to use as open file dialog)')
[CompletionResult]::new('-server', '-server', [CompletionResultType]::ParameterName, 'start server (automatic)') [CompletionResult]::new('-server', '-server', [CompletionResultType]::ParameterName, 'start server (automatic)')
[CompletionResult]::new('-version', '-version', [CompletionResultType]::ParameterName, 'show version') [CompletionResult]::new('-version', '-version', [CompletionResultType]::ParameterName, 'show version')
[CompletionResult]::new('-help', '-help', [CompletionResultType]::ParameterName, 'show help')
) )
if ($wordToComplete.StartsWith('-')) { if ($wordToComplete.StartsWith('-')) {
+2
View File
@@ -14,6 +14,7 @@ local arguments
arguments=( arguments=(
'-command[command to execute on client initialization]' '-command[command to execute on client initialization]'
'-config[path to the config file (instead of the usual paths)]'
'-cpuprofile[path to the file to write the CPU profile]' '-cpuprofile[path to the file to write the CPU profile]'
'-doc[show documentation]' '-doc[show documentation]'
'-last-dir-path[path to the file to write the last dir on exit (to use for cd)]' '-last-dir-path[path to the file to write the last dir on exit (to use for cd)]'
@@ -22,6 +23,7 @@ arguments=(
'-selection-path[path to the file to write selected files on open (to use as open file dialog)]' '-selection-path[path to the file to write selected files on open (to use as open file dialog)]'
'-server[start server (automatic)]' '-server[start server (automatic)]'
'-version[show version]' '-version[show version]'
'-help[show help]'
'*:filename:_files' '*:filename:_files'
) )
+5 -5
View File
@@ -4,11 +4,11 @@
# #
# You may also like to assign a key to this command: # You may also like to assign a key to this command:
# #
# Set-PSReadLineKeyHandler -Chord Ctrl+o -ScriptBlock { # Set-PSReadLineKeyHandler -Chord Ctrl+o -ScriptBlock {
# [Microsoft.PowerShell.PSConsoleReadLine]::RevertLine() # [Microsoft.PowerShell.PSConsoleReadLine]::RevertLine()
# [Microsoft.PowerShell.PSConsoleReadLine]::Insert('lfcd.ps1') # [Microsoft.PowerShell.PSConsoleReadLine]::Insert('lfcd.ps1')
# [Microsoft.PowerShell.PSConsoleReadLine]::AcceptLine() # [Microsoft.PowerShell.PSConsoleReadLine]::AcceptLine()
# } # }
# #
# You may put this in one of the profiles found in $PROFILE. # You may put this in one of the profiles found in $PROFILE.
# #
+1 -1
View File
@@ -1,4 +1,4 @@
# interpreter for shell commands (needs to be POSIX compatible) # interpreter for shell commands
set shell sh set shell sh
# set '-eu' options for shell commands # set '-eu' options for shell commands
+20
View File
@@ -178,6 +178,8 @@ func (e *setExpr) eval(app *app, args []string) {
gOpts.smartdia = false gOpts.smartdia = false
case "smartdia!": case "smartdia!":
gOpts.smartdia = !gOpts.smartdia gOpts.smartdia = !gOpts.smartdia
case "waitmsg":
gOpts.waitmsg = e.val
case "wrapscan": case "wrapscan":
gOpts.wrapscan = true gOpts.wrapscan = true
case "nowrapscan": case "nowrapscan":
@@ -309,6 +311,8 @@ func (e *setExpr) eval(app *app, args []string) {
app.ui.loadFile(app.nav, true) app.ui.loadFile(app.nav, true)
case "shell": case "shell":
gOpts.shell = e.val gOpts.shell = e.val
case "shellflag":
gOpts.shellflag = e.val
case "shellopts": case "shellopts":
if e.val == "" { if e.val == "" {
gOpts.shellopts = nil gOpts.shellopts = nil
@@ -1301,6 +1305,22 @@ func (e *callExpr) eval(app *app, args []string) {
app.ui.loadFile(app.nav, true) app.ui.loadFile(app.nav, true)
app.ui.loadFileInfo(app.nav) app.ui.loadFileInfo(app.nav)
} }
case "find: ":
app.ui.cmdPrefix = ""
if moved, found := app.nav.findNext(); !found {
app.ui.echoerrf("find: pattern not found: %s", app.nav.find)
} else if moved {
app.ui.loadFile(app.nav, true)
app.ui.loadFileInfo(app.nav)
}
case "find-back: ":
app.ui.cmdPrefix = ""
if moved, found := app.nav.findPrev(); !found {
app.ui.echoerrf("find-back: pattern not found: %s", app.nav.find)
} else if moved {
app.ui.loadFile(app.nav, true)
app.ui.loadFileInfo(app.nav)
}
case "rename: ": case "rename: ":
app.ui.cmdPrefix = "" app.ui.cmdPrefix = ""
if curr, err := app.nav.currFile(); err != nil { if curr, err := app.nav.currFile(); err != nil {
+2
View File
@@ -24,6 +24,7 @@ lf \- terminal file manager
.SH SYNOPSIS .SH SYNOPSIS
.SY lf .SY lf
.OP \-command command .OP \-command command
.OP \-config path
.OP \-cpuprofile path .OP \-cpuprofile path
.OP \-doc .OP \-doc
.OP \-last-dir-path path .OP \-last-dir-path path
@@ -32,6 +33,7 @@ lf \- terminal file manager
.OP \-selection-path path .OP \-selection-path path
.OP \-server .OP \-server
.OP \-version .OP \-version
.OP \-help
.RI [ directory ] .RI [ directory ]
.YS .YS
.SH DESCRIPTION .SH DESCRIPTION
+2
View File
@@ -8,3 +8,5 @@ require (
golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d
gopkg.in/djherbis/times.v1 v1.2.0 gopkg.in/djherbis/times.v1 v1.2.0
) )
replace github.com/gdamore/tcell/v2 => github.com/gokcehan/tcell/v2 v2.2.1-0.20210329222449-4dd2d52e83ef
+2 -3
View File
@@ -1,7 +1,7 @@
github.com/gdamore/encoding v1.0.0 h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdko= github.com/gdamore/encoding v1.0.0 h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdko=
github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg= github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg=
github.com/gdamore/tcell/v2 v2.2.0 h1:vSyEgKwraXPSOkvCk7IwOSyX+Pv3V2cV9CikJMXg4U4= github.com/gokcehan/tcell/v2 v2.2.1-0.20210329222449-4dd2d52e83ef h1:I2KyR549rTlwGBHe2uwZHGNNeAIHUpwIs6V522yK+SE=
github.com/gdamore/tcell/v2 v2.2.0/go.mod h1:cTTuF84Dlj/RqmaCIV5p4w8uG1zWdk0SF6oBpwHp4fU= github.com/gokcehan/tcell/v2 v2.2.1-0.20210329222449-4dd2d52e83ef/go.mod h1:cTTuF84Dlj/RqmaCIV5p4w8uG1zWdk0SF6oBpwHp4fU=
github.com/lucasb-eyer/go-colorful v1.0.3 h1:QIbQXiugsb+q10B+MI+7DI1oQLdmnep86tWFlaaUAac= github.com/lucasb-eyer/go-colorful v1.0.3 h1:QIbQXiugsb+q10B+MI+7DI1oQLdmnep86tWFlaaUAac=
github.com/lucasb-eyer/go-colorful v1.0.3/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0= github.com/lucasb-eyer/go-colorful v1.0.3/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
github.com/mattn/go-runewidth v0.0.10 h1:CoZ3S2P7pvtP45xOtBw+/mDL2z0RKI576gSkzRRpdGg= github.com/mattn/go-runewidth v0.0.10 h1:CoZ3S2P7pvtP45xOtBw+/mDL2z0RKI576gSkzRRpdGg=
@@ -10,7 +10,6 @@ github.com/rivo/uniseg v0.1.0 h1:+2KBaVoUmb9XzDsrx/Ct0W/EYOSFf/nWTauy++DprtY=
github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68 h1:nxC68pudNYkKU6jWhgrqdreuFiOQWj1Fs7T3VrH4Pjw= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68 h1:nxC68pudNYkKU6jWhgrqdreuFiOQWj1Fs7T3VrH4Pjw=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf h1:MZ2shdL+ZM/XzY3ZGOnh4Nlpnxz5GSOhOmtHo3iPU6M=
golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d h1:SZxvLBoTP5yHO3Frd4z4vrF+DBX9vMVanchswa69toE= golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d h1:SZxvLBoTP5yHO3Frd4z4vrF+DBX9vMVanchswa69toE=
golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
+31 -1
View File
@@ -5,6 +5,7 @@ lf \- terminal file manager
.SH SYNOPSIS .SH SYNOPSIS
.SY lf .SY lf
.OP \-command command .OP \-command command
.OP \-config path
.OP \-cpuprofile path .OP \-cpuprofile path
.OP \-doc .OP \-doc
.OP \-last-dir-path path .OP \-last-dir-path path
@@ -13,6 +14,7 @@ lf \- terminal file manager
.OP \-selection-path path .OP \-selection-path path
.OP \-server .OP \-server
.OP \-version .OP \-version
.OP \-help
.RI [ directory ] .RI [ directory ]
.YS .YS
.SH DESCRIPTION .SH DESCRIPTION
@@ -141,6 +143,7 @@ The following options can be used to customize the behavior of lf:
reverse bool (default off) reverse bool (default off)
scrolloff int (default 0) scrolloff int (default 0)
shell string (default 'sh' for unix and 'cmd' for windows) shell string (default 'sh' for unix and 'cmd' for windows)
shellflag string (default '-c' for unix and '/c' for windows)
shellopts []string (default '') shellopts []string (default '')
smartcase bool (default on) smartcase bool (default on)
smartdia bool (default off) smartdia bool (default off)
@@ -148,6 +151,7 @@ The following options can be used to customize the behavior of lf:
tabstop int (default 8) tabstop int (default 8)
timefmt string (default 'Mon Jan _2 15:04:05 2006') timefmt string (default 'Mon Jan _2 15:04:05 2006')
truncatechar string (default '~') truncatechar string (default '~')
waitmsg string (default 'Press any key to continue')
wrapscan bool (default on) wrapscan bool (default on)
wrapscroll bool (default off) wrapscroll bool (default off)
.EE .EE
@@ -159,6 +163,8 @@ The following environment variables are exported for shell commands:
fs fs
fx fx
id id
PWD
OLDPWD
LF_LEVEL LF_LEVEL
OPENER OPENER
EDITOR EDITOR
@@ -763,7 +769,13 @@ Minimum number of offset lines shown at all times in the top and the bottom of t
shell string (default 'sh' for unix and 'cmd' for windows) shell string (default 'sh' for unix and 'cmd' for windows)
.EE .EE
.PP .PP
Shell executable to use for shell commands. Shell commands are executed as 'shell shellopts -c command -- arguments'. On windows, '/c' is used instead of '-c' which should work in 'cmd' and 'powershell'. Shell executable to use for shell commands. Shell commands are executed as 'shell shellopts shellflag command -- arguments'.
.PP
.EX
shellflag string (default '-c' for unix and '/c' for windows)
.EE
.PP
Command line flag used to pass shell commands.
.PP .PP
.EX .EX
shellopts []string (default '') shellopts []string (default '')
@@ -807,6 +819,12 @@ Format string of the file modification time shown in the bottom line.
.PP .PP
Truncate character shown at the end when the file name does not fit to the pane. Truncate character shown at the end when the file name does not fit to the pane.
.PP .PP
.EX
waitmsg string (default 'Press any key to continue')
.EE
.PP
String shown after commands of shell-wait type.
.PP
.EX .EX
wrapscan bool (default on) wrapscan bool (default on)
.EE .EE
@@ -845,6 +863,18 @@ Selected file(s) (i.e. 'fs') if there are any selected files, otherwise current
.PP .PP
Id of the running client. Id of the running client.
.PP .PP
.EX
PWD
.EE
.PP
Present working directory.
.PP
.EX
OLDPWD
.EE
.PP
Initial working directory.
.PP
.EX .EX
LF_LEVEL LF_LEVEL
.EE .EE
+17 -5
View File
@@ -31,6 +31,7 @@ var (
gLogPath string gLogPath string
gServerLogPath string gServerLogPath string
gSelect string gSelect string
gConfigPath string
gCommands arrayFlag gCommands arrayFlag
gVersion string gVersion string
) )
@@ -64,6 +65,12 @@ func exportEnvVars() {
os.Setenv("PAGER", envPager) os.Setenv("PAGER", envPager)
os.Setenv("SHELL", envShell) os.Setenv("SHELL", envShell)
dir, err := os.Getwd()
if err != nil {
fmt.Fprintf(os.Stderr, "%s\n", err)
}
os.Setenv("OLDPWD", dir)
level, err := strconv.Atoi(envLevel) level, err := strconv.Atoi(envLevel)
if err != nil { if err != nil {
log.Printf("reading lf level: %s", err) log.Printf("reading lf level: %s", err)
@@ -187,16 +194,16 @@ func main() {
false, false,
"show version") "show version")
remoteCmd := flag.String(
"remote",
"",
"send remote command to server")
serverMode := flag.Bool( serverMode := flag.Bool(
"server", "server",
false, false,
"start server (automatic)") "start server (automatic)")
remoteCmd := flag.String(
"remote",
"",
"send remote command to server")
cpuprofile := flag.String( cpuprofile := flag.String(
"cpuprofile", "cpuprofile",
"", "",
@@ -217,6 +224,11 @@ func main() {
"", "",
"path to the file to write selected files on open (to use as open file dialog)") "path to the file to write selected files on open (to use as open file dialog)")
flag.StringVar(&gConfigPath,
"config",
"",
"path to the config file (instead of the usual paths)")
flag.Var(&gCommands, flag.Var(&gCommands,
"command", "command",
"command to execute on client initialization") "command to execute on client initialization")
+4
View File
@@ -42,6 +42,7 @@ var gOpts struct {
relativenumber bool relativenumber bool
smartcase bool smartcase bool
smartdia bool smartdia bool
waitmsg string
wrapscan bool wrapscan bool
wrapscroll bool wrapscroll bool
findlen int findlen int
@@ -55,6 +56,7 @@ var gOpts struct {
cleaner string cleaner string
promptfmt string promptfmt string
shell string shell string
shellflag string
timefmt string timefmt string
truncatechar string truncatechar string
ratios []int ratios []int
@@ -82,6 +84,7 @@ func init() {
gOpts.relativenumber = false gOpts.relativenumber = false
gOpts.smartcase = true gOpts.smartcase = true
gOpts.smartdia = false gOpts.smartdia = false
gOpts.waitmsg = "Press any key to continue"
gOpts.wrapscan = true gOpts.wrapscan = true
gOpts.wrapscroll = false gOpts.wrapscroll = false
gOpts.findlen = 1 gOpts.findlen = 1
@@ -95,6 +98,7 @@ func init() {
gOpts.cleaner = "" gOpts.cleaner = ""
gOpts.promptfmt = "\033[32;1m%u@%h\033[0m:\033[34;1m%d\033[0m\033[1m%f\033[0m" gOpts.promptfmt = "\033[32;1m%u@%h\033[0m:\033[34;1m%d\033[0m\033[1m%f\033[0m"
gOpts.shell = gDefaultShell gOpts.shell = gDefaultShell
gOpts.shellflag = gDefaultShellFlag
gOpts.timefmt = time.ANSIC gOpts.timefmt = time.ANSIC
gOpts.truncatechar = "~" gOpts.truncatechar = "~"
gOpts.ratios = []int{1, 2, 3} gOpts.ratios = []int{1, 2, 3}
+4 -2
View File
@@ -23,6 +23,7 @@ var (
var ( var (
gDefaultShell = "sh" gDefaultShell = "sh"
gDefaultShellFlag = "-c"
gDefaultSocketProt = "unix" gDefaultSocketProt = "unix"
gDefaultSocketPath string gDefaultSocketPath string
) )
@@ -99,7 +100,7 @@ func shellCommand(s string, args []string) *exec.Cmd {
s = fmt.Sprintf("IFS='%s'; %s", gOpts.ifs, s) s = fmt.Sprintf("IFS='%s'; %s", gOpts.ifs, s)
} }
args = append([]string{"-c", s, "--"}, args...) args = append([]string{gOpts.shellflag, s, "--"}, args...)
args = append(gOpts.shellopts, args...) args = append(gOpts.shellopts, args...)
@@ -177,12 +178,13 @@ func errCrossDevice(err error) bool {
return err.(*os.LinkError).Err.(syscall.Errno) == syscall.EXDEV return err.(*os.LinkError).Err.(syscall.Errno) == syscall.EXDEV
} }
func exportFiles(f string, fs []string) { func exportFiles(f string, fs []string, pwd string) {
envFile := f envFile := f
envFiles := strings.Join(fs, gOpts.filesep) envFiles := strings.Join(fs, gOpts.filesep)
os.Setenv("f", envFile) os.Setenv("f", envFile)
os.Setenv("fs", envFiles) os.Setenv("fs", envFiles)
os.Setenv("PWD", pwd)
if len(fs) == 0 { if len(fs) == 0 {
os.Setenv("fx", envFile) os.Setenv("fx", envFile)
+4 -2
View File
@@ -22,6 +22,7 @@ var envPathExt = os.Getenv("PATHEXT")
var ( var (
gDefaultShell = "cmd" gDefaultShell = "cmd"
gDefaultShellFlag = "/c"
gDefaultSocketProt = "tcp" gDefaultSocketProt = "tcp"
gDefaultSocketPath = "127.0.0.1:12345" gDefaultSocketPath = "127.0.0.1:12345"
) )
@@ -77,7 +78,7 @@ func detachedCommand(name string, arg ...string) *exec.Cmd {
} }
func shellCommand(s string, args []string) *exec.Cmd { func shellCommand(s string, args []string) *exec.Cmd {
args = append([]string{"/c", s}, args...) args = append([]string{gOpts.shellflag, s}, args...)
args = append(gOpts.shellopts, args...) args = append(gOpts.shellopts, args...)
@@ -133,7 +134,7 @@ func errCrossDevice(err error) bool {
return err.(*os.LinkError).Err.(syscall.Errno) == 17 return err.(*os.LinkError).Err.(syscall.Errno) == 17
} }
func exportFiles(f string, fs []string) { func exportFiles(f string, fs []string, pwd string) {
envFile := fmt.Sprintf(`"%s"`, f) envFile := fmt.Sprintf(`"%s"`, f)
var quotedFiles []string var quotedFiles []string
@@ -144,6 +145,7 @@ func exportFiles(f string, fs []string) {
os.Setenv("f", envFile) os.Setenv("f", envFile)
os.Setenv("fs", envFiles) os.Setenv("fs", envFiles)
os.Setenv("PWD", pwd)
if len(fs) == 0 { if len(fs) == 0 {
os.Setenv("fx", envFile) os.Setenv("fx", envFile)
+6 -5
View File
@@ -1144,22 +1144,23 @@ func (ui *ui) readExpr() {
}() }()
} }
func (ui *ui) suspend() { func (ui *ui) suspend() error {
ui.screen.Suspend() return ui.screen.Suspend()
} }
func (ui *ui) resume() { func (ui *ui) resume() error {
ui.screen.Resume() return ui.screen.Resume()
} }
func anyKey() { func anyKey() {
fmt.Print(gOpts.waitmsg)
defer fmt.Print("\n")
oldState, err := term.MakeRaw(int(os.Stdin.Fd())) oldState, err := term.MakeRaw(int(os.Stdin.Fd()))
if err != nil { if err != nil {
panic(err) panic(err)
} }
defer term.Restore(int(os.Stdin.Fd()), oldState) defer term.Restore(int(os.Stdin.Fd()), oldState)
fmt.Print("Press any key to continue")
b := make([]byte, 1) b := make([]byte, 1)
os.Stdin.Read(b) os.Stdin.Read(b)
} }