Last active
December 26, 2025 10:27
-
-
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.
This file contains hidden or 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
| bash -lc 'set -e | |
| need(){ command -v "$1" >/dev/null 2>&1; } | |
| sudo_(){ need sudo && sudo "$@" || "$@"; } | |
| # ---- install zsh + basics (NO apt update) ---- | |
| if need apt-get; then | |
| sudo_ DEBIAN_FRONTEND=noninteractive apt-get -y install zsh git curl >/dev/null 2>&1 || true | |
| elif need brew; then | |
| brew install zsh git curl >/dev/null 2>&1 || true | |
| fi | |
| # ---- set zsh as default shell ---- | |
| ZSH_BIN="$(command -v zsh || true)" | |
| [ -n "$ZSH_BIN" ] && [ "${SHELL:-}" != "$ZSH_BIN" ] && chsh -s "$ZSH_BIN" >/dev/null 2>&1 || true | |
| # ---- install Oh-My-Zsh ---- | |
| [ -d "$HOME/.oh-my-zsh" ] || RUNZSH=no CHSH=no sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" >/dev/null 2>&1 || true | |
| ZSH_CUSTOM="${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}" | |
| clone(){ [ -d "$2/.git" ] && return; git clone -q --depth=1 "$1" "$2" >/dev/null 2>&1 || true; } | |
| clone https://github.com/zsh-users/zsh-syntax-highlighting "$ZSH_CUSTOM/plugins/zsh-syntax-highlighting" | |
| clone https://github.com/zsh-users/zsh-autosuggestions "$ZSH_CUSTOM/plugins/zsh-autosuggestions" | |
| clone https://github.com/zsh-users/zsh-completions "$ZSH_CUSTOM/plugins/zsh-completions" | |
| ZSHRC="$HOME/.zshrc"; touch "$ZSHRC" | |
| # ---- base OMZ config ---- | |
| grep -q "^export ZSH=" "$ZSHRC" || printf "\nexport ZSH=\"\$HOME/.oh-my-zsh\"\nZSH_THEME=\"robbyrussell\"\n" >>"$ZSHRC" | |
| grep -q "^plugins=" "$ZSHRC" || echo "plugins=(git dirhistory zsh-completions zsh-autosuggestions zsh-syntax-highlighting)" >>"$ZSHRC" | |
| # ---- sane Zsh config (added once) ---- | |
| grep -q "tag: base-zsh" "$ZSHRC" || cat >>"$ZSHRC" <<'"'"'EOF'"'"' | |
| # ========================== | |
| # tag: base-zsh | |
| # ========================== | |
| # Detect SSH | |
| is_ssh(){ [[ -n "$SSH_CONNECTION" || -n "$SSH_TTY" ]]; } | |
| # ----- Deferred compinit (fast startup) ----- | |
| autoload -Uz compinit | |
| __did_compinit=0 | |
| __lazy_compinit() { | |
| (( __did_compinit )) && return | |
| __did_compinit=1 | |
| compinit -C 2>/dev/null || true | |
| } | |
| __complete() { __lazy_compinit; zle expand-or-complete } | |
| zle -N expand-or-complete __complete | |
| # ----- Completion styles (QUOTED) ----- | |
| zstyle ':completion:*' use-cache on | |
| zstyle ':completion:*' cache-path ~/.zsh/cache | |
| zstyle ':completion:*' menu select | |
| zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' | |
| zstyle ':completion:*' squeeze-slashes true | |
| zstyle ':completion:*' verbose no | |
| # ----- Autosuggestions (SSH-safe) ----- | |
| ZSH_AUTOSUGGEST_STRATEGY=(history) | |
| ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE=10 | |
| ZSH_AUTOSUGGEST_USE_ASYNC=1 | |
| is_ssh && ZSH_AUTOSUGGEST_USE_ASYNC=0 | |
| # ----- History sanity ----- | |
| HISTSIZE=10000 | |
| SAVEHIST=100000 | |
| setopt APPEND_HISTORY INC_APPEND_HISTORY SHARE_HISTORY | |
| setopt HIST_IGNORE_ALL_DUPS HIST_REDUCE_BLANKS HIST_IGNORE_SPACE | |
| # ----- Keys ----- | |
| bindkey "^?" backward-delete-char | |
| bindkey "^H" backward-kill-word | |
| bindkey -e | |
| # ----- QoL ----- | |
| setopt autocd correct | |
| unsetopt beep | |
| # ----- Small helpers ----- | |
| alias c="clear" | |
| alias ..="cd .." | |
| alias ...="cd ../.." | |
| mkcd(){ mkdir -p -- "$1" && cd -- "$1"; } | |
| path(){ echo "$PATH" | tr ":" "\n"; } | |
| # ----- Load OMZ last ----- | |
| [ -f "$ZSH/oh-my-zsh.sh" ] && source "$ZSH/oh-my-zsh.sh" | |
| EOF | |
| echo "✅ Zsh installed & configured. Log out/in or run: exec zsh"' |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment