Skip to content

Simplified lf -remote interface #2174

@c4rlo

Description

@c4rlo

#2145 got me thinking that it would be quite nice if there was a simpler way to send commands to the current (in the sense of $id) lf instance.

A typical example from https://github.com/gokcehan/lf/wiki/Integrations illustrates this:

cmd zi ${{
    result="$(zoxide query -i | sed 's/\\/\\\\/g;s/"/\\"/g')"
    lf -remote "send $id cd \"$result\""
}}

The need for manually quoting the result is quite cumbersome.

I'd like to be able to instead write this as:

cmd zi ${{
    result=$(zoxide query -i)
    lf -local-send cd "$result"
}}

So, my proposal is to introduce new command-line options as follows:

  1. lf -local-send COMMAND ARGS... shall be equivalent to lf -remote "send $id COMMAND ARGS...", but taking care of the quoting.
  2. lf -local-query TYPE shall be similarly equivalent to lf -remote "query $id TYPE".

Note that these commands would require the id environment variable to be set.

Further options and variations that may be considered:

  • It may then be reasonable to rename the id environment variable to something more unique, e.g. lf_id (with a period of backward compatibility). Once there is less need to type it out, it's fine if it's a few characters longer.
  • Does query really need to be its own special thing, or could that just be a built-in command?
  • I'm combining two ideas here – not needing to spell out $id and taking care of quoting – but they are kind of independent. Could do only one or the other.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions