From f158c4e9131c7e4931801a8aaa7c777d3aff26df Mon Sep 17 00:00:00 2001 From: Aditya Gupta Date: Thu, 25 Jun 2026 22:21:26 +0530 Subject: [PATCH] feat(installers): Added lazygit installer --- installers/install_lazygit.sh | 81 +++++++++++++++++++++++++++++++++++ lib/registry.sh | 4 +- 2 files changed, 84 insertions(+), 1 deletion(-) create mode 100755 installers/install_lazygit.sh diff --git a/installers/install_lazygit.sh b/installers/install_lazygit.sh new file mode 100755 index 0000000..4adbb88 --- /dev/null +++ b/installers/install_lazygit.sh @@ -0,0 +1,81 @@ +#!/usr/bin/env bash +# Tool: lazygit +# DisplayName: lazygit +# Description: Simple terminal UI for git commands +# +# lazygit Installer Script +# + +# Prevent standalone execution +if [ -z "${_LIB_COMMON_SOURCED:-}" ]; then + echo "Error: This script must be run through the 'b' CLI." >&2 + exit 1 +fi + +set -euo pipefail + +# ─── Installation Logic ────────────────────────────────────────────── + +install_lazygit() { + if has_command lazygit; then + if ! confirm "lazygit is already installed. Reinstall/Upgrade?"; then + log_info "Skipping lazygit installation." + return + fi + else + if ! confirm "Install lazygit?"; then + log_info "Skipping lazygit installation." + return + fi + fi + + local latest_tag="" + if has_command curl; then + latest_tag=$(curl -sL https://api.github.com/repos/jesseduffield/lazygit/releases/latest \ + | grep '"tag_name":' | head -n1 \ + | sed -E 's/.*"tag_name": "([^"]+)".*/\1/' || true) + fi + + if [ -z "$latest_tag" ]; then + latest_tag="v0.62.2" # fallback + log_warn "Failed to fetch latest version. Falling back to: $latest_tag" + fi + + local version="${latest_tag#v}" + + local arch=$(detect_arch) + local arch_str="x86_64" + if [ "$arch" = "arm64" ]; then + arch_str="arm64" + fi + + local url="https://github.com/jesseduffield/lazygit/releases/download/${latest_tag}/lazygit_${version}_linux_${arch_str}.tar.gz" + + TMP_DIR="$(make_temp_dir)" + cleanup() { rm -rf "$TMP_DIR"; } + trap cleanup EXIT + + local dest="$TMP_DIR/lazygit.tar.gz" + + log_info "Downloading lazygit ${latest_tag}..." + download_file "$url" "$dest" + + log_info "Extracting..." + tar -xzf "$dest" -C "$TMP_DIR" + + mkdir -p "$HOME/.local/bin" + cp "$TMP_DIR/lazygit" "$HOME/.local/bin/lazygit" + chmod +x "$HOME/.local/bin/lazygit" + track_file "$HOME/.local/bin/lazygit" +} + +# ─── Main ───────────────────────────────────────────────────────────── + +main() { + install_lazygit + + echo + log_success "lazygit installation complete." +} + +main "$@" diff --git a/lib/registry.sh b/lib/registry.sh index 0d30023..abbb9b4 100644 --- a/lib/registry.sh +++ b/lib/registry.sh @@ -5,6 +5,7 @@ declare -A INSTALLERS=( [asciicinema]="asciinema terminal recorder" [bat]="Bat (alternative to cat) and configure alias" [docker]="Container runtime and orchestration platform" + [lazygit]="Simple terminal UI for git commands" [node]="Node.js (LTS) and NVM" [nvim]="Neovim 0.12.0 and configuration" [pnpm]="pnpm package manager" @@ -21,6 +22,7 @@ declare -A INSTALLER_DISPLAYS=( [asciicinema]="asciicinema" [bat]="Bat" [docker]="Docker" + [lazygit]="lazygit" [node]="Node" [nvim]="Neovim" [pnpm]="Pnpm" @@ -32,4 +34,4 @@ declare -A INSTALLER_DISPLAYS=( [zoxide]="Zoxide" ) -INSTALLER_KEYS=(agy asciicinema bat docker node nvim pnpm rust starship uv yay yazi zoxide) +INSTALLER_KEYS=(agy asciicinema bat docker lazygit node nvim pnpm rust starship uv yay yazi zoxide)