-
-
Save aiya000/b0b2ac7298d33d3cac2693866433d2ae 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 | |
/usr/bin/git "$@" | |
return $? | |
fi | |
if [[ -z $ZSH_ENV_USE_WSL_GIT ]] && should_use_windows_git ; then | |
git.exe "$@" | |
return $? | |
fi | |
/usr/bin/git "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment