-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate_gitbin
More file actions
executable file
·105 lines (102 loc) · 4.61 KB
/
update_gitbin
File metadata and controls
executable file
·105 lines (102 loc) · 4.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/bin/bash
declare -A gitbin
gitbin["bat"]="sharkdp/bat" # better cat
gitbin["btop"]="aristocratos/btop" # better top
gitbin["cmctl"]="cert-manager/cert-manager" # for k8s certs
gitbin["delta"]="dandavison/delta" # better diff
gitbin["fx"]="antonmedv/fx" # json viewer
gitbin["fzf"]="junegunn/fzf" # fuzzy find
gitbin["gron"]="tomnomnom/gron" # grepable json
gitbin["k9s"]="derailed/k9s" # k8s tui
gitbin["lazygit"]="jesseduffield/lazygit" # git tui
gitbin["lf"]="gokcehan/lf" # file manager
gitbin["lnav"]="tstack/lnav" # log navigation
gitbin["stern"]="stern/stern" # k8s log viewer
gitbin["trip"]="fujiapple852/trippy" # better traceroute
gitbin["paclear"]="orangekame3/paclear" # Pacman clear
gitbin["carapace"]="carapace-sh/carapace-bin" # zsh cli completion
gitbin["jnv"]="ynqa/jnv" # Json viewer/filter
gitbin["xlights"]="xLightsSequencer/xLights" # Xlights Appimage
gitbin["wezterm"]="wezterm/wezterm" # Wezterm Appimage
gitbin["greenlight"]="unknownskl/greenlight" # Greenlight Appimage
gitbin["freeshow"]="ChurchApps/FreeShow" # Freeshow Appimage
#gitbin["nextcloud"]="nextcloud-releases/desktop" # Nextcloud Appimage
gitbin["shellcheck"]="koalaman/shellcheck" # Shell checker
gitbin["vivid"]="sharkdp/vivid" # LS_COLORS generator
#gitbin["usql"]="xo/usql" # Universal SQL Client
gitbin["bluetuith"]="bluetuith-org/bluetuith" # Bluetooth TUI
gitbin["mqttui"]="EDJoPaTo/mqttui" # MQTT TUI
gitbin["kubediff"]="Ramilito/kubediff" # Kube Diff
gitbin["yq"]="mikefarah/yq" # Yq parser
gitbin["rclone"]="rclone/rclone" # Rclone
gitbin["binsider"]="orhun/binsider" # Binary checker
gitbin["moonlight"]="moonlight-stream/moonlight-qt" # Moonlight stream
gitbin["hugo"]="gohugoio/hugo" # Hugo site builder
gitbin["pagefind"]="CloudCannon/pagefind" # Hugo search builder
gitbin["fd"]="sharkdp/fd" # FD Find
gitbin["atuin"]="atuinsh/atuin" # Atuin
gitbin["eza"]="eza-community/eza" # Eza
NC='\033[0m' # No Color
RED='\033[1;31m'
BLUE='\033[1;34m'
GRAY='\033[0;37m'
function grab_bin() {
SKIPPED=""
BIN="$1"
REPO=${gitbin["$BIN"]}
mkdir -p "$BASE/$REPO"
cd "$BASE/$REPO" || return
curl -s -o release "https://api.github.com/repos/${REPO}/releases/latest"
VERSION=$(grep tag_name release | cut -f4 -d\")
RELEASED=$(grep published_at release | cut -f4 -d\")
echo -e "${BLUE}$REPO${NC} $VERSION - $RELEASED"
for ARCH in x86_64 aarch64; do
CURRENT_VERSION=$(cat "$HOME/Sync/bin/$ARCH/.${BIN}.version" 2>/dev/null)
if [ "$CURRENT_VERSION" = "$VERSION" ] || [ "$CURRENT_VERSION" = "skip" ]; then
SKIPPED="$SKIPPED $ARCH"
continue
fi
if [ "$ARCH" = "x86_64" ]; then SA="x86_64\|amd64\|appimage"; fi
if [ "$ARCH" = "aarch64" ]; then SA="aarch64\|arm64"; fi
grep "download_url" "$BASE/$REPO/release" | grep -i -E "linux|AppImage" | grep -i -e "$SA" | grep -v -E "deb|rpm|apk|sha256|json|blockma|yml|musl|update|asc" | sed -e 's/^.*\(https.*\)".*$/\1/g' | sort | while read -r DOWN
do if [ -n "$DOWN" ]; then
cd "$BASE/$REPO" || return
mkdir $ARCH 2>/dev/null
cd $ARCH || exit
if (echo "$DOWN" | grep -qE "gz$"); then
(curl -L "$DOWN" | tar xfz -) 2>/dev/null
elif (echo "$DOWN" | grep -qE "xz$"); then
(curl -L "$DOWN" | tar xfJ -) 2>/dev/null
elif (echo "$DOWN" | grep -qE "bz2$"); then
(curl -L "$DOWN" | tar xfj -) 2>/dev/null
elif (echo "$DOWN" | grep -qE "tbz$"); then
(curl -L "$DOWN" | tar xfj -) 2>/dev/null
elif (echo "$DOWN" | grep -qE "zip$"); then
(curl -L "$DOWN" >a.zip && unzip -q a.zip) 2>/dev/null
else
(curl -L -o "$BIN" "$DOWN") 2>/dev/null
chmod +x "$BIN"
fi
FILES=$(find . -type f -name "$BIN" | head -1 | sed -e 's/^.\///g')
if [ -n "$FILES" ]; then
echo "$VERSION" >"$HOME/Sync/bin/$ARCH/.${BIN}.version"
echo -e "Grabbed: ${RED}$ARCH${NC}"
mv "$FILES" ~/Sync/bin/$ARCH/
fi
fi
done
done
echo -e "Skipped:${GRAY}$SKIPPED${NC}"
}
BASE=/tmp/gitbin.$$
mkdir $BASE
cd $BASE || exit
if [ -z "$1" ]; then
for BIN in "${!gitbin[@]}"; do
grab_bin "$BIN" ""
done
else
grab_bin "$1" "$1"
fi
rm -rf $BASE
#chmod +x ~/Sync/bin/*/* 2>/dev/null