@jswork/ushell-module-git 1.0.69 → 1.0.71
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/modules/16-wt.sh +2 -53
- package/package.json +1 -1
package/modules/16-wt.sh
CHANGED
|
@@ -1,56 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
|
|
3
|
-
# wtt
|
|
4
|
-
# https://github.com/yourusername/worktree-cli
|
|
3
|
+
# wtt - Git Worktree 快速切换工具
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
if command -v wt >/dev/null 2>&1; then
|
|
8
|
-
|
|
9
|
-
# Find the actual wt binary path
|
|
10
|
-
WT_BIN=$(command -v wt)
|
|
11
|
-
|
|
12
|
-
# 🚀 wt/wtt function for true directory switching
|
|
13
|
-
# wt and wtt (worktree-tool) provide directory switching without conflicting with wt binary
|
|
14
|
-
wt() {
|
|
15
|
-
_wt_impl "$@"
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
wtt() {
|
|
19
|
-
_wt_impl "$@"
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
_wt_impl() {
|
|
23
|
-
case "$1" in
|
|
24
|
-
switch|co)
|
|
25
|
-
# Handle switch/co commands for true directory switching
|
|
26
|
-
shift
|
|
27
|
-
local wt_cli="$WT_BIN" # Use the actual binary path
|
|
28
|
-
|
|
29
|
-
# Get the path from wt switch command
|
|
30
|
-
local path
|
|
31
|
-
path=$($wt_cli switch "$@" 2>/dev/null)
|
|
32
|
-
|
|
33
|
-
# Check if we got a valid path (absolute path starts with /)
|
|
34
|
-
if [[ "$path" = /* ]] && [[ -d "$path" ]]; then
|
|
35
|
-
cd "$path" || return 1
|
|
36
|
-
echo "✅ Switched to: $path"
|
|
37
|
-
else
|
|
38
|
-
# Let the original command handle errors and display
|
|
39
|
-
$wt_cli switch "$@"
|
|
40
|
-
fi
|
|
41
|
-
;;
|
|
42
|
-
*)
|
|
43
|
-
# Pass all other commands to wt binary (use full path to avoid recursion)
|
|
44
|
-
"$WT_BIN" "$@"
|
|
45
|
-
;;
|
|
46
|
-
esac
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
else
|
|
50
|
-
# wt binary not found - show installation message once
|
|
51
|
-
if [[ -z "$WTT_SHOWN_MISSING" ]]; then
|
|
52
|
-
echo "⚠️ wt CLI not found in PATH"
|
|
53
|
-
echo "Install: go build -o wt main.go && sudo mv wt /usr/local/bin/wt"
|
|
54
|
-
export WTT_SHOWN_MISSING=1
|
|
55
|
-
fi
|
|
56
|
-
fi
|
|
5
|
+
alias wtt="wt co && source ~/.config/wt/boot.sh"
|