-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·103 lines (81 loc) · 4.17 KB
/
install.sh
File metadata and controls
executable file
·103 lines (81 loc) · 4.17 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
#!/usr/bin/env sh
# tai install/update script
# Downloads the latest tai binary from GitHub Releases and installs it to
# ~/.local/share/tai/tai.
set -eu
REPO="NitorCreations/tai"
INSTALL_DIR="${HOME}/.local/share/tai"
BINARY_NAME="tai"
# ── helpers ──────────────────────────────────────────────────────────────────
die() { printf 'error: %s\n' "$*" >&2; exit 1; }
need() {
command -v "$1" >/dev/null 2>&1 || die "'$1' is required but not found"
}
# ── detect OS and arch ───────────────────────────────────────────────────────
detect_os() {
case "$(uname -s)" in
Linux) echo "linux" ;;
Darwin) echo "darwin" ;;
*) die "unsupported OS: $(uname -s)" ;;
esac
}
detect_arch() {
case "$(uname -m)" in
x86_64|amd64) echo "amd64" ;;
aarch64|arm64|armv8*) echo "arm64" ;;
*) die "unsupported architecture: $(uname -m)" ;;
esac
}
# ── fetch latest release tag from GitHub API ─────────────────────────────────
latest_version() {
need curl
url="https://api.github.com/repos/${REPO}/releases/latest"
version=$(curl -fsSL "$url" | grep '"tag_name":' | sed 's/.*"tag_name":[ ]*"\([^"]*\)".*/\1/')
[ -n "$version" ] || die "could not determine latest version from GitHub API"
echo "$version"
}
# ── main ──────────────────────────────────────────────────────────────────────
need curl
need tar
OS=$(detect_os)
ARCH=$(detect_arch)
VERSION=$(latest_version)
# goreleaser archive name template: tai_VERSION_OS_ARCH.tar.gz (version without "v" prefix)
ARCHIVE="tai_${VERSION#v}_${OS}_${ARCH}.tar.gz"
DOWNLOAD_URL="https://github.com/${REPO}/releases/download/${VERSION}/${ARCHIVE}"
printf 'Installing tai %s (%s/%s)...\n' "$VERSION" "$OS" "$ARCH"
# ── download and extract ──────────────────────────────────────────────────────
TMP=$(mktemp -d)
trap 'rm -rf "$TMP"' EXIT
printf 'Downloading %s\n' "$DOWNLOAD_URL"
curl -fsSL "$DOWNLOAD_URL" -o "${TMP}/${ARCHIVE}"
tar -xzf "${TMP}/${ARCHIVE}" -C "$TMP" "$BINARY_NAME"
# ── install binary ────────────────────────────────────────────────────────────
mkdir -p "$INSTALL_DIR"
cp "${TMP}/${BINARY_NAME}" "${INSTALL_DIR}/${BINARY_NAME}"
chmod 755 "${INSTALL_DIR}/${BINARY_NAME}"
# ── done ──────────────────────────────────────────────────────────────────────
printf '\ntai %s installed to %s\n' "$VERSION" "${INSTALL_DIR}/${BINARY_NAME}"
printf '\n'
printf 'Next steps:\n'
printf '\n'
printf ' 1. Add tai to your PATH:\n'
printf ' export PATH="%s:$PATH"\n' "$INSTALL_DIR"
printf ' Add this line to ~/.bashrc or ~/.zshrc to make it permanent.\n'
printf '\n'
printf ' 2. Load shell keybinding widget (optional):\n'
printf ' Adds _tai_widget to your shell and binds it to Ctrl+T.\n'
printf ' It lets you select a command interactively and inject it into your prompt.\n'
printf '\n'
printf ' To load in the current shell:\n'
printf ' eval "$(tai widget bash)" # or: tai widget zsh\n'
printf ' To persist across sessions, add the same line to ~/.bashrc or ~/.zshrc.\n'
printf '\n'
printf ' 3. Enable tab completions (optional):\n'
printf '\n'
printf ' To load in the current shell:\n'
printf ' eval "$(tai completion bash)" # or: tai completion zsh\n'
printf ' To persist across sessions, add the same line to ~/.bashrc or ~/.zshrc.\n'
printf '\n'
printf ' 4. Reload your shell (only needed if you edited ~/.bashrc or ~/.zshrc):\n'
printf ' exec $SHELL\n'