Snippet-Based Universal Installer (UBI)

Snippet-Based Universal Installer (UBI)

HermitGrab supports snippets that encapsulate common logic. This example shows the universal installer using UBI to simplify binary installs across different tools.

Highlights

  • Centralized Install Logic: UBI install script used in multiple tools.
  • Parameterized: Uses {{ var.exe }}, {{ var.url }} etc.
[snippets]
ubi = """
#!/bin/bash
location=\"$HOME/.local/bin\"
if [ \"{{ var.location }}\" != \"\" ]; then
  location=\"{{ var.location }}\"
fi
exe=\"\"
if [ \"{{ var.exe }}\" != \"\" ]; then
  exe=-e {{ var.exe }}
fi
if [ \"{{ var.url }}\" != \"\" ]; then
  ubi -u {{ var.url }} $exe -i $location
else
  ubi -p {{ var.name }} $exe -i $location
fi
echo \"Installed {{ var.name }} to $location using ubi\"
"""

[[install]]
name = "sharkdp/fd"
check = "command -v fd"
install = "{{ snippet ubi }}"

[install.variables]
exe = "fd"