From ea1633a1bc786b334439da8a55d4eb8dfb02f9fb Mon Sep 17 00:00:00 2001 From: "Lockszmith (kateryna)" Date: Sat, 21 Sep 2024 15:13:28 -0400 Subject: [PATCH] added update nvim --- .../bin/executable_get-github-release.sh | 20 +++++++++++++ .../bin/executable_update-nvim | 28 +++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 _home/private_dot_local/bin/executable_get-github-release.sh create mode 100644 _home/private_dot_local/bin/executable_update-nvim diff --git a/_home/private_dot_local/bin/executable_get-github-release.sh b/_home/private_dot_local/bin/executable_get-github-release.sh new file mode 100644 index 0000000..dd16b97 --- /dev/null +++ b/_home/private_dot_local/bin/executable_get-github-release.sh @@ -0,0 +1,20 @@ +#! /usr/bin/env bash + +GH_PROJECT="${1}" +GH_DL_TAG="${2:-latest}" +GH_FILTER="${3:-deb}" +if [[ ! "$GH_FILTER" =~ '(' ]]; then + GH_FILTER="contains(\"${GH_FILTER}\")" +fi +SRC_URL=https://api.github.com/repos/${GH_PROJECT}/releases/${GH_DL_TAG} +DL_URL=$( \ + curl -sL curl ${SRC_URL} \ + | jq -r " \ + .assets[] \ + | select(.browser_download_url \ + | ${GH_FILTER} ) \ + | .browser_download_url \ + ") +[[ -n "$DL_URL" ]] \ + && printf "%s\n" $DL_URL \ + || return 1 2>/dev/null || exit 1 diff --git a/_home/private_dot_local/bin/executable_update-nvim b/_home/private_dot_local/bin/executable_update-nvim new file mode 100644 index 0000000..8cb1567 --- /dev/null +++ b/_home/private_dot_local/bin/executable_update-nvim @@ -0,0 +1,28 @@ +#! /usr/bin/env bash + +set -e + +BASE_0=${BASE_0:-$0} +BASE_SHELL=$(basename "$SHELL") + +_update-nvim() { + local LatestURL="$(get-github-release.sh \ + 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 + + 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" +} + +_update-nvim "${@}" +