-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·110 lines (100 loc) · 4.84 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·110 lines (100 loc) · 4.84 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
104
105
106
107
108
109
110
#!/bin/bash
# Dotfiles install script - runs automatically in GitHub Codespaces
# and can be run manually on any machine.
set -e
DOTFILES_DIR="$(cd "$(dirname "$0")" && pwd)"
# Symlink copilot instructions for Copilot CLI
if [ -f "$DOTFILES_DIR/.github/copilot-instructions.md" ]; then
mkdir -p "$HOME/.copilot"
ln -sf "$DOTFILES_DIR/.github/copilot-instructions.md" "$HOME/.copilot/copilot-instructions.md"
echo "✓ Linked copilot-instructions.md → ~/.copilot/copilot-instructions.md"
fi
# Symlink user-scope Copilot CLI skills so they auto-load on every session.
if [ -d "$DOTFILES_DIR/.copilot/skills" ]; then
mkdir -p "$HOME/.copilot/skills"
for skill_path in "$DOTFILES_DIR/.copilot/skills/"*/; do
[ -d "$skill_path" ] || continue
skill_name="$(basename "$skill_path")"
target="$HOME/.copilot/skills/$skill_name"
if [ -L "$target" ] || [ ! -e "$target" ]; then
ln -sfn "$skill_path" "$target"
echo "✓ Linked skill $skill_name → $target"
else
echo "⚠ $target exists and is not a symlink - skipping"
fi
done
fi
# Install gh guard wrapper as a PATH shim at ~/.local/bin/gh.
# Guards both `gh pr ready` and `gh pr create` against accidental/unreviewed runs.
if [ -x "$DOTFILES_DIR/bin/gh-guard" ]; then
mkdir -p "$HOME/.local/bin"
GH_TARGET="$HOME/.local/bin/gh"
if [ -L "$GH_TARGET" ] || [ ! -e "$GH_TARGET" ]; then
ln -sfn "$DOTFILES_DIR/bin/gh-guard" "$GH_TARGET"
echo "✓ Linked gh wrapper → ~/.local/bin/gh (intercepts 'gh pr ready' and 'gh pr create')"
else
echo "⚠ $GH_TARGET exists and is not a symlink - skipping gh wrapper install"
echo " Move or remove the existing file and re-run install.sh to enable the guard."
fi
# Ensure ~/.local/bin is on PATH ahead of /opt/homebrew/bin so the wrapper wins
# over the real gh binary. Cover both zsh (macOS default) and bash (Codespaces,
# Linux). brew shellenv (in .zprofile) prepends /opt/homebrew/bin, so we add
# our own prepend AFTER brew runs.
PATH_LINE='export PATH="$HOME/.local/bin:$PATH" # dotfiles: gh wrapper'
for shell_rc in "$HOME/.zprofile" "$HOME/.profile" "$HOME/.bashrc"; do
rc_short="${shell_rc/#$HOME/~}"
if [ -f "$shell_rc" ] && grep -q "dotfiles: gh wrapper" "$shell_rc"; then
echo "✓ PATH for gh wrapper already in $rc_short"
else
printf '\n%s\n' "$PATH_LINE" >> "$shell_rc"
echo "✓ Appended PATH for gh wrapper to $rc_short (open a new shell to apply)"
fi
done
fi
# Install pr-marker helper as a PATH shim at ~/.local/bin/pr-marker.
# Writes the per-branch plan/code/demo/PR-description/tests markers that the
# gh-guard `gh pr create` gate checks, keeping the path encoding in one place.
if [ -x "$DOTFILES_DIR/bin/pr-marker" ]; then
mkdir -p "$HOME/.local/bin"
PR_MARKER_TARGET="$HOME/.local/bin/pr-marker"
if [ -L "$PR_MARKER_TARGET" ] || [ ! -e "$PR_MARKER_TARGET" ]; then
ln -sfn "$DOTFILES_DIR/bin/pr-marker" "$PR_MARKER_TARGET"
echo "✓ Linked pr-marker → ~/.local/bin/pr-marker"
else
echo "⚠ $PR_MARKER_TARGET exists and is not a symlink - skipping"
fi
fi
# Install notification-triage launchd agent (macOS only).
# The wrapper itself goes in ~/.local/bin so it stays on PATH for ad-hoc runs,
# and the plist gets symlinked into ~/Library/LaunchAgents so launchctl can
# pick it up on a cron-like schedule (every 2h, 08:00-18:00, Mon-Fri).
TRIAGE_WRAPPER="$DOTFILES_DIR/bin/notification-triage"
TRIAGE_PLIST="$DOTFILES_DIR/LaunchAgents/com.zkoppert.notification-triage.plist"
if [ -x "$TRIAGE_WRAPPER" ] && [ "$(uname)" = "Darwin" ]; then
mkdir -p "$HOME/.local/bin"
TRIAGE_BIN_TARGET="$HOME/.local/bin/notification-triage"
if [ -L "$TRIAGE_BIN_TARGET" ] || [ ! -e "$TRIAGE_BIN_TARGET" ]; then
ln -sfn "$TRIAGE_WRAPPER" "$TRIAGE_BIN_TARGET"
echo "✓ Linked notification-triage → ~/.local/bin/notification-triage"
else
echo "⚠ $TRIAGE_BIN_TARGET exists and is not a symlink - skipping"
fi
if [ -f "$TRIAGE_PLIST" ]; then
mkdir -p "$HOME/Library/LaunchAgents" "$HOME/Library/Logs"
PLIST_TARGET="$HOME/Library/LaunchAgents/com.zkoppert.notification-triage.plist"
if [ -L "$PLIST_TARGET" ] || [ ! -e "$PLIST_TARGET" ]; then
# launchctl bootstrap (modern) or load -w (legacy) both work fine here;
# unload first so re-runs are consistent (no error if it isn't loaded).
launchctl unload "$PLIST_TARGET" >/dev/null 2>&1 || true
ln -sfn "$TRIAGE_PLIST" "$PLIST_TARGET"
if launchctl load "$PLIST_TARGET" 2>/dev/null; then
echo "✓ Loaded launchd agent com.zkoppert.notification-triage"
else
echo "⚠ launchctl load failed for $PLIST_TARGET - check 'launchctl error' and ~/Library/Logs/notification-triage.log"
fi
else
echo "⚠ $PLIST_TARGET exists and is not a symlink - skipping (delete it manually if you want the dotfiles version)"
fi
fi
fi
echo "Dotfiles install complete."