diff --git a/scripts/install-starship-nerdfont.sh b/scripts/install-starship-nerdfont.sh new file mode 100755 index 0000000..d1419d2 --- /dev/null +++ b/scripts/install-starship-nerdfont.sh @@ -0,0 +1,73 @@ +#!/usr/bin/env bash +# Installs Starship (the prompt) + JetBrainsMono Nerd Font (the icons) on a +# host you SSH into from ArchNest's Terminal page, and wires Starship into +# bash/zsh if either is present. Safe to re-run. +# +# This repo is private, so there's no public raw-URL one-liner. Run it directly +# on the target VM instead, as the user whose shell you want themed: +# scp scripts/install-starship-nerdfont.sh youruser@host:/tmp/ +# ssh youruser@host 'bash /tmp/install-starship-nerdfont.sh' +# or paste its contents into a Terminal/SSH session and run it there. + +set -euo pipefail + +NERD_FONT_VERSION="v3.4.0" +NERD_FONT_NAME="JetBrainsMono" +FONT_DIR="${HOME}/.local/share/fonts/NerdFonts" + +echo "==> Installing Starship" +if command -v starship >/dev/null 2>&1; then + echo " starship already installed ($(starship --version | head -1)), skipping" +else + curl -fsSL https://starship.rs/install.sh | sh -s -- -y +fi + +echo "==> Installing ${NERD_FONT_NAME} Nerd Font into ${FONT_DIR}" +mkdir -p "${FONT_DIR}" +TMP_TAR="$(mktemp)" +curl -fsSL -o "${TMP_TAR}" \ + "https://github.com/ryanoasis/nerd-fonts/releases/download/${NERD_FONT_VERSION}/${NERD_FONT_NAME}.tar.xz" +tar -xJf "${TMP_TAR}" -C "${FONT_DIR}" +rm -f "${TMP_TAR}" + +if command -v fc-cache >/dev/null 2>&1; then + fc-cache -f "${FONT_DIR}" >/dev/null +fi + +STARSHIP_INIT_BASH='eval "$(starship init bash)"' +STARSHIP_INIT_ZSH='eval "$(starship init zsh)"' + +add_init_line() { + local rcfile="$1" line="$2" + [ -f "${rcfile}" ] || return 0 + if ! grep -qF "${line}" "${rcfile}"; then + printf '\n# Added by ArchNest install-starship-nerdfont.sh\n%s\n' "${line}" >> "${rcfile}" + echo " added Starship init to ${rcfile}" + else + echo " ${rcfile} already initializes Starship, skipping" + fi +} + +echo "==> Wiring Starship into shell rc files" +add_init_line "${HOME}/.bashrc" "${STARSHIP_INIT_BASH}" +add_init_line "${HOME}/.zshrc" "${STARSHIP_INIT_ZSH}" + +mkdir -p "${HOME}/.config" +if [ ! -f "${HOME}/.config/starship.toml" ]; then + starship preset nerd-font-symbols -o "${HOME}/.config/starship.toml" 2>/dev/null \ + || echo " (preset command unavailable on this Starship version — using its built-in default prompt, which already includes icons)" +fi + +cat <