Skip to content

Instantly share code, notes, and snippets.

@cheeseonamonkey
Last active January 5, 2026 06:13
Show Gist options
  • Select an option

  • Save cheeseonamonkey/38d6464c26332d73743144fc771d3c0f to your computer and use it in GitHub Desktop.

Select an option

Save cheeseonamonkey/38d6464c26332d73743144fc771d3c0f to your computer and use it in GitHub Desktop.
Set up a fresh server (runpod, linode, etc.) the way I like it.
curl -fsSL "https://gist.githubusercontent.com/cheeseonamonkey/38d6464c26332d73743144fc771d3c0f/raw/206180318661c451b976d9fe47425e5a930d7f74/bootstrap_fresh_host.sh" | bash
#!/usr/bin/env bash
set -euo pipefail
log(){ echo "→ $*"; }
need(){ command -v "$1" >/dev/null 2>&1; }
sudo_(){ if [ "$(id -u)" -ne 0 ] && need sudo; then sudo "$@"; else "$@"; fi; }
log "Installing zsh + git + curl + python3..."
if need apt-get; then
sudo_ env DEBIAN_FRONTEND=noninteractive apt-get update -y
sudo_ env DEBIAN_FRONTEND=noninteractive apt-get install -y \
zsh git curl python3 python3-venv python3-pip
elif need apk; then
sudo_ apk add --no-cache zsh git curl python3 py3-pip
elif need dnf; then
sudo_ dnf install -y zsh git curl python3 python3-pip
elif need yum; then
sudo_ yum install -y zsh git curl python3 python3-pip
elif need pacman; then
sudo_ pacman -Sy --noconfirm zsh git curl python python-pip
else
echo "No supported package manager found." >&2
exit 1
fi
log "Installing Oh My Zsh + plugins..."
OMZ="$HOME/.oh-my-zsh"
ZSH_CUSTOM="${ZSH_CUSTOM:-$OMZ/custom}"
if [ ! -d "$OMZ/.git" ]; then
git clone --depth=1 https://github.com/ohmyzsh/ohmyzsh.git "$OMZ"
fi
mkdir -p "$ZSH_CUSTOM/plugins"
clone(){ [ -d "$2/.git" ] || git clone --depth=1 "$1" "$2"; }
clone https://github.com/zsh-users/zsh-completions "$ZSH_CUSTOM/plugins/zsh-completions"
clone https://github.com/zsh-users/zsh-autosuggestions "$ZSH_CUSTOM/plugins/zsh-autosuggestions"
clone https://github.com/zsh-users/zsh-syntax-highlighting "$ZSH_CUSTOM/plugins/zsh-syntax-highlighting"
log "Creating /workspace/venv..."
if [ -d /workspace ]; then
python3 -m venv /workspace/venv || true
/workspace/venv/bin/python -m pip install -U pip setuptools wheel >/dev/null 2>&1 || true
fi
log "Writing ~/.zshrc..."
ZSHRC="$HOME/.zshrc"
[ -f "$ZSHRC" ] && cp "$ZSHRC" "$ZSHRC.bak"
cat >"$ZSHRC" <<'EOF'
# ~/.zshrc
export ZSH="$HOME/.oh-my-zsh"
ZSH_THEME="robbyrussell"
# Plugins (custom plugins live under $ZSH_CUSTOM/plugins)
plugins=(git zsh-autosuggestions zsh-syntax-highlighting)
ZSH_DISABLE_COMPFIX=true
zstyle ':omz:update' mode disabled
HISTSIZE=10000
SAVEHIST=100000
setopt APPEND_HISTORY INC_APPEND_HISTORY SHARE_HISTORY
setopt HIST_IGNORE_ALL_DUPS HIST_REDUCE_BLANKS HIST_IGNORE_SPACE
setopt autocd correct
unsetopt beep
bindkey -e
bindkey '^?' backward-delete-char
bindkey '^H' backward-kill-word
bindkey '^[[3~' delete-char
bindkey '^[[3;5~' kill-word
bindkey '^[[1;5D' backward-word
bindkey '^[[1;5C' forward-word
bindkey '^[Od' backward-word
bindkey '^[Oc' forward-word
alias c='clear'
alias ..='cd ..'
alias ...='cd ../..'
mkcd(){ mkdir -p "$1" && cd "$1"; }
# ====== Completion / TAB behavior (vanilla + smart listing) ======
# - First TAB lists candidates when ambiguous
# - Second TAB enters a selectable menu
zmodload zsh/complist 2>/dev/null || true
setopt AUTO_LIST AUTO_MENU COMPLETE_IN_WORD
# Add zsh-users/zsh-completions to fpath (actual completion files live in /src)
ZSH_CUSTOM="${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}"
fpath=("$ZSH_CUSTOM/plugins/zsh-completions/src" $fpath)
zstyle ':completion:*' menu select
zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}"
autoload -Uz colors && colors
[[ -r "$ZSH/oh-my-zsh.sh" ]] && source "$ZSH/oh-my-zsh.sh"
[[ -r /workspace/venv/bin/activate ]] && source /workspace/venv/bin/activate
# ====== Vanilla Minimal Prompt ======
if [[ $EUID -eq 0 ]]; then
PROMPT='%F{cyan}%~%f %#> '
else
PROMPT='%F{green}%~%f $> '
fi
EOF
log "✓ Done! Run: exec zsh -l"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment