#!/usr/bin/env bash ## CONSTANTS BASEDIR=$(dirname $0) ## FUNCTIONS function assert_debian13 { test -f /etc/debian_version && grep --quiet ^13\. /etc/debian_version || echo "assert: Debian 13 missing!" } function assert_gnome_desktop { [[ $XDG_SESSION_DESKTOP == "gnome" ]] || echo "assert: Gnome Shell missing!" } function install_ghostty { if ! command -v ghostty >/dev/null; then curl -sS https://debian.griffo.io/EA0F721D231FDD3A0A17B9AC7808B4DD62C41256.asc | sudo gpg --dearmor --yes -o /etc/apt/trusted.gpg.d/debian.griffo.io.gpg echo "deb https://debian.griffo.io/apt $(lsb_release -sc 2>/dev/null) main" | sudo tee /etc/apt/sources.list.d/debian.griffo.io.list sudo apt-get update && sudo apt-get install -y ghostty else echo Ghostty already installed! fi if ! systemctl is-enabled --user --quiet app-com.mitchellh.ghostty; then systemctl enable --user app-com.mitchellh.ghostty.service else echo "Ghostty service already enabled!" fi } function install_homebrew { # $nope grep OK file # exit 11 # echo AAA on_exit 45 exit 45 raise_error 'BBB' false echo BBB bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" } function set_alternative { local key command path_to_command path_to_key key=$1 [[ -f /etc/alternatives/$key ]] || raise_error "alternative <${key}> not found!" 11 path_to_key=$(readlink "/etc/alternatives/$key") command=$2 path_to_command=$(command -v "${command}") if [[ "${path_to_key}" != "${path_to_command}" ]]; then echo "$key: $path_to_key != $path_to_command" sudo -vp 'sudo for update-alternatives: ' sudo update-alternatives --install "/usr/bin/${key}" "${key}" "${path_to_command}" 100 sudo update-alternatives --set "${key}" "${path_to_command}" else echo "alternative ${key} => ${command}" fi } function configure_default { # CAPS LOCK means ESC gsettings set org.gnome.desktop.input-sources xkb-options "['caps:escape']" set_alternative editor nvim set_alternative vi nvim set_alternative vim nvim [[ ! -f $HOME/.vimrc ]] && cp "$BASEDIR/resources/vimrc" "$HOME/.vimrc" || echo vimrc defined! configure_nvim configure_nvim nvim-vanilla } function configure_nvim { local nvim_app=${1:-nvim} if grep -q "\$HOME/.vimrc" "$HOME/.config/${nvim_app}/init.lua"; then cat "$BASEDIR/resources/init.lua" "$HOME/.config/${nvim_app}/init.lua" >"$HOME/.config/${nvim_app}/init.lua.new" mv "$HOME/.config/${nvim_app}/init.lua.new" "$HOME/.config/${nvim_app}/init.lua" echo "${nvim_app} init.lua may load .vimrc newly created!" else echo "${nvim_app} init.lua may load .vimrc already defined!" fi } function install_neovim { local shellrc alias_expr shellrc="$HOME/.bashrc" if ! grep -q nvim-vanilla "$shellrc"; then echo "alias nvim-vanilla='NVIM_APPNAME=nvim-vanilla nvim'" >>"$shellrc" echo 'nvim-vanilla created!' RELOAD_SHELL=true else echo 'nvim-vanilla ready!' fi } ## MAIN source "$BASEDIR/lib/backtrace.bash" assert_debian13 assert_gnome_desktop install_ghostty install_homebrew # install_neovim configure_default