wfxr / forgit

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

when using "ga" to git add: zsh:11: parse error near `else', no diff in right box #152

Closed Araly closed 3 years ago

Araly commented 3 years ago

Check list

Environment info

Problem / Steps to reproduce

In any git repo that I've tried, when I run ga, I don't see a diff in the right box, just

zsh:11: parse error near `else'

I installed with the omf method

cjappl commented 3 years ago

will you try typing fish before you try ga again, just to be sure you're running it in fish? It's strange to see a zsh error while running the fish version of this plugin! I suspect a configuration error.

Is this just with ga, or with other commands too?

Araly commented 3 years ago

I am running fish for sure, but I see that the SHELL variable is set to /bin/zsh, and if I try to set it with fish as a universal variable (that persists over reboots), it tells me it's overshadowed by a global variable (that is set for all sessions but doesn't persist) of the same name. So somewhere in my config something is setting that variable. If I just set the variable for that session only I can override the global value and ga works without any issues. I'll hunt that configuration down on my side and I'll close this issue

cjappl commented 3 years ago

@wfxr Have you ever seen anything like that?

Good luck @Araly, be sure to post a comment if you figure it out, may help someone in the future :)

wfxr commented 3 years ago

@wfxr Have you ever seen anything like that?

I haven't seen this error. The error message looks like the fish plugin was sourced in the zsh shell for some reasons.

cjappl commented 3 years ago

Very strange, for sure!!

Araly commented 3 years ago

I couldn't find why the SHELL variable was set as a global variable anywhere. I have a setup at work where I can't chsh (it gets reset on reboots) so I tell alacritty and guake to run fish instead of the default shell. Maybe zsh still gets called and sets itself as SHELL, or maybe that's just set at login because my default shell is zsh.

My solution was to have set -gx SHELL /usr/bin/fish in ~/.config/fish/config.fish to overwrite it, and it works well. Maybe forgit or something called by forgit reads SHELL at some point to know what it's running on, even if it has been installed via omf ? I imagine my case of having SHELL not match with the shell that's running is not very common

cjappl commented 3 years ago

Very strange! Well, glad you got to the bottom of it. Don't hesitate to reach out if you find any more issues

cjappl commented 3 years ago

@Araly, interestingly enough, this just started happening with me too when I switched to a new job!

I will dig in at some point and see if we can fix this on the forgit side. I can't figure out why I can't update my shell with chsh. I figured that would fix it. I'm going to use your hack for now.

Super strange

cjappl commented 3 years ago

@Araly I think I have found the fix! It seems like you have to do a little legwork for fish to be identified as a shell

First, make sure fish is listed as a shell in /etc/shells. Here is a quick one liner that can help you do that.

which fish | sudo tee -a /etc/shells

Then you need to change the shell for your user

chsh -s (which fish)

You then need to close out of your terminal session, but then when you open a new one everything was good for me!

Will you confirm this works and get back to me?

Araly commented 3 years ago

I tried but it didn't work for me. I don't think I can change my shell at my work, or rather the shell is always overwritten when I reboot. I don't have that issue on my personal computer though, and fish is recognized as a shell all on its own. I'll just keep this little hack for now