Created
December 10, 2019 10:07
-
-
Save GongT/29ac0baa0218a82197ebf87135bd8e5b to your computer and use it in GitHub Desktop.
remove Windows staff from PATH cygwin
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
if uname | grep -iq "cygwin" ; then | |
IFS=: read -r -d '' -a path_array < <(printf '%s:\0' "$PATH") | |
WINPATH="" | |
LP="" | |
for P in "${path_array[@]}"; do | |
if [[ "$P" =~ ^/cygdrive ]]; then | |
WINPATH+=":$P" | |
else | |
LP+="$P:" | |
fi | |
done | |
export WINPATH="${WINPATH:1}" | |
export PATH="$LP:/bin:/usr/sbin:/sbin" | |
unset path_array P LP | |
function exec-win() { | |
PATH="$WINPATH" "$@" | |
} | |
export -f exec-win | |
function exec-mix() { | |
PATH="$WINPATH:$PATH" "$@" | |
} | |
export -f exec-mix | |
function which-win() { | |
PATH="$WINPATH" command -v "$1" | |
} | |
export -f which-win | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment