kelleyma49 / PSFzf

A PowerShell wrapper around the fuzzy finder fzf
MIT License
787 stars 34 forks source link

Add option to use something else instead of `Set-Location` with `Invoke-FzfPsReadlineHandlerSetLocation` #88

Closed Aankhen closed 2 years ago

Aankhen commented 2 years ago

This package is awesome! The Alt+C binding is what I’m most interested in. I try to avoid cd/Set-Location, though; I’d like to be able to use Push-Location or even zoxide instead. Would it be possible to add a setting to use a different command? (I tried to do this myself and thought I got it right on the script side, but I couldn’t figure out how to get PowerShell to pick up my changes even after rebuilding and reimporting.)

mattcargile commented 2 years ago

I think you want these environment variables?

$env:FZF_ALT_C_COMMAND $env:FZF_ALT_C_OPTS

Nevermind, I see what you mean. You would want to change this line. You should be able to go into your local copy of the module and update this line.

https://github.com/kelleyma49/PSFzf/blob/0843f35b0e77101f0718e89bb075e20e4e211d23/PSFzf.Base.ps1#L746

P.S. There is a new alpha release 2.3.1-alpha where you need to use the AllowPrerelease flag.

mattcargile commented 2 years ago

Also, did you Build the .sln as well and copy the .dll into the root directory prior to Import-Module? You could try adding a -Verbose flag to see what the error was.

The solution also has a dependency on this add-on.

kelleyma49 commented 2 years ago

I added a new option to Set-PsFzfOption called AltCCommand, which accepts a scriptblock which is used as a replacement for the command in the Alt+C function. Refer to the default scriptblock for an example:

https://github.com/kelleyma49/PSFzf/blob/626aa365a2c2702516903b4cee050b6cceb03ff0/PSFzf.Base.ps1#L34

Aankhen commented 2 years ago

That works perfectly with zoxide. Thank you very much!