Skip to content

Instantly share code, notes, and snippets.

@GongT
Created November 5, 2019 03:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GongT/affd1d6029c86f63c5cd86345b6bc11c to your computer and use it in GitHub Desktop.
Save GongT/affd1d6029c86f63c5cd86345b6bc11c to your computer and use it in GitHub Desktop.
start VSCode from cygwin (/usr/local/bin/code)
#/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