lf
lf copied to clipboard
Some way to integrate zoxide with lf in Windows Powershell
The code that works in Bash is:
cmd z %{{
result="$(zoxide query --exclude "${PWD}" -- "$0")"
lf -remote "send ${id} cd '${result}'"
}}
cmd z :push z<space>
How would I do it in Windows Powershell? I have tried this code without success.
cmd z $lf -remote "send $env:id cd $(zoxide query --exclude $env:PWD -- $args[0])"
P.S. Analyzing the behavior of this, I think the problem is that the arguments that are passed to the commands on the LF command line are not actually passed to the Powershell code.
Example.
cmd z $lf -remote "send $env:id cd $(zoxide query --exclude $env:PWD -- $args[0])"
map z push :z<space>
You would do :z <argument>
and this argument is supposed to take the place of $args[0]
in the code. However, this does not occur, there is no connection there.
As a result you get a Zoxide error message: no command found and a Powershell error message stating that the string you passed as an argument in :z <argument>
is not recognized as the name of a cmdlet, function script file or executable program.
Passing additional arguments to PowerShell is possible, but only with the experimental -CommandWithArgs
option, which will make the arguments available in the $args
variable.
This is already being discussed in #1506 so I will close this off as a duplicate.