-
-
Save aiya000/7ddcef549f51ca5fe6c2aed91810375f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Currently on NTFS, WSL2's git is too heavy. | |
sub_cmd=$1 | |
function should_use_windows_git () { | |
[[ $(pwd) =~ '^/mnt/' ]] \ | |
|| [[ $(pwd) =~ '/home/aiya000/Windows' ]] \ | |
|| [[ $(pwd) =~ '/home/aiya000/Desktop' ]] | |
} | |
function is_needing_auth () { | |
local command_needs_auth=(push pull fetch) cmd | |
for cmd in "${command_needs_auth[@]}" ; do | |
if [[ $sub_cmd = "$cmd" ]] ; then | |
return 0 | |
fi | |
done | |
return 1 | |
} | |
if is_needing_auth ; then | |
# echo 'Using WSL2 git' | |
/usr/bin/git "$@" | |
return $? | |
fi | |
if [[ -z $ZSH_ENV_USE_WSL_GIT ]] && should_use_windows_git ; then | |
# echo 'Using git.exe' | |
git.exe "$@" | |
return $? | |
fi | |
# echo 'Using WSL2 git' | |
/usr/bin/git "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment