2023-09-10 12:35:10 -05:00
#!/usr/bin/env bash
set -e
if [ $( whoami) = = "root" ] ; then
echo "Run as a normal user, not root"
exit 1
fi
command_exists( ) { type " $1 " & >/dev/null; }
if command_exists "apt-get" ; then
sudo apt-get install wget gpg
2024-04-20 20:35:22 -05:00
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor >packages.microsoft.gpg
2023-09-10 12:35:10 -05:00
sudo install -D -o root -g root -m 644 packages.microsoft.gpg /etc/apt/keyrings/packages.microsoft.gpg
sudo sh -c 'echo "deb [arch=amd64,arm64,armhf signed-by=/etc/apt/keyrings/packages.microsoft.gpg] https://packages.microsoft.com/repos/code stable main" > /etc/apt/sources.list.d/vscode.list'
rm -f packages.microsoft.gpg
sudo apt install apt-transport-https
sudo apt update
sudo apt install code
2024-03-17 18:56:48 -05:00
elif command_exists "dnf" ; then
2023-09-10 12:35:10 -05:00
sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
sudo sh -c 'echo -e "[code]\nname=Visual Studio Code\nbaseurl=https://packages.microsoft.com/yumrepos/vscode\nenabled=1\ngpgcheck=1\ngpgkey=https://packages.microsoft.com/keys/microsoft.asc" > /etc/yum.repos.d/vscode.repo'
2024-03-17 18:56:48 -05:00
sudo dnf install code -y
2024-02-28 13:14:13 -06:00
elif command_exists "yay" ; then
yay -S visual-studio-code-bin clang-format-static-bin --noconfirm --needed
2023-09-10 12:35:10 -05:00
elif command_exists "zypp" ; then
# Untested
sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
sudo sh -c 'echo -e "[code]\nname=Visual Studio Code\nbaseurl=https://packages.microsoft.com/yumrepos/vscode\nenabled=1\ntype=rpm-md\ngpgcheck=1\ngpgkey=https://packages.microsoft.com/keys/microsoft.asc" > /etc/zypp/repos.d/vscode.repo'
sudo zypper refresh
sudo zypper install code
elif command_exists "emerge" ; then
echo Not yet supported, exiting...
exit
elif command_exists "apk" ; then
echo Not yet supported, exiting...
exit
2024-04-17 21:41:40 -05:00
elif command_exists "xbps-install" ; then
sudo xbps-install vscode
2023-09-10 12:35:10 -05:00
else
echo "Unsupported: unknown package manager and distro"
fi