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

Unable to execute some commands with custom .bashrc (`exec fish` in the last line) #115

Closed eitsupi closed 3 years ago

eitsupi commented 3 years ago

I modified my .bashrc to use fish and noticed that wslgit wasn't working.

The following commands will work.

> wsl -e bash -c "git version"
git version 2.31.0
> git version
git version 2.31.0

The following command will not run git, but will start fish.

> git pull
Welcome to fish, the friendly interactive shell
Type `help` for instructions on how to use fish
carlolars commented 3 years ago

Wslgit tries to be "smart", so some commands (clone, fetch, pull and push) start bash in interactive mode and the rest start bash in non-interactive mode, see Advanced Usage in the readme. If you run wsl -e bash -ic "git version" you should get the same as with git pull.

If you don't need to run .bashrc at all for git commands that access remote sources then just set WSLGIT_USE_INTERACTIVE_SHELL=false in your Windows environment variables. Or you can make .bashrc not start fish if bash was started by wslgit by checking if WSLGIT is set, for example somthing like this:

[ -z "$WSLGIT" ] && exec fish
eitsupi commented 3 years ago

Or you can make .bashrc not start fish if bash was started by wslgit by checking if WSLGIT is set, for example somthing like this:

[ -z "$WSLGIT" ] && exec fish

@carlolars Thank you for your quick response ! That works for me.

I would like to continue using this wonderful product.