Created
November 5, 2019 03:30
-
-
Save GongT/affd1d6029c86f63c5cd86345b6bc11c to your computer and use it in GitHub Desktop.
start VSCode from cygwin (/usr/local/bin/code)
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
#/usr/bin/env bash | |
ARGS=("$@") | |
WPATH=() | |
PPATH=() | |
OIFS="$IFS" | |
IFS=":" | |
X=( $PATH ) | |
for P in "${X[@]}" ; do | |
if [[ "$P" =~ "/cygdrive/" ]] ; then | |
WPATH+=("$P") | |
else | |
PPATH+=("$P") | |
fi | |
done | |
IFS="$OIFS" | |
unset OIFS | |
for I in "${WPATH[@]}" ; do | |
if [[ -e "$I/code" ]]; then | |
CODE="$I/code" | |
break; | |
fi | |
done | |
if [[ -z "$CODE" ]]; then | |
echo "Cannot find code.exe From:" >&2 | |
for I in "${WPATH[@]}" ; do | |
echo "$I" >&2 | |
done | |
exit 1 | |
fi | |
for I in "${ARGS[@]}"; do | |
if [[ "${I[0]}" == '-' ]]; then | |
PARGS+=("$I") | |
else | |
PARGS+=("$(cygpath -c OEM -m -l -a "$I")") | |
fi | |
done | |
"${CODE}" "${PARGS[@]}" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment