Skip to content

Instantly share code, notes, and snippets.

@scturtle
Created April 22, 2026 02:12
Show Gist options
  • Select an option

  • Save scturtle/22c9ac5b1297683d7aa9e56d3f41524d to your computer and use it in GitHub Desktop.

Select an option

Save scturtle/22c9ac5b1297683d7aa9e56d3f41524d to your computer and use it in GitHub Desktop.
#!/usr/bin/env fish
function check_var -a var msg
if test -z $var; echo $msg >&2; exit 1; end
end
function check_status -a msg
if test $status != 0; echo $msg >&2; exit 1; end
end
function check_file -a file
if not test -e $file; echo "$file not found" >&2; exit 1; end
end
function get_file -a repo pattern
set -l ver (curl -s "https://github.com/$repo/releases" | grep 'releases/tag' |\
string match -rg 'releases/tag/(.*?)"' | sed 's/%2F/-/g' | head -1)
check_var "$ver" "$repo version not found"
echo "found $repo version" $ver >&2
set -l filename (curl -s "https://github.com/$repo/releases/expanded_assets/$ver" |\
string match -rg "($pattern)" | head -1)
check_var "$filename" "$repo $ver $pattern not found"
echo "found $filename" >&2
if not test -e $filename
curl -s -OL "https://github.com/$repo/releases/download/$ver/$filename"
end
echo $filename
end
set -l BTOP_TBZ (get_file 'aristocratos/btop' 'btop-x86_64-unknown-linux-musl.tbz')
tar xf $BTOP_TBZ
check_status "$BTOP_TBZ unzip failed"
check_file "btop/bin/btop"
cp btop/bin/btop ~/.local/bin/btop
set -l FD_TGZ (get_file 'sharkdp/fd' 'fd-.*-x86_64-unknown-linux-musl.tar.gz')
tar xf $FD_TGZ
check_status "$FD_TGZ unzip failed"
check_file fd-*-x86_64-unknown-linux-musl/fd
cp fd-*-x86_64-unknown-linux-musl/fd ~/.local/bin/fd
set -l GDU_TGZ (get_file 'dundee/gdu' 'gdu_linux_amd64_static.tgz')
tar xf $GDU_TGZ
check_status "$GDU_TGZ unzip failed"
check_file gdu_linux_amd64_static
cp gdu_linux_amd64_static ~/.local/bin/gdu
set -l RG_TGZ (get_file 'BurntSushi/ripgrep' 'ripgrep-.*-x86_64-unknown-linux-musl.tar.gz')
tar xf $RG_TGZ
check_status "$RG_TGZ unzip failed"
check_file ripgrep-*-x86_64-unknown-linux-musl/rg
cp ripgrep-*-x86_64-unknown-linux-musl/rg ~/.local/bin/rg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment