Adding update-atuin, improving update-nvim

This commit is contained in:
Lockszmith (kateryna) 2024-09-25 20:30:40 -04:00
parent ea1633a1bc
commit 08fe84eb47
2 changed files with 70 additions and 9 deletions

View File

@ -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 "${@}"

View File

@ -10,19 +10,48 @@ _update-nvim() {
neovim/neovim latest appimage \
| grep appimage\$
)"
local appPath="${HOME}/.local/bin/nvim.AppImage"
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 "${HOME}/.local/bin/"{nvim.AppImage,nvim,vi,vim} 2>/dev/null || true
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 "${@}"