Skip to content

Instantly share code, notes, and snippets.

@GongT
Created December 10, 2019 10:07
Show Gist options
  • Save GongT/29ac0baa0218a82197ebf87135bd8e5b to your computer and use it in GitHub Desktop.
Save GongT/29ac0baa0218a82197ebf87135bd8e5b to your computer and use it in GitHub Desktop.
remove Windows staff from PATH cygwin
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