lf icon indicating copy to clipboard operation
lf copied to clipboard

cmd: allow "$@" to pass all arguments

Open ajeetdsouza opened this issue 3 years ago • 3 comments

Hi, I'm trying to setup lf with zoxide. What I currently have looks something like:

cmd z %{{
    res="$(zoxide query "$1")"
    lf -remote "send $id cd \"$res\""
}}

I'm using $1 which currently only supports a single argument, but ideally, zoxide should be usable with any number of arguments. It would be great if lf could support a syntax like $@ to pass in all the arguments.

ajeetdsouza avatar Apr 26 '22 07:04 ajeetdsouza

I tried

cmd z %{{
    echo "$@"
}}

and it prints out first second third when I execute :z first second third. lf simply runs the command body as a shell script and passes all the parameters you provide to it, so I don't think there would be an problem with using $@.

en0mem avatar May 18 '22 00:05 en0mem

Which shell is it running with? Somehow, the syntax: res="$(zoxide query "$@")" doesn't seem to be working correctly, even though it runs just fine in Bash.

ajeetdsouza avatar May 18 '22 07:05 ajeetdsouza

That is really weird. I tried the command substitution syntax

cmd z %{{
    res="$(echo "$@")"
    echo "$res"
}}

with sh, bash and zsh, and it all works as expected. Which shell are you using? It uses the shell you specify in the shell option.

en0mem avatar May 18 '22 13:05 en0mem