Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non interactive and advanced .bashrc startup file loading #23

Merged
merged 4 commits into from
Mar 7, 2018

Conversation

diablodale
Copy link
Contributor

This adds a feature to enable more flexible management of which startup files run with WSLgit as discussed in issue #16

Windows 10 builds less than 17063

No change.
Launches git in interactive, non-login bash shell.

Windows 10 builds 17063 and later

Optional change.
Launches git in interactive or non-interactive, non-login bash shell.

  • When Windows environment variable BASH_ENV is set and variable WSLENV contains "BASH_ENV", then WSLgit is launched into WSL bash with a non-interactive non-login shell. e.g.
    BASH_ENV=~/.bashrc
    WSLENV=VAR1:BASH_ENV:VAR3:VAR4
  • WSL's Bash will read the BASH_ENV variable and load the given file. In that file, you can detect it being interactive or non-interactive and manage things you want to do in each case. For example, you may want to always set variables for GPG, SSH, etc. However, for non-interactive shells, you may want to skip slow actions.

Launching WSLgit as non-interactive and skipping slow actions in .bashrc can significantly speed the responsiveness of WSLgit. For example, it changed my response time from several seconds down to microseconds.

This PR uses wsl.exe to launch into WSL instead of the deprecated bash.exe.

Example .bashrc

# this code runs for all cases
GPGKEY="abcd1234"

# If not running interactively, don't do anything
case $- in
    *i*) ;;
      *) return;;
esac

# this code runs only in interactive shells
./slow_action.sh

- Win10 builds 17063+ support sharing env vars w/ WSL
- when WSLENV and BASH_ENV are shared, will launch
  WSL as non-interactive
- Win builds prior (e.g. FCU) will not get this feature
@krazyito65 krazyito65 mentioned this pull request Feb 14, 2018
@andy-5 andy-5 merged commit 93c95eb into andy-5:master Mar 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants