Skip to content

Instantly share code, notes, and snippets.

@xai
Last active November 17, 2022 21:39
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 xai/369bfa73223787f1a4e3297596cb139a to your computer and use it in GitHub Desktop.
Save xai/369bfa73223787f1a4e3297596cb139a to your computer and use it in GitHub Desktop.
#!/bin/bash
set -e
SOURCES="$HOME/Git/misc/microsoft"
VSCODE="$HOME/Downloads/vscode"
VSCODIUM="$HOME/Downloads/vscodium"
REPOS="$HOME/Git/"
ARGS="--extensions-dir $HOME/debugging/extensions"
usage() {
echo "$0 vscode-version [repo]"
exit 1
}
configure_nvm() {
echo "Configure node version"
. ${HOME}/.nvm/nvm.sh
nvm use 16
echo
}
prepare_repo() {
cd $1
echo "$1: reset and build repository"
git reset .
git checkout .
git clean -dfx
time yarn
cd -
}
prepare_data_dir() {
if [ ! -z "$1" -a -d "$1" ]
then
echo "Cleaning $1"
rm -rf "$1"
fi
}
if [ -z "$1" ]
then
usage
fi
codeversion="$1"
shift
configure_nvm
if [[ "$codeversion" =~ "src-" ]]
then
ossversion="${codeversion/src-/}"
executable="${SOURCES}/vscode-${ossversion}/scripts/code.sh"
datadir="$HOME/.config/code-oss-$ossversion"
echo "Using open source version: $codeversion"
elif [[ "$codeversion" =~ "codium-" ]]
then
codiumversion="${codeversion/codium-/}"
executable="${VSCODIUM}/vscodium-${codiumversion}/bin/codium"
datadir="$HOME/.config/codium-$codiumversion"
echo "Using vscodium binary version: $codiumversion"
else
executable="${VSCODE}/vscode-${codeversion}/bin/code"
datadir="$HOME/.config/code-$codeversion"
echo "Using released binary version: $codeversion"
fi
if [ -x $executable ]
then
location=""
if [ ! -z "$1" ]
then
location="$REPOS/${1}"
if [ ! -d ${location}/.git ]
then
echo "Not a repository: $location"
exit 3
fi
# prepare_repo "$location"
prepare_data_dir "$datadir"
if [ -f ${location}/*code-workspace ]
then
location="$location/*.code-workspace"
fi
fi
echo "$executable --user-data-dir=$datadir $ARGS $location"
$executable --user-data-dir=$datadir $ARGS $location
exit $?
else
echo "executable not found or not executable: $executable"
exit 2
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment