Skip to content

Instantly share code, notes, and snippets.

@marcelloinfoweb
Created July 24, 2020 13:26
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save marcelloinfoweb/eb24dc108a5ac609f8de63e863abde90 to your computer and use it in GitHub Desktop.
Install vscode on Clear Linux
#!/bin/bash
# https://openwebcraft.com/notes/clearlinux-desktop-setup/
echo "--- start"
wget https://vscode-update.azurewebsites.net/latest/linux-x64/stable -O code_latest_amd64.tar.gz
SRC_FILE=code_latest_amd64.tar.gz
DEST=/opt/code
DEST_BIN=$DEST/bin
DESKTOP_FILE=~/.local/share/applications/code.desktop
DESKTOP_FILE_HANDLER=~/.local/share/applications/code-url-handler.desktop
if [ -d "$SRC_FILE" ]; then
echo "deleting: $SRC_FILE"
sudo rm $SRC_FILE
fi
# create extraction dir
if [ -d "$DEST" ]; then
echo "deleting: $DEST"
sudo rm -rf $DEST
fi
sudo mkdir -p $DEST
# extract archive
echo "extracting: $SRC_FILE"
sudo tar xzf $SRC_FILE -C /opt --transform 's/VSCode-linux-x64/code/'
ls $DEST
# add exe to env path
SH_PATH="export PATH=\$PATH:$DEST_BIN"
if ! grep -q "$SH_PATH" ~/.bashrc ; then
sudo echo "$SH_PATH" >> ~/.bashrc
fi
# creating desktop file
echo "creating desktop file: $DESKTOP_FILE"
touch $DESKTOP_FILE
echo "#!/usr/bin/env xdg-open
[Desktop Entry]
Name=Visual Studio Code
Comment=Code Editing. Refined.
GenericName=Text Editor
Exec=$DEST_BIN/code --no-sandbox --unity-launch %F
Icon=com.visualstudio.code
Type=Application
StartupNotify=false
StartupWMClass=code
Categories=Utility;TextEditor;Development;IDE;
MimeType=text/plain;inode/directory;
Actions=new-empty-window;
Keywords=vscode;
[Desktop Action new-empty-window]
Name=New Empty Window
Exec=$DEST_BIN/code --no-sandbox --new-window %F
Icon=com.visualstudio.code
" > $DESKTOP_FILE
# creating desktop file
echo "creating desktop file: $DESKTOP_FILE_HANDLER"
touch $DESKTOP_FILE_HANDLER
echo "#!/usr/bin/env xdg-open
[Desktop Entry]
Name=Visual Studio Code - URL Handler
Comment=Code Editing. Redefined.
GenericName=Text Editor
Exec=$DEST_BIN/code --no-sandbox --open-url %U
Icon=visual-studio-code
Type=Application
NoDisplay=true
StartupNotify=true
Categories=Utility;TextEditor;Development;IDE;
MimeType=x-scheme-handler/vscode;
Keywords=vscode;
" > $DESKTOP_FILE_HANDLER
echo "--- done"
@ThaiLe011094
Copy link

please update the link to this
https://code.visualstudio.com/sha/download?build=stable&os=linux-x64

@trixoniisama
Copy link

wget "https://code.visualstudio.com/sha/download?build=stable&os=linux-x64" -O code_latest_amd64.tar.gz
to be more exact.

Don't forget to install wget beforehand: sudo swupd bundle-add wget.
Also, VScode wouldn't work under Wayland for me, had to log out, switch to Xorg (X11) and make that the default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment