shell-host/apps/vscode/vscode.func

36 lines
954 B
Bash
Executable File

#!/bin/bash
vscode() {
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
}
# # if script was executed then call the function
(return 0 2>/dev/null) || vscode $@