-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·52 lines (43 loc) · 1.27 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·52 lines (43 loc) · 1.27 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
#!/usr/bin/env bash
set -euo pipefail
BINARY="livemark"
MODULE="github.com/jeziellopes/livemark"
# Check Go is installed
if ! command -v go &>/dev/null; then
echo "error: Go is not installed. Get it at https://go.dev/dl/" >&2
exit 1
fi
echo "Installing $BINARY..."
go install "${MODULE}@latest"
# Resolve where go install puts binaries
GOBIN="$(go env GOPATH)/bin"
if [ -n "$(go env GOBIN)" ]; then
GOBIN="$(go env GOBIN)"
fi
echo "Installed to $GOBIN/$BINARY"
# If GOBIN is not in PATH, add it to the appropriate shell profile
if ! echo "$PATH" | tr ':' '\n' | grep -qx "$GOBIN"; then
# Detect shell profile
case "${SHELL:-}" in
*/zsh) PROFILE="$HOME/.zshrc" ;;
*/bash) PROFILE="$HOME/.bashrc" ;;
*) PROFILE="$HOME/.profile" ;;
esac
EXPORT_LINE="export PATH=\"\$PATH:$GOBIN\""
if ! grep -qF "$GOBIN" "$PROFILE" 2>/dev/null; then
echo "" >> "$PROFILE"
echo "# Added by livemark installer" >> "$PROFILE"
echo "$EXPORT_LINE" >> "$PROFILE"
echo ""
echo " ✅ Added PATH export to $PROFILE"
echo " Run this to apply now:"
echo ""
echo " source $PROFILE"
echo ""
else
echo ""
echo " ℹ️ $GOBIN already referenced in $PROFILE (restart your shell to apply)"
echo ""
fi
fi
echo "Done. Run: $BINARY --help"