-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·65 lines (55 loc) · 1.74 KB
/
install.sh
File metadata and controls
executable file
·65 lines (55 loc) · 1.74 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
#!/usr/bin/env bash
# mxkey skill — one-time setup
#
# Symlinks the bundled `mxkey` script into ~/.local/bin/ so it's on PATH.
# Idempotent: safe to re-run. Does nothing if `mxkey` is already available.
set -euo pipefail
if [[ "$(uname)" != "Darwin" ]]; then
echo "mxkey requires macOS. Current OS: $(uname)" >&2
exit 1
fi
# Resolve the bundled mxkey binary (alongside this script in the repo root).
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
BUNDLED="$SCRIPT_DIR/mxkey"
if [[ ! -f "$BUNDLED" ]]; then
echo "error: expected bundled mxkey at $BUNDLED — is the skill installed?" >&2
exit 1
fi
# Make it executable (in case the tarball didn't preserve perms).
chmod +x "$BUNDLED"
# Already on PATH?
if command -v mxkey >/dev/null 2>&1; then
existing="$(command -v mxkey)"
if [[ "$(readlink "$existing" 2>/dev/null || echo "$existing")" == "$BUNDLED" ]]; then
echo "mxkey already set up at $existing" >&2
else
echo "mxkey is already on PATH at: $existing" >&2
echo "(bundled copy at $BUNDLED not linked — not overwriting)" >&2
fi
exit 0
fi
# Ensure ~/.local/bin exists.
LOCAL_BIN="$HOME/.local/bin"
mkdir -p "$LOCAL_BIN"
# Symlink.
ln -sf "$BUNDLED" "$LOCAL_BIN/mxkey"
echo "linked $LOCAL_BIN/mxkey -> $BUNDLED" >&2
# Verify PATH includes ~/.local/bin.
case ":$PATH:" in
*":$LOCAL_BIN:"*)
echo "$LOCAL_BIN is on PATH — you're good." >&2
;;
*)
echo "" >&2
echo "WARNING: $LOCAL_BIN is not on PATH." >&2
echo "Add this to your shell rc (~/.zshrc or ~/.bashrc):" >&2
echo "" >&2
echo " export PATH=\"\$HOME/.local/bin:\$PATH\"" >&2
echo "" >&2
echo "Then reload: source ~/.zshrc" >&2
;;
esac
# Sanity check.
if "$BUNDLED" list >/dev/null 2>&1; then
echo "mxkey ready." >&2
fi