Skip to content

Instantly share code, notes, and snippets.

@dhh
Last active May 20, 2024 02:41
Show Gist options
  • Save dhh/159b129f511f76db3ae8adb463f70d05 to your computer and use it in GitHub Desktop.
Save dhh/159b129f511f76db3ae8adb463f70d05 to your computer and use it in GitHub Desktop.
linux-setup.sh
# CLI
sudo apt update -y
sudo apt install -y \
git curl btop \
docker.io docker-buildx \
build-essential pkg-config autoconf bison rustc cargo clang \
libssl-dev libreadline-dev zlib1g-dev libyaml-dev libreadline-dev libncurses5-dev libffi-dev libgdbm-dev libjemalloc2 \
libvips imagemagick libmagickwand-dev mupdf mupdf-tools \
redis-tools sqlite3 libsqlite3-0 libmysqlclient-dev \
rbenv apache2-utils
# UI apps
sudo apt install xournalpp nautilus-dropbox
sudo snap install 1password spotify vlc zoom-client signal-desktop typora pinta
sudo snap install code zellij --classic
# Install Tactile Window Manager via Gnome Extensions
sudo apt install -y gnome-browser-connector
open https://chromewebstore.google.com/detail/gnome-shell-integration/gphhapmejobijbbhgpjhcjognlahblep
open https://extensions.gnome.org/extension/4548/tactile/
# Install chrome
cd ~/Downloads
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo dpkg -i google-chrome-stable_current_amd64.deb
cd -
# Install Cascadia Nerd Font (and use it in the terminal)
cd ~/Downloads
wget https://github.com/ryanoasis/nerd-fonts/releases/download/v3.1.1/CascadiaMono.zip
unzip CascadiaMono.zip -d CascadiaFont
mkdir -p ~/.local/share/fonts
cp CascadiaFont/*.ttf ~/.local/share/fonts
fc-cache
PROFILE_ID=$(gsettings get org.gnome.Terminal.ProfilesList default | tr -d "'\n")
gsettings set org.gnome.Terminal.Legacy.Profile:/org/gnome/terminal/legacy/profiles:/:$PROFILE_ID/ font 'CaskaydiaMono Nerd Font 10'
cd -
# Configure zellij for Tokyo Night theme
mkdir -p ~/.config/zellij
cat << EOF >> ~/.config/zellij/config.kdl
themes {
tokyo-night {
fg 169 177 214
bg 26 27 38
black 56 62 90
red 249 51 87
green 158 206 106
yellow 224 175 104
blue 122 162 247
magenta 187 154 247
cyan 42 195 222
white 192 202 245
orange 255 158 100
}
}
theme "tokyo-night"
default_layout "compact"
EOF
# Install ulauncher
sudo add-apt-repository universe -y
sudo add-apt-repository ppa:agornostal/ulauncher -y
sudo apt update
sudo apt install ulauncher
# Install neovim w/ lazyvim
sudo add-apt-repository ppa:neovim-ppa/stable
sudo apt update -y
sudo apt install -y ripgrep neovim
git clone https://github.com/LazyVim/starter ~/.config/nvim
# Install lazygit
cd ~/Downloads
LAZYGIT_VERSION=$(curl -s "https://api.github.com/repos/jesseduffield/lazygit/releases/latest" | grep -Po '"tag_name": "v\K[^"]*')
curl -Lo lazygit.tar.gz "https://github.com/jesseduffield/lazygit/releases/latest/download/lazygit_${LAZYGIT_VERSION}_Linux_x86_64.tar.gz"
tar xf lazygit.tar.gz lazygit
sudo install lazygit /usr/local/bin
cd -
# Install iA Writer theme for Typora
cd ~/Downloads
git clone https://github.com/dhh/ia_typora
mkdir -p ~/.local/share/fonts
cp ia_typora/fonts/iAWriterMonoS-* ~/.local/share/fonts/
fc-cache
mkdir -p ~/snap/typora/88/.config/Typora/themes/
cp ia_typora/ia_typora*.css ~/snap/typora/88/.config/Typora/themes/
cd -
# Ruby
echo 'eval "$(/usr/bin/rbenv init - bash)"' >> ~/.bashrc
source ~/.bashrc
git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build
rbenv install 3.3.1
rbenv global 3.3.1
# Binstubs
cat << EOF >> ~/.bashrc
export PATH="./bin:$PATH"
set +h
alias r='./bin/rails'
EOF
# Setup git aliases
git config --global alias.co checkout
git config --global alias.br branch
git config --global alias.ci commit
git config --global alias.st status
git config --global pull.rebase true
cat << EOF >> ~/.bashrc
alias g='git'
alias gcm='git commit -m'
alias gcam='git commit -a -m'
alias gcad='git commit -a --amend'
EOF
source ~/.bashrc
# Setup GitHub CLI
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \
&& sudo chmod go+r /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 update \
&& sudo apt install gh -y
gh auth login
# Setup GitHub Desktop
wget -qO - https://apt.packages.shiftkey.dev/gpg.key | gpg --dearmor | sudo tee /usr/share/keyrings/shiftkey-packages.gpg > /dev/null
sudo sh -c 'echo "deb [arch=amd64 signed-by=/usr/share/keyrings/shiftkey-packages.gpg] https://apt.packages.shiftkey.dev/ubuntu/ any main" > /etc/apt/sources.list.d/shiftkey-packages.list'
sudo apt update && sudo apt install github-desktop
# Setup Docker
echo "Add user to docker group (needs restart to become effective)"
sudo usermod -aG docker ${USER}
echo "alias d='docker'" >> ~/.bashrc
source ~/.bashrc
DOCKER_CONFIG=${DOCKER_CONFIG:-$HOME/.docker}
mkdir -p $DOCKER_CONFIG/cli-plugins
curl -SL https://github.com/docker/compose/releases/download/v2.27.0/docker-compose-linux-x86_64 -o $DOCKER_CONFIG/cli-plugins/docker-compose
chmod +x $DOCKER_CONFIG/cli-plugins/docker-compose
docker run -d --restart unless-stopped -p 3306:3306 --name=mysql8 -e MYSQL_ROOT_PASSWORD= -e MYSQL_ALLOW_EMPTY_PASSWORD=true mysql:8
docker run -d --restart unless-stopped -p 6379:6379 --name=redis redis
# Setup nodenv
git clone https://github.com/nodenv/nodenv.git ~/.nodenv
sudo ln -vs ~/.nodenv/bin/nodenv /usr/local/bin/nodenv
cd ~/.nodenv
src/configure && make -C src || true
cd ~/
mkdir -p "$(nodenv root)"/plugins
git clone https://github.com/nodenv/node-build.git "$(nodenv root)"/plugins/node-build
git clone https://github.com/nodenv/nodenv-aliases.git $(nodenv root)/plugins/nodenv-aliases
nodenv install 20.11.1
nodenv global 20.11.1
sudo ln -vs $(nodenv root)/shims/* /usr/local/bin/
echo 'eval "$(nodenv init -)"' >> ~/.bashrc
source ~/.bashrc
@americos
Copy link

I'm curious why you prefer to run rbenv and nodeenv instead something like asdf to manage both Ruby and Node versions?

@felipemeamaral
Copy link

felipemeamaral commented May 6, 2024

I'm curious why you prefer to run rbenv and nodeenv instead something like asdf to manage both Ruby and Node versions?

asdf has some reports of NOT working properly with VSCode.
I tried it in the past for Go and Node development and it was unable to find the resources, even after setting all the required paths on it.
I guess that DHH has hit the same wall as me or it is a matter of preference.

@jeffreyguenther
Copy link

mise is a great alternative to asdf. It uses the same plugins and is much faster.

@justinko
Copy link

I’ve had zero issues with asdf with any language.

@sylvester-roos
Copy link

NixOS fixes this

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