andy-5 / wslgit

Use Git installed in Bash on Windows/Windows Subsystem for Linux (WSL) from Windows and Visual Studio Code (VSCode)
MIT License
1.18k stars 59 forks source link

Fish (and other shells) support #132

Open Zopolis4 opened 1 year ago

Zopolis4 commented 1 year ago

I use fish as my exclusive shell in wsl, and have a variety of variables and functions set in config.fish that I frequently use in my git usage.

I would very much like not to have to port these over to bash, as they are in some cases impossible to port, so I was wondering if an option to use the default shell (set by chsh) or to set a specific shell could be added?

andy-5 commented 1 year ago

Let me check if I understand your request correctly. You would like to change the shell executable through which the git command is executed?

Currently wslgit executes something like

wsl.exe /bin/bash -c "git --version"

and you would like to be able to change that to, e.g.

wsl.exe /usr/bin/fish -c "git --version"

(or some other shell). Did I understand that correctly?

Right now this is not possible, but I think we could add an environment variable to configure the shell executable. But this would be without any guarantees that a particular shell is supported. A quick check suggests that fish supports the -i and -c flags, like bash, so I think it would work.

Zopolis4 commented 1 year ago

... Did I understand that correctly?

Yeah, that's essentially my request.

rosahay-silabs commented 10 months ago

I observed with WSL 2 atleast whatever I have the SHELL=/usr/bin/zsh set to will be used by wslgit, I am using this with GitExtensions and zsh.

All was working fine until some update came along and broke "Current branch only" functionality with the setup. This works even now if you use bash instead.

Error details:

Exit code: 1 Command: wsl Arguments: -d Ubuntu git -c log.showSignature=false log -z --pretty=format:"%H%T%P%n%at%n%ct%n%aN%n%aE%n%cN%n%cE%n%B" --max-count=500 --glob=refs/stas[h] ea3970a7f11cd227ac55917edaa835a2a9bc4fc8 -- Working directory: \wsl$\Ubuntu\home\user\repo\

GitExtUtils.ExternalOperationException: zsh:1: no matches found: --glob=refs/stas[h]
 ---> System.Exception: zsh:1: no matches found: --glob=refs/stas[h]
   --- End of inner exception stack trace ---
   at void GitUI.RevisionGridControl.PerformRefreshRevisions(Func<RefsFilter, IReadOnlyList<IGitRef>> getRefs, bool forceRefresh)+() => { } in C:/projects/gitextensions/GitUI/UserControls/RevisionGrid/RevisionGridControl.cs:line 1309
   at async Task GitUI.GitUIExtensions.InvokeAsync(Control control, Action action, CancellationToken token) in C:/projects/gitextensions/GitUI/GitUIExtensions.cs:line 239
   at async void GitUI.TaskManager.FileAndForget(Task task, Func<Exception, bool> fileOnlyIf)+(?) => { } in C:/projects/gitextensions/GitExtUtils/GitUI/TaskManager.cs:line 29

The fix was to do the following:

cp /etc/zsh/zshenv ~/.zshenv
echo "alias git=\"noglob git\"" >> ~/.zshenv

Now everything works as usual. Hope this helps someone facing the same issue.