gokcehan / lf

Terminal file manager
MIT License
7.75k stars 332 forks source link

lf -command="select XXX" doesn't work #939

Open jupblb opened 2 years ago

jupblb commented 2 years ago

It seems that lf -command="select XXX" doesn't work. Steps to reproduce:

touch test
lf -command="select test"

Opening lf alone and later using :select ./test does work.

DusanLesan commented 2 years ago

I think you need to use lf remote like:

lf -remote "send select \"test\""
mtoohey31 commented 2 years ago

That works, but I believe lf -command="select test" should also work. If you update app.loop as I have on this branch so that commands get evaluated after the nav field is initialized, then it works. @gokcehan do you see any problems with re-ordering things like that? Would you accept a PR with the change from that branch?

gokcehan commented 1 year ago

@jupblb @DusanLesan I think you can simply call lf test to select a file.

@mtoohey31 I don't use these features myself but I remember there were a few reorderings for the initialization in the past so another reorder will likely break the usecase of someone else. Maybe you can use git blame to see the related discussions for the current order.

DusanLesan commented 1 year ago

@jupblb @DusanLesan I think you can simply call lf test to select a file.

You are right. It is possible. I overlooked that this is about opening of new lf instance and only thought about selecting in already opened lf window

mtoohey31 commented 1 year ago

I totally overlooked that too! That solves my problem, so I'm going to leave things alone for now, cause it's hard to tell whether re-ordering things will cause problems.

In case anyone comes across this later and wants to investigate further, I'll leave the changes I was considering in a patch below, since I'm deleting my fork to avoid clutter.

```patch diff --git a/app.go b/app.go index 24e21f9..fc2710f 100644 --- a/app.go +++ b/app.go @@ -265,6 +265,15 @@ func (app *app) loop() { } } + wd, err := os.Getwd() + if err != nil { + log.Printf("getting current directory: %s", err) + } + + app.nav.getDirs(wd) + app.nav.addJumpList() + app.nav.init = true + for _, cmd := range gCommands { p := newParser(strings.NewReader(cmd)) @@ -277,15 +286,6 @@ func (app *app) loop() { } } - wd, err := os.Getwd() - if err != nil { - log.Printf("getting current directory: %s", err) - } - - app.nav.getDirs(wd) - app.nav.addJumpList() - app.nav.init = true - if gSelect != "" { go func() { lstat, err := os.Lstat(gSelect) ```