-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·142 lines (106 loc) · 4.92 KB
/
install.sh
File metadata and controls
executable file
·142 lines (106 loc) · 4.92 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#!/usr/bin/env bash
# werksfeer installer
# Usage: curl -fsSL https://raw.githubusercontent.com/DefactoSoftware/werksfeer/main/install.sh | sh
set -euo pipefail
REPO="DefactoSoftware/werksfeer"
BRANCH="main"
BASE_URL="https://raw.githubusercontent.com/${REPO}/${BRANCH}"
echo "Installing werksfeer..."
# Determine install directory
if [ -w "/usr/local/bin" ]; then
INSTALL_DIR="/usr/local/bin"
else
INSTALL_DIR="${HOME}/.local/bin"
mkdir -p "$INSTALL_DIR"
fi
# Download main script
curl -fsSL "${BASE_URL}/werksfeer" -o "${INSTALL_DIR}/werksfeer"
chmod +x "${INSTALL_DIR}/werksfeer"
# Download hook template
HOOKS_DIR="${XDG_DATA_HOME:-$HOME/.local/share}/werksfeer/hooks"
mkdir -p "$HOOKS_DIR"
curl -fsSL "${BASE_URL}/hooks/post-checkout" -o "${HOOKS_DIR}/post-checkout"
chmod +x "${HOOKS_DIR}/post-checkout"
echo ""
echo "Installed werksfeer to ${INSTALL_DIR}/werksfeer"
echo "Hook template at ${HOOKS_DIR}/post-checkout"
echo ""
# PATH check
if ! echo "$PATH" | tr ':' '\n' | grep -qxF "$INSTALL_DIR"; then
echo "NOTE: ${INSTALL_DIR} is not in your PATH. Add it:"
echo ""
echo " # bash/zsh"
echo " export PATH=\"${INSTALL_DIR}:\$PATH\""
echo ""
echo " # fish"
echo " fish_add_path ${INSTALL_DIR}"
echo ""
fi
cat <<EOF
Next, add a .worktree.toml to your project root (can be empty for auto-detection):
touch .worktree.toml
Then set up werksfeer for your workflow. Pick one:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
GIT HOOKS — runs automatically on worktree creation (wt switch -c / git worktree add)
# Global (all repos — replaces per-repo hooks):
git config --global core.hooksPath ${HOOKS_DIR}
# Single repo:
cp ${HOOKS_DIR}/post-checkout /path/to/repo/.git/hooks/
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
CLAUDE CODE / CLAUDE DESKTOP — add to .claude/settings.json:
{
"hooks": {
"WorktreeCreate": [
{
"hooks": [
{
"type": "command",
"command": "bash -c 'set -e; NAME=\$(cat | jq -r .name); DIR=\"\$CLAUDE_PROJECT_DIR/.worktrees/\$NAME\"; git worktree add \"\$DIR\" --detach HEAD >&2; cd \"\$DIR\" && werksfeer >&2; echo \"\$DIR\"'"
}
]
}
],
"WorktreeRemove": [
{
"hooks": [
{
"type": "command",
"command": "bash -c 'cat | jq -r .worktree_path | xargs werksfeer --cleanup'"
}
]
}
]
}
}
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
CODEX APP — create .codex/setup.sh:
#!/usr/bin/env bash
werksfeer
Then select it as your Local Environment setup script in the Codex app.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
CURSOR — add to .cursor/worktrees.json:
{
"setup-worktree": [
"werksfeer"
]
}
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
WORKTRUNK (recommended) — better CLI for worktree management:
# Install: https://github.com/max-sixty/worktrunk
wt switch -c my-feature # create & switch
wt switch -x claude -c feat -- 'prompt' # launch agent in worktree
wt remove # clean up
With git hooks configured, werksfeer runs automatically on wt switch -c.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
OTHER AGENTS — run after worktree creation:
wt switch -c my-feature
werksfeer
Or with plain git:
git worktree add ../my-feature feature-branch
cd ../my-feature
werksfeer
If your agent supports post-worktree hooks or setup scripts,
point them at "werksfeer". It is idempotent and runs unattended.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
See https://github.com/DefactoSoftware/werksfeer for full documentation.
EOF