2022-02-21 12:42:22 -08:00
|
|
|
#!/bin/bash
|
|
|
|
|
2023-12-14 17:29:19 -08:00
|
|
|
|
2022-02-21 12:42:22 -08:00
|
|
|
vscode() {
|
2023-12-14 17:29:19 -08:00
|
|
|
|
|
|
|
CODE_BIN=/opt/vscode/bin/code
|
|
|
|
VSCODIUM_BIN=$(command -v code-oss)
|
|
|
|
local home=/opt/vscode;local code=-codium
|
|
|
|
local exts; local user; local bin=$VSCODIUM_BIN
|
|
|
|
[[ $1 == "-c" ]] && code=-code && bin=$CODE_BIN && shift 1
|
|
|
|
if [[ $1 == "-h" ]]; then
|
|
|
|
home=$2
|
|
|
|
shift 2
|
|
|
|
else
|
|
|
|
home=${VSCODE_HOME:-$home}/${USER}$code
|
|
|
|
fi
|
|
|
|
exts=$home/extensions
|
|
|
|
user=$home/data
|
|
|
|
if [[ -x $bin ]]; then
|
|
|
|
if ! mkdir -p ${home} ; then
|
|
|
|
echo "unable to set vscode home at $home, aborting"
|
|
|
|
return 1
|
|
|
|
else
|
|
|
|
echo "saving vscode user data and extentions to $home"
|
|
|
|
fi
|
|
|
|
echo $bin --user-data-dir=$user --extensions-dir=$exts "$@"
|
|
|
|
$bin --user-data-dir=$user --extensions-dir=$exts "$@"
|
|
|
|
else
|
|
|
|
echo "can't find binary $bin"
|
|
|
|
fi
|
2022-02-21 12:42:22 -08:00
|
|
|
}
|
|
|
|
|
2023-12-14 17:29:19 -08:00
|
|
|
|
2022-02-21 12:42:22 -08:00
|
|
|
# # if script was executed then call the function
|
|
|
|
(return 0 2>/dev/null) || vscode $@
|