From 96b9f396acb61efbf11ba3a8984915434fc1f46a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartal=20L=C3=A6arsson?= Date: Sat, 29 Aug 2026 12:09:29 +0100 Subject: [PATCH] add zsh and plugins --- ubuntu-provisioning.sh | 82 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 76 insertions(+), 6 deletions(-) diff --git a/ubuntu-provisioning.sh b/ubuntu-provisioning.sh index 0c73e0d..b4776d3 100755 --- a/ubuntu-provisioning.sh +++ b/ubuntu-provisioning.sh @@ -53,7 +53,6 @@ if ! dpkg -s dbeaver-ce >/dev/null 2>&1; then sudo tee /etc/apt/sources.list.d/dbeaver.list fi - # ============================================================ # apt packages # ============================================================ @@ -107,14 +106,84 @@ APT_PACKAGES=( mssql-tools18 unixodbc-dev dbeaver-ce + zsh ) - echo "=== apt packages ===" sudo apt-get update -y sudo apt-get upgrade -y ACCEPT_EULA=Y sudo apt-get install -y "${APT_PACKAGES[@]}" +# ============================================================ +# Set zsh as default shell +# ============================================================ +echo "=== zsh default shell ===" +if [[ "$(getent passwd "$USER" | cut -d: -f7)" != *"zsh"* ]]; then + chsh -s "$(which zsh)" + echo "*** zsh set as default shell — log out/in required for full effect. ***" +fi + +# ============================================================ +# oh-my-zsh +# ============================================================ +echo "=== oh-my-zsh ===" +ZSH_CUSTOM="${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}" +if [[ ! -d "$HOME/.oh-my-zsh" ]]; then + sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" "" --unattended +fi + +# ============================================================ +# zsh plugins (syntax-highlighting + autosuggestions) +# ============================================================ +echo "=== zsh plugins ===" + +ZSH_HIGHLIGHT_REPO="https://github.com/zsh-users/zsh-syntax-highlighting.git" +ZSH_AUTOSUGGEST_REPO="https://github.com/zsh-users/zsh-autosuggestions.git" + +if [[ ! -d "$ZSH_CUSTOM/plugins/zsh-syntax-highlighting" ]]; then + git clone --depth 1 "$ZSH_HIGHLIGHT_REPO" "$ZSH_CUSTOM/plugins/zsh-syntax-highlighting" +fi + +if [[ ! -d "$ZSH_CUSTOM/plugins/zsh-autosuggestions" ]]; then + git clone --depth 1 "$ZSH_AUTOSUGGEST_REPO" "$ZSH_CUSTOM/plugins/zsh-autosuggestions" +fi + +# ============================================================ +# .zshrc +# ============================================================ +echo "=== .zshrc ===" +ZSHRC="$HOME/.zshrc" +cat > "$ZSHRC" << 'ZSHRC_EOF' +export ZSH="$HOME/.oh-my-zsh" +ZSH_THEME="robbyrussell" +plugins=( + git + zsh-syntax-highlighting + zsh-autosuggestions +) +source $ZSH/oh-my-zsh.sh + +export PATH="$HOME/.cargo/bin:$PATH" +export PATH="$PATH:/usr/local/go/bin" +export GOPATH="$HOME/go" +export PATH="$PATH:$GOPATH/bin" +export PATH="$PATH:/opt/mssql-tools18/bin" +ZSHRC_EOF + +# ============================================================ +# tmux — default shell to zsh +# ============================================================ +echo "=== tmux default shell ===" +TMUX_CONF="$HOME/.tmux.conf" +TOUCH_TMUX=0 +if [[ ! -f "$TMUX_CONF" ]]; then + touch "$TMUX_CONF" + TOUCH_TMUX=1 +fi +if ! grep -qF 'set-option -g default-shell' "$TMUX_CONF"; then + printf 'set-option -g default-shell %s\n' "$(which zsh)" >> "$TMUX_CONF" +fi + # ============================================================ # Add user to libvirt groups # ============================================================ @@ -240,11 +309,10 @@ if ! command -v task >/dev/null 2>&1; then fi # ============================================================ -# Ensure cargo is in PATH +# Ensure cargo is in PATH (.bashrc kept for non-interactive bash) # ============================================================ if ! grep -q 'export PATH="$HOME/.cargo/bin:$PATH"' "$HOME/.bashrc"; then printf '\nexport PATH="$HOME/.cargo/bin:$PATH"\n' >> "$HOME/.bashrc" - source "$HOME/.bashrc" fi # ============================================================ @@ -258,6 +326,8 @@ sudo systemctl enable --now libvirtd.service # ============================================================ echo "=== Done ===" -echo "Log out and back in for libvirt group to take effect." -echo "Rust and Cargo are at ~/.cargo/bin — added to .bashrc." +echo "zsh is the default shell — log out and back in." +echo "tmux is configured to use zsh as default-shell." +echo "oh-my-zsh with syntax-highlighting + autosuggestions installed." +echo "Rust and Cargo are at ~/.cargo/bin — added to .zshrc and .bashrc." echo "If mssql-server was installed, run: sudo /opt/mssql/bin/mssql-conf setup"