-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
74 lines (60 loc) · 1.92 KB
/
Copy pathinstall.sh
File metadata and controls
74 lines (60 loc) · 1.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
#!/bin/bash
# Usage: curl -fsSL https://raw.githubusercontent.com/opengiver/wt-cli/main/install.sh | bash
set -e
REPO="opengiver/wt-cli"
INSTALL_DIR="$HOME/.local/bin"
echo "🚀 Installing wt-cli..."
mkdir -p "$INSTALL_DIR"
curl -fsSL "https://raw.githubusercontent.com/$REPO/main/bin/wt" -o "$INSTALL_DIR/wt"
curl -fsSL "https://raw.githubusercontent.com/$REPO/main/bin/wtf" -o "$INSTALL_DIR/wtf"
chmod +x "$INSTALL_DIR/wt" "$INSTALL_DIR/wtf"
SHELL_INTEGRATION='
# wt-cli (DO NOT EDIT)
wt() {
if [[ "$1" == "cd" ]] && [[ -n "$2" ]]; then
local target_dir
target_dir=$(command wt cd "$2" 2>/dev/null)
if [[ -n "$target_dir" ]] && [[ -d "$target_dir" ]]; then
cd "$target_dir"
else
command wt cd "$2"
fi
else
command wt "$@"
fi
}
# wt-cli end'
install_shell_integration() {
local rc_file="$1"
if [[ -f "$rc_file" ]] && grep -q "wt-cli (DO NOT EDIT)" "$rc_file" 2>/dev/null; then
echo " ⏭️ Shell integration already in $rc_file"
return 0
fi
echo "$SHELL_INTEGRATION" >> "$rc_file"
echo " ✅ Added shell integration to $rc_file"
}
echo ""
echo "📦 Installing shell integration..."
if [[ -n "$ZSH_VERSION" ]] || [[ "$SHELL" == *"zsh"* ]]; then
install_shell_integration "$HOME/.zshrc"
elif [[ -n "$BASH_VERSION" ]] || [[ "$SHELL" == *"bash"* ]]; then
install_shell_integration "$HOME/.bashrc"
else
[[ -f "$HOME/.zshrc" ]] && install_shell_integration "$HOME/.zshrc"
[[ -f "$HOME/.bashrc" ]] && install_shell_integration "$HOME/.bashrc"
fi
if [[ ":$PATH:" != *":$INSTALL_DIR:"* ]]; then
echo ""
echo "⚠️ $INSTALL_DIR is not in PATH"
echo " Add to ~/.zshrc or ~/.bashrc:"
echo " export PATH=\"\$HOME/.local/bin:\$PATH\""
fi
echo ""
echo "✅ Installation complete!"
echo ""
echo "⚡ Restart terminal or: source ~/.zshrc"
echo ""
echo "Usage:"
echo " wt ls List worktrees"
echo " wt cd <name> Change to worktree"
echo " wt help Show help"