Last active
March 22, 2025 10:46
-
-
Save surajsharma/4619f35666662ccd5f9114676919a1a4 to your computer and use it in GitHub Desktop.
setup code-server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Function to check if a command exists | |
command_exists() { | |
command -v "$1" >/dev/null 2>&1 | |
} | |
# Set Git user name and email credentials | |
git config --global user.name "suraj sharma" | |
git config --global user.email "[email protected]" | |
# Function to install packages based on the OS | |
install_package() { | |
if command_exists apt-get; then | |
sudo apt-get install -y "$1" | |
elif command_exists yum; then | |
sudo yum install -y "$1" | |
elif command_exists dnf; then | |
sudo dnf install -y "$1" | |
elif command_exists pacman; then | |
sudo pacman -S --noconfirm "$1" | |
else | |
echo "Unsupported package manager" | |
exit 1 | |
fi | |
} | |
# Update package manager | |
if command_exists apt-get; then | |
sudo apt-get update | |
elif command_exists yum; then | |
sudo yum update -y | |
elif command_exists dnf; then | |
sudo dnf update -y | |
elif command_exists pacman; then | |
sudo pacman -Syu --noconfirm | |
fi | |
# Install fc-list (fontconfig) | |
if ! command_exists fc-list; then | |
install_package fontconfig | |
fi | |
# Install lsof | |
if ! command_exists lsof; then | |
install_package lsof | |
fi | |
# Install Go | |
if ! command_exists go; then | |
wget https://go.dev/dl/go1.24.1.linux-amd64.tar.gz | |
sudo rm -rf /usr/local/go | |
sudo tar -C /usr/local -xzf go1.24.1.linux-amd64.tar.gz | |
echo 'export PATH=$PATH:/usr/local/go/bin' >> ~/.bashrc | |
rm go1.24.1.linux-amd64.tar.gz | |
fi | |
# Setup Go environment variables in .bashrc | |
echo 'export PATH=$PATH:/usr/local/go/bin' >> /etc/profile | |
echo 'export PATH=$PATH:/usr/local/go/bin' >> ~/.bashrc | |
echo 'export GOPATH=$HOME/go' >> ~/.bashrc | |
echo 'export PATH=$PATH:$GOPATH/bin' >> ~/.bashrc | |
# Apply the environment variables to current session | |
export PATH=$PATH:/usr/local/go/bin | |
export GOPATH=$HOME/go | |
export PATH=$PATH:$GOPATH/bin | |
# Create GOPATH directory | |
mkdir -p $GOPATH | |
# Install Node.js using nvm | |
if ! command_exists node; then | |
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash | |
export NVM_DIR="$HOME/.nvm" | |
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" | |
nvm install node # installs latest version | |
fi | |
# Install GitHub CLI | |
if ! command_exists gh; then | |
if command_exists apt-get; then | |
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg | |
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null | |
sudo apt-get update | |
sudo apt-get install -y gh | |
else | |
install_package gh | |
fi | |
fi | |
# Install Zsh and make it default shell | |
if ! command_exists zsh; then | |
install_package zsh | |
chsh -s $(which zsh) | |
# Install Oh My Zsh (optional but recommended) | |
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" | |
fi | |
# Install tmux | |
if ! command_exists tmux; then | |
install_package tmux | |
fi | |
# Install Python | |
if ! command_exists python3; then | |
install_package python3 | |
install_package python3-pip | |
fi | |
go install github.com/air-verse/air@latest | |
echo "Installation complete! Please log out and log back in for all changes to take effect." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment