Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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