The issue is that in a xonsh session, after using the file searcher (which modifies $FZF_DEFAULT_OPTS to include the default args), the args are carried over to the command history search. It then tries to fetch a preview for commands, which doesn't work, and I imagine could lead to unintended commands being run.
This PR modifies the code to use dict(os.environ) instead of os.environ directly, so that we can modify a copy without affecting env vars. Although os.environ is its own class and not a dict, subprocess.run takes a mapping as per the documentation:
If env is not None, it must be a mapping that defines the environment variables for the new process
And I've tested this to verify it now works as expected.
Hi! Thanks for maintaining this, it's quite useful.
I found that the xontrib modifies environment variables in a way that is probably not desired.
I set my $FZF_DEFAULT_OPTS to the following:
This uses
bat
to display a nice file preview:The issue is that in a xonsh session, after using the file searcher (which modifies
$FZF_DEFAULT_OPTS
to include the default args), the args are carried over to the command history search. It then tries to fetch a preview for commands, which doesn't work, and I imagine could lead to unintended commands being run.This PR modifies the code to use
dict(os.environ)
instead ofos.environ
directly, so that we can modify a copy without affecting env vars. Althoughos.environ
is its own class and not a dict,subprocess.run
takes a mapping as per the documentation:And I've tested this to verify it now works as expected.