From 9e17f28a6cd2fe2cd3518548c5691a0f58e9f020 Mon Sep 17 00:00:00 2001 From: Eric Yu Date: Fri, 1 Mar 2024 23:37:20 -0800 Subject: [PATCH] vscode script --- tools/scripts/install_code | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100755 tools/scripts/install_code diff --git a/tools/scripts/install_code b/tools/scripts/install_code new file mode 100755 index 0000000..2acff09 --- /dev/null +++ b/tools/scripts/install_code @@ -0,0 +1,38 @@ +#!/bin/bash + +# Set the version of VSCode. If you want different version, just change this line +code_version="1.82.3" + +# Define the source file and target directory +source_file="source_file.txt" +target_dir="$HOME/bin" + +# Check if $HOME/bin directory exists, if not, create it +if [ ! -d "$target_dir" ]; then + mkdir -p "$target_dir" + echo "Created $target_dir" +fi + +mkdir code +cd code + +# Download VSCode +curl -L -o code.rpm "https://update.code.visualstudio.com/$code_version/linux-rpm-x64/stable" +rpm2cpio code.rpm | cpio -idv + +rm -rf code.rpm + +# correct permissions +cd usr/share/code +chmod +x code +cd bin +chmod +x code + +# Since we don't have sudo, modify a line of the Chromium backend to allow non-roots to run +sed -i 's/\(ELECTRON_RUN_AS_NODE=1 "$ELECTRON" "$CLI" --ms-enable-electron-run-as-node\)/\1 --no-sandbox/' code + +# create shortcut to user's bin folder, which by default is already something in PATH +ln -s $PWD/code $target_dir/code + +# Make sure the linked one also has perm +chmod +x $target_dir/code