forgit icon indicating copy to clipboard operation
forgit copied to clipboard

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

Open fadzlan opened this issue 2 years ago • 7 comments

Check list

  • [x] I have read through the README
  • [x] I have the latest version of forgit
  • [x] I have searched through the existing issues

Environment info

  • OS
    • [x] Linux
    • [ ] Mac OS X
    • [ ] Windows
    • [ ] Others:
  • Shell
    • [ ] bash
    • [x] zsh
    • [ ] fish

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.

fadzlan avatar May 31 '22 07:05 fadzlan

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 avatar Jun 05 '22 18:06 wren

@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.

wren avatar Jun 05 '22 18:06 wren

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

wfxr avatar Jun 06 '22 07:06 wfxr

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>

fadzlan avatar Jun 09 '22 16:06 fadzlan

@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.

wren avatar Jun 20 '22 19:06 wren

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

wfxr avatar Jun 21 '22 01:06 wfxr

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.

stale[bot] avatar Sep 08 '22 23:09 stale[bot]