Skip to content

Instantly share code, notes, and snippets.

@hoho4190
Created April 9, 2024 12:14
Show Gist options
  • Save hoho4190/5d320524f9d08e31884709c3f8d29f5f to your computer and use it in GitHub Desktop.
Save hoho4190/5d320524f9d08e31884709c3f8d29f5f to your computer and use it in GitHub Desktop.
lazygit-install-update

Debian GNU/Linux 12 (bookworm) aarch64

https://github.com/jesseduffield/lazygit?tab=readme-ov-file#ubuntu

lazygit-install-update.sh

#!/bin/bash

DOWNLOAD_DIR=~/downloads
LATEST_TAG=$(curl -s "https://api.github.com/repos/jesseduffield/lazygit/releases/latest" | jq -r '.tag_name')
LATEST_VERSION=${LATEST_TAG//v/}
KERNEL_NAME=$(uname -s)
ARCHITECTURE=$(dpkg --print-architecture)

# version check
if version_info=$(lazygit --version); then
    cur_version=$(echo "$version_info" | grep -oP 'version=\K[0-9]+(\.[0-9]+){2}' | head -1)
    if ! dpkg --compare-versions "${LATEST_VERSION}" "gt" "$cur_version"; then
        echo "lazygit is already the newest version ($cur_version)"
        exit 0
    fi
fi

mkdir -p "$DOWNLOAD_DIR"
cd "$DOWNLOAD_DIR" || exit 1

asset_name="lazygit_${LATEST_VERSION}_${KERNEL_NAME}_${ARCHITECTURE}.tar.gz"
echo "Asset name: $asset_name"

curl -Lo lazygit.tar.gz \
        "https://github.com/jesseduffield/lazygit/releases/download/$LATEST_TAG/$asset_name"
tar xf lazygit.tar.gz lazygit
sudo install lazygit /usr/local/bin

rm lazygit.tar.gz lazygit
  • check and set DOWNLOAD_DIR
  • check asset_name
  • jq required

check

lazygit --version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment