-
Notifications
You must be signed in to change notification settings - Fork 331
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
-print-selection and -selection-path not work #1814
Comments
@superiums I think selection works only for files and that it works when you select and open (instead of select and quit) |
I had a look through past issues, it looks like you're not the first person to be confused about how
IMO the current workflow (
If I could change the way this feature works I would make it so that:
The only concern is that this feature has existed for a very long time and that changing the way it works would constitute a breaking change. I am also not particularly interested in maintaining an additional option to allow users to choose between the old and new behaviors (if implemented). As a side note I managed to implement this kind of functionality based entirely on configuration, without having to use map Q :{{
$echo "$fs" > "/proc/$id/fd/1"
quit
}} Though at this point I think it's probably too late to remove these options, and that it's better to just keep them as builtins. |
I think the following patch should work, leaving it here for reference. Click to expanddiff --git a/app.go b/app.go
index 45e0dbd..2dc7575 100644
--- a/app.go
+++ b/app.go
@@ -31,11 +31,10 @@ type app struct {
cmdHistoryBeg int
cmdHistoryInd int
menuCompActive bool
menuComps []string
menuCompInd int
- selectionOut []string
watch *watch
}
func newApp(ui *ui, nav *nav) *app {
quitChan := make(chan struct{}, 1)
diff --git a/client.go b/client.go
index 00fa1f5..d358aa2 100644
--- a/client.go
+++ b/client.go
@@ -68,20 +68,20 @@ func run() {
if gLastDirPath != "" {
writeLastDir(gLastDirPath, app.nav.currDir().path)
}
- if gSelectionPath != "" && len(app.selectionOut) > 0 {
- writeSelection(gSelectionPath, app.selectionOut)
+ if gSelectionPath != "" {
+ writeSelection(gSelectionPath, app.nav.currSelections())
}
if gPrintLastDir {
fmt.Println(app.nav.currDir().path)
}
- if gPrintSelection && len(app.selectionOut) > 0 {
- for _, file := range app.selectionOut {
+ if gPrintSelection {
+ for _, file := range app.nav.currSelections() {
fmt.Println(file)
}
}
}
diff --git a/eval.go b/eval.go
index 445d081..16f7d63 100644
--- a/eval.go
+++ b/eval.go
@@ -1074,16 +1074,10 @@ func (e *callExpr) eval(app *app, args []string) {
restartIncCmd(app)
onChdir(app)
return
}
- if gSelectionPath != "" || gPrintSelection {
- app.selectionOut, _ = app.nav.currFileOrSelections()
- app.quitChan <- struct{}{}
- return
- }
-
app.ui.loadFileInfo(app.nav)
if cmd, ok := gOpts.cmds["open"]; ok {
cmd.eval(app, e.args)
}
diff --git a/main.go b/main.go
index 985d842..efaf8c2 100644
--- a/main.go
+++ b/main.go
@@ -248,11 +248,11 @@ func main() {
"print the last dir to stdout on exit (to use for cd)")
printSelection := flag.Bool(
"print-selection",
false,
- "print the selected files to stdout on open (to use as open file dialog)")
+ "print the selected files to stdout on exit")
remoteCmd := flag.String(
"remote",
"",
"send remote command to server")
@@ -273,11 +273,11 @@ func main() {
"path to the file to write the last dir on exit (to use for cd)")
flag.StringVar(&gSelectionPath,
"selection-path",
"",
- "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 exit")
flag.StringVar(&gConfigPath,
"config",
"",
"path to the config file (instead of the usual paths)") |
got it, thanks very much ! |
i'm wondering to use lf as a filepicker in qute.
but found in terminal:
lf -print-selection
print nothiing while selected and quit.also
lf -selection-path /tmp/s
writes no file.The text was updated successfully, but these errors were encountered: