Skip to content

Commit 4063f9a

Browse files
committed
feat: add lazygit
1 parent 81ffcf3 commit 4063f9a

File tree

5 files changed

+130
-0
lines changed

5 files changed

+130
-0
lines changed

lazygit/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
title: Lazygit
3+
homepage: https://github.com/jesseduffield/lazygit
4+
tagline: |
5+
simple terminal UI for git commands
6+
---
7+
8+
```sh
9+
lazygit
10+
```

lazygit/install.ps1

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/usr/bin/env pwsh
2+
3+
###################
4+
# Install lazygit #
5+
###################
6+
7+
# Every package should define these variables
8+
$pkg_cmd_name = "lazygit"
9+
10+
$pkg_dst_cmd = "$Env:USERPROFILE\.local\bin\lazygit.exe"
11+
$pkg_dst = "$pkg_dst_cmd"
12+
13+
$pkg_src_cmd = "$Env:USERPROFILE\.local\opt\lazygit-v$Env:WEBI_VERSION\bin\lazygit.exe"
14+
$pkg_src_bin = "$Env:USERPROFILE\.local\opt\lazygit-v$Env:WEBI_VERSION\bin"
15+
$pkg_src_dir = "$Env:USERPROFILE\.local\opt\lazygit-v$Env:WEBI_VERSION"
16+
$pkg_src = "$pkg_src_cmd"
17+
18+
New-Item "$Env:USERPROFILE\Downloads\webi" -ItemType Directory -Force | Out-Null
19+
$pkg_download = "$Env:USERPROFILE\Downloads\webi\$Env:WEBI_PKG_FILE"
20+
21+
# Fetch archive
22+
IF (!(Test-Path -Path "$Env:USERPROFILE\Downloads\webi\$Env:WEBI_PKG_FILE")) {
23+
Write-Output "Downloading lazygit from $Env:WEBI_PKG_URL to $pkg_download"
24+
& curl.exe -A "$Env:WEBI_UA" -fsSL "$Env:WEBI_PKG_URL" -o "$pkg_download.part"
25+
& Move-Item "$pkg_download.part" "$pkg_download"
26+
}
27+
28+
IF (!(Test-Path -Path "$pkg_src_cmd")) {
29+
Write-Output "Installing lazygit"
30+
31+
# TODO: create package-specific temp directory
32+
# Enter tmp
33+
Push-Location .local\tmp
34+
35+
# Remove any leftover tmp cruft
36+
Remove-Item -Path ".\lazygit-v*" -Recurse -ErrorAction Ignore
37+
Remove-Item -Path ".\lazygit.exe" -Recurse -ErrorAction Ignore
38+
39+
# Unpack archive file into this temporary directory
40+
# Windows BSD-tar handles zip. Imagine that.
41+
Write-Output "Unpacking $pkg_download"
42+
& tar xf "$pkg_download"
43+
44+
# Settle unpacked archive into place
45+
Write-Output "Install Location: $pkg_src_cmd"
46+
New-Item "$pkg_src_bin" -ItemType Directory -Force | Out-Null
47+
Move-Item -Path ".\lazygit.exe" -Destination "$pkg_src_bin"
48+
49+
# Exit tmp
50+
Pop-Location
51+
}
52+
53+
Write-Output "Copying into '$pkg_dst_cmd' from '$pkg_src_cmd'"
54+
Remove-Item -Path "$pkg_dst_cmd" -Recurse -ErrorAction Ignore | Out-Null
55+
Copy-Item -Path "$pkg_src" -Destination "$pkg_dst" -Recurse

lazygit/install.sh

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/bin/sh
2+
3+
__init_lazygit() {
4+
set -e
5+
set -u
6+
7+
###################
8+
# Install lazygit #
9+
###################
10+
11+
# Every package should define these 6 variables
12+
pkg_cmd_name="lazygit"
13+
14+
pkg_dst_cmd="$HOME/.local/bin/lazygit"
15+
pkg_dst="$pkg_dst_cmd"
16+
17+
pkg_src_cmd="$HOME/.local/opt/lazygit-v$WEBI_VERSION/bin/lazygit"
18+
pkg_src_dir="$HOME/.local/opt/lazygit-v$WEBI_VERSION"
19+
pkg_src="$pkg_src_cmd"
20+
21+
# pkg_install must be defined by every package
22+
pkg_install() {
23+
# ~/.local/opt/gh-v0.99.9/bin
24+
mkdir -p "$(dirname "$pkg_src_cmd")"
25+
26+
# mv ./lazygit-*/lazygit ~/.local/opt/lazygit-v0.99.9/bin/lazygit
27+
mv ./lazygit "$pkg_src_cmd"
28+
}
29+
30+
# pkg_get_current_version is recommended, but (soon) not required
31+
pkg_get_current_version() {
32+
# 'lazygit --version' has output in this format:
33+
# commit=, build date=, build source=nix, version=0.44.1, os=linux, arch=amd64, git version=2.47.0
34+
# This trims it down to just the version number:
35+
# 0.44.1
36+
output=$(lazygit --version)
37+
version=${output#*version=}
38+
version=${version%%,*}
39+
echo "$version"
40+
}
41+
42+
}
43+
44+
__init_lazygit

lazygit/releases.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
'use strict';
2+
3+
var github = require('../_common/github.js');
4+
var owner = 'jesseduffield';
5+
var repo = 'lazygit';
6+
7+
module.exports = function () {
8+
return github(null, owner, repo).then(function (all) {
9+
return all;
10+
});
11+
};
12+
13+
if (module === require.main) {
14+
module.exports().then(function (all) {
15+
all = require('../_webi/normalize.js')(all);
16+
// just select the first 5 for demonstration
17+
all.releases = all.releases.slice(0, 5);
18+
console.info(JSON.stringify(all, null, 2));
19+
});
20+
}

test/install.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ __test() {
243243
koji \
244244
kubectx \
245245
kubens \
246+
lazygit \
246247
lf \
247248
lsd \
248249
mutagen \

0 commit comments

Comments
 (0)