Skip to content

Instantly share code, notes, and snippets.

@lubien
Created February 26, 2026 13:30
Show Gist options
  • Select an option

  • Save lubien/2bc827778c551d9c6298ff5826eaff3e to your computer and use it in GitHub Desktop.

Select an option

Save lubien/2bc827778c551d9c6298ff5826eaff3e to your computer and use it in GitHub Desktop.
#!/bin/bash
# Function to install VSCode
install_vscode() {
echo "Installing Visual Studio Code..."
# Update package index
sudo apt update
# Install required dependencies
sudo apt install -y apt-transport-https curl
# Import the Microsoft GPG key
curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor | sudo tee /usr/share/keyrings/vscode.gpg > /dev/null
# Add the VSCode repository
echo "deb [signed-by=/usr/share/keyrings/vscode.gpg] https://packages.microsoft.com/repos/vscode stable main" | sudo tee /etc/apt/sources.list.d/vscode.list
# Update package index again
sudo apt update
# Install VSCode
sudo apt install -y code
}
# Check if 'code' command exists
if command -v code &>/dev/null; then
echo "Visual Studio Code is already installed. Running code tunnel..."
code tunnel
else
install_vscode
echo "Visual Studio Code installed successfully. Running code tunnel..."
code tunnel
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment