-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap-machine
More file actions
executable file
·65 lines (53 loc) · 2.04 KB
/
Copy pathbootstrap-machine
File metadata and controls
executable file
·65 lines (53 loc) · 2.04 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
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# shellcheck source=lib/worktree-common.sh
source "$SCRIPT_DIR/lib/worktree-common.sh"
target_bin_dir="${1:-$HOME/.local/bin}"
wt_config="$(worktrunk_config_path)"
wt_config_dir="$(dirname "$wt_config")"
expected_path="$(expected_worktrunk_worktree_path)"
"$SCRIPT_DIR/install-global-tools" "$target_bin_dir"
case ":$PATH:" in
*":$target_bin_dir:"*)
printf 'PATH already includes %s\n' "$target_bin_dir"
;;
*)
printf '\nAdd this line to your shell config if needed:\n\n'
printf 'export PATH="%s:$PATH"\n' "$target_bin_dir"
printf '\nThen reload your shell, for example:\n\n'
printf 'source ~/.zshrc\n'
;;
esac
if ! command -v wt >/dev/null 2>&1; then
printf '\nWorktrunk is not installed. Install it first, then re-run this command.\n\n'
printf 'Recommended on macOS/Linux with Homebrew:\n'
printf ' brew install worktrunk\n'
printf '\nAfter install, re-run:\n'
printf ' ./bootstrap-machine %s\n' "$target_bin_dir"
exit 0
fi
printf '\nConfiguring Worktrunk shell integration...\n'
wt config shell install || true
mkdir -p "$wt_config_dir"
if [[ ! -f "$wt_config" ]]; then
printf 'Creating Worktrunk user config...\n'
wt config create >/dev/null 2>&1 || true
fi
touch "$wt_config"
if grep -Eq '^[[:space:]]*worktree-path[[:space:]]*=' "$wt_config"; then
perl -0pi -e 's#^[[:space:]]*worktree-path[[:space:]]*=.*$#worktree-path = "'"$expected_path"'"#m' "$wt_config"
else
printf '\nworktree-path = "%s"\n' "$expected_path" >> "$wt_config"
fi
printf 'Worktrunk user config: %s\n' "$wt_config"
printf 'Configured worktree-path for Rootwork layout.\n'
printf 'Managed line:\n'
printf ' worktree-path = "%s"\n' "$expected_path"
printf '\nFinal checks:\n'
printf ' 1. Restart your shell\n'
printf ' 2. Run: type wt\n'
printf ' 3. Run: rwt doctor\n'
printf ' 4. Run Worktrunk from the real repo, for example:\n'
printf ' cd ~/Projects/<ProjectName>/repos/<ProjectName>\n'
printf ' wt switch --create feature/test\n'