wfxr / forgit

:zzz: A utility tool powered by fzf for using git interactively.
MIT License
4.33k stars 136 forks source link

git sub-command does not respect env variables in .zshrc #210

Closed fadzlan closed 1 year ago

fadzlan commented 2 years ago

Check list

Environment info

Currently on commit 6385f85

Problem / Steps to reproduce

Setting values in in .zshrc file works alias (eg. glo), but not as git alias (eg. git forgit log).

For example, glo works with the setting the following in .zshrc file

FORGIT_FZF_DEFAULT_OPTS="
--reverse
"

but git forgit log does not respect the values and thus does not have the reverse flag applied.

wren commented 2 years ago
FORGIT_FZF_DEFAULT_OPTS="
--reverse
"

Hi @fadzlan, thanks for filing this report.

Due to the way the git forgit * aliases work, you must use the export keyword when setting environment variables for this to work properly. So, if you update your .zshrc like so, you should be good to go:

export FORGIT_FZF_DEFAULT_OPTS="
--reverse
"
wren commented 2 years ago

@wfxr This should probably be updated in README.md. I was thinking of just adding export to all of the examples of setting config in the file (this will make the config always work for both shell aliases and the git aliases).

I can send a PR later today if you're ok with this approach.

wfxr commented 2 years ago

@wren Do you mean let the user set all the environment variables in .zshrc?

fadzlan commented 2 years ago

It works! Thanks.

In the current documentation, there is already instruction to set up the environment variable, just not where should you set it.

I think it can remain that way, with just additional instruction to add export if the current setting is not working for git forgit <command>

wren commented 2 years ago

@wfxr Sorry for the slow reply; I missed this in my inbox.

I was asking whether it's ok to put export in front of all of the examples in the readme. Users can continue to set variables wherever they are setting them now (like .zshrc), but having export there will make the vars work with both the traditional way to run forgit, and the git sub-command. So, since it works with both methods, it might be clearer for users if export is there on all of the examples. Just an idea, though. I'm happy to approach it some other way if you prefer.

wfxr commented 2 years ago

@wren Got it. I think it's OK!

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.