From 08fe84eb479c816c93298a9e1bc4f03e8d06ce19 Mon Sep 17 00:00:00 2001 From: "Lockszmith (kateryna)" Date: Wed, 25 Sep 2024 20:30:40 -0400 Subject: [PATCH] Adding update-atuin, improving update-nvim --- .../bin/executable_update-atuin | 32 +++++++++++++ .../bin/executable_update-nvim | 47 +++++++++++++++---- 2 files changed, 70 insertions(+), 9 deletions(-) create mode 100644 _home/private_dot_local/bin/executable_update-atuin diff --git a/_home/private_dot_local/bin/executable_update-atuin b/_home/private_dot_local/bin/executable_update-atuin new file mode 100644 index 0000000..816f97f --- /dev/null +++ b/_home/private_dot_local/bin/executable_update-atuin @@ -0,0 +1,32 @@ +#! /usr/bin/env bash + +set -e + +BASE_0=${BASE_0:-$0} +BASE_SHELL=$(basename "$SHELL") + +#! /usr/bin/env bash + +_update-atuin() { ( + set -e + + local LatestURL="$( + get-github-release.sh \ + atuinsh/atuin \ + latest atuin-x86_64-unknown-linux-musl.tar.gz \ + | grep -E 'tar\.gz$' + )" + local dlPath="$(mktemp --directory --suffix atuin)" + local appPath="$HOME/.local/bin" + printf 'Downloading from %s... ' "${LatestURL#*/download/}" + curl -sLO --output-dir "$dlPath" "$LatestURL" && printf 'Done' + printf '\n' + ( cd "$dlPath"; curl -sL "$LatestURL.sha256" | sha256sum --check ) + ( cd "$appPath"; tar zxf "$dlPath"/*.tar.gz --strip-components=1 --no-anchored 'atuin' ) + rm -R "$dlPath" + + printf '%s\n' \ + 'atuin binary installed, please restart you shell' +); } + +_update-atuin "${@}" diff --git a/_home/private_dot_local/bin/executable_update-nvim b/_home/private_dot_local/bin/executable_update-nvim index 8cb1567..512d4d0 100644 --- a/_home/private_dot_local/bin/executable_update-nvim +++ b/_home/private_dot_local/bin/executable_update-nvim @@ -10,19 +10,48 @@ _update-nvim() { neovim/neovim latest appimage \ | grep appimage\$ )" - local appPath="${HOME}/.local/bin/nvim.AppImage" - - rm "${HOME}/.local/bin/"{nvim.AppImage,nvim,vi,vim} 2>/dev/null || true - + local appDir="${HOME}/.local/bin" + if [ "$USER" = "root" ]; then + appDir="${HOME}/usr-local-bin" + while umount --types overlay /usr/local/bin 2>/dev/null; do + : + done + mkdir -pm 755 "$appDir" \ + && mount -t overlay overlay -o "lowerdir=$appDir:/usr/local/bin" /usr/local/bin + update-alternatives --remove vim.tiny /usr/bin/vim.tiny + fi + local appPath="${appDir}/nvim.AppImage" + + rm "${appDir}/"{nvim.AppImage,nvim,vi,vim,vim.tiny,vimdiff} 2>/dev/null || true + printf 'Downloading from %s... ' "${LatestURL#*/download/}" curl -sLo "$appPath" "$LatestURL" && printf 'Done' printf '\n' chmod +x "$appPath" - - ln -rs "$appPath" "${HOME}/.local/bin/nvim" - ln -rs "$appPath" "${HOME}/.local/bin/vi" - ln -rs "$appPath" "${HOME}/.local/bin/vim" + + ln -rs "$appPath" "${appDir}/nvim" + ln -rs "$appPath" "${appDir}/vi" + ln -rs "$appPath" "${appDir}/vim" + ln -rs "$appPath" "${appDir}/vim.tiny" + ln -rs "$appPath" "${appDir}/vimdiff" + + if [ "$USER" = "root" ]; then + update-alternatives --install /usr/bin/editor editor "$appPath" 110 + update-alternatives --install /usr/bin/edit edit "$appPath" 110 + update-alternatives --install /usr/bin/ex ex "$appPath" 110 + update-alternatives --install /usr/bin/vi vi "$appPath" 110 + update-alternatives --install /usr/bin/view view "$appPath" 110 + update-alternatives --install /usr/bin/vim vim "$appPath" 110 + update-alternatives --install /usr/bin/vimdiff vimdiff "$appPath" 110 + update-alternatives --set editor "$appPath" + update-alternatives --set edit "$appPath" + update-alternatives --set ex "$appPath" + update-alternatives --set vi "$appPath" + update-alternatives --set view "$appPath" + update-alternatives --set vim "$appPath" + update-alternatives --set vimdiff "$appPath" + + fi } _update-nvim "${@}" -