From 01073293f62c2bd018cb567d4d95bb4453e5b791 Mon Sep 17 00:00:00 2001 From: pvincent Date: Wed, 1 Jul 2026 23:50:18 +0400 Subject: [PATCH] update-alternatives --- install.sh | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/install.sh b/install.sh index 7d40f5c..e51e370 100755 --- a/install.sh +++ b/install.sh @@ -38,13 +38,44 @@ function install_ghostty { } function install_homebrew { - : + + bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" +} + +function raise_error { + message=${1:-an undefined error has occured!} + code=${2:-1} + echo "error ${code}: ${message}" >&2 + exit ${code} +} + +function set_alternative { + local key=$1 + [[ -f /etc/alternatives/$key ]] || raise_error "alternative <${key}> not found!" 11 + + local path_to_key=$(readlink -f /usr/bin/$key) + + local command=$2 + local path_to_command=$(command -v "${command}") + + if [[ "${path_to_key}" != "${path_to_command}" ]]; then + 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 + # 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 + } ## MAIN @@ -54,6 +85,6 @@ assert_gnome_desktop echo "MIAOU-DESKTOP installation..." install_ghostty -install_homebrew +# install_homebrew configure_default echo SUCCESS