wtcode 0.4.0__tar.gz → 0.5.0__tar.gz
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.
- {wtcode-0.4.0/wtcode.egg-info → wtcode-0.5.0}/PKG-INFO +2 -1
- {wtcode-0.4.0 → wtcode-0.5.0}/README.md +1 -0
- {wtcode-0.4.0 → wtcode-0.5.0}/pyproject.toml +1 -1
- {wtcode-0.4.0 → wtcode-0.5.0}/wtcode/__init__.py +1 -1
- {wtcode-0.4.0 → wtcode-0.5.0}/wtcode/wtcode.sh +51 -9
- {wtcode-0.4.0 → wtcode-0.5.0/wtcode.egg-info}/PKG-INFO +2 -1
- {wtcode-0.4.0 → wtcode-0.5.0}/LICENSE +0 -0
- {wtcode-0.4.0 → wtcode-0.5.0}/setup.cfg +0 -0
- {wtcode-0.4.0 → wtcode-0.5.0}/wtcode/__main__.py +0 -0
- {wtcode-0.4.0 → wtcode-0.5.0}/wtcode.egg-info/SOURCES.txt +0 -0
- {wtcode-0.4.0 → wtcode-0.5.0}/wtcode.egg-info/dependency_links.txt +0 -0
- {wtcode-0.4.0 → wtcode-0.5.0}/wtcode.egg-info/entry_points.txt +0 -0
- {wtcode-0.4.0 → wtcode-0.5.0}/wtcode.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: wtcode
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.5.0
|
|
4
4
|
Summary: Launch your favorite code tool in a git worktree
|
|
5
5
|
Author-email: Jaeho Shin <netj@sparcs.org>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -82,6 +82,7 @@ WTCODE_CMD=cursor wtcode feature # use cursor as default tool
|
|
|
82
82
|
| Variable | Description |
|
|
83
83
|
|---|---|
|
|
84
84
|
| `WTCODE_CMD` | Default tool to launch (e.g., `claude`, `lazygit`, `vim`, `cursor`) |
|
|
85
|
+
| `WTCODE_USE_CURRENT_BRANCH` | When creating a brand-new branch, fork it from the current HEAD instead of the default: `origin/HEAD` (falling back to `origin/main`, then `origin/master`) |
|
|
85
86
|
| `WTCODE_DEBUG` | Enable debug tracing when set to any value |
|
|
86
87
|
| `GIT_WORKTREE_ROOT` | Override the directory where worktrees are created |
|
|
87
88
|
|
|
@@ -64,6 +64,7 @@ WTCODE_CMD=cursor wtcode feature # use cursor as default tool
|
|
|
64
64
|
| Variable | Description |
|
|
65
65
|
|---|---|
|
|
66
66
|
| `WTCODE_CMD` | Default tool to launch (e.g., `claude`, `lazygit`, `vim`, `cursor`) |
|
|
67
|
+
| `WTCODE_USE_CURRENT_BRANCH` | When creating a brand-new branch, fork it from the current HEAD instead of the default: `origin/HEAD` (falling back to `origin/main`, then `origin/master`) |
|
|
67
68
|
| `WTCODE_DEBUG` | Enable debug tracing when set to any value |
|
|
68
69
|
| `GIT_WORKTREE_ROOT` | Override the directory where worktrees are created |
|
|
69
70
|
|
|
@@ -5,6 +5,14 @@
|
|
|
5
5
|
# Created: 2026-02-03
|
|
6
6
|
set -eu
|
|
7
7
|
shopt -s extglob
|
|
8
|
+
|
|
9
|
+
# declare all WTCODE_* env vars and their defaults in one place
|
|
10
|
+
: ${WTCODE_CMD:=}
|
|
11
|
+
: ${WTCODE_USE_CURRENT_BRANCH:=false}
|
|
12
|
+
: ${WTCODE_TMUX_MODE:=send-keys}
|
|
13
|
+
: ${WTCODE_TERMINAL_MODE:=send-keys}
|
|
14
|
+
: ${WTCODE_DEBUG:=}
|
|
15
|
+
|
|
8
16
|
${WTCODE_DEBUG:+set -x}
|
|
9
17
|
|
|
10
18
|
--msg() { echo "wtcode: $*" >&2; }
|
|
@@ -20,7 +28,7 @@ ${WTCODE_DEBUG:+set -x}
|
|
|
20
28
|
sed 's/^-//; s/-$//' # trim leading/trailing hyphens
|
|
21
29
|
}
|
|
22
30
|
|
|
23
|
-
WTCODE_VERSION=0.
|
|
31
|
+
WTCODE_VERSION=0.5.0
|
|
24
32
|
--version() { echo "wtcode $WTCODE_VERSION"; }
|
|
25
33
|
--help() {
|
|
26
34
|
cat <<USAGE
|
|
@@ -42,6 +50,10 @@ Usage: wtcode [BRANCH] [CMD [CMD-ARGS...]]
|
|
|
42
50
|
|
|
43
51
|
Environment variables:
|
|
44
52
|
WTCODE_CMD Default tool to launch (e.g., claude, lazygit, vim)
|
|
53
|
+
WTCODE_USE_CURRENT_BRANCH
|
|
54
|
+
When creating a brand-new branch, fork it from the
|
|
55
|
+
current HEAD instead of the default: origin/HEAD
|
|
56
|
+
(falling back to origin/main, then origin/master)
|
|
45
57
|
WTCODE_TMUX_MODE When in tmux, control how the tool is launched:
|
|
46
58
|
send-keys - send command to current pane (default in tmux)
|
|
47
59
|
split-window - create split pane with send-keys
|
|
@@ -68,12 +80,33 @@ USAGE
|
|
|
68
80
|
|
|
69
81
|
# commands to try as default, in order of preference
|
|
70
82
|
WTCODE_CMDS_TO_TRY=(
|
|
71
|
-
$
|
|
83
|
+
$WTCODE_CMD
|
|
72
84
|
claude
|
|
73
85
|
aider
|
|
74
86
|
codex
|
|
75
87
|
)
|
|
76
88
|
|
|
89
|
+
###############################################################################
|
|
90
|
+
## --default-base-ref -- ref to fork a brand-new branch from
|
|
91
|
+
###############################################################################
|
|
92
|
+
# defaults to origin/HEAD (falling back to origin/main, then origin/master),
|
|
93
|
+
# so new worktrees start from the repo's default branch instead of whatever
|
|
94
|
+
# happens to be checked out where wtcode was invoked. set
|
|
95
|
+
# WTCODE_USE_CURRENT_BRANCH=true to restore the old behavior of forking from
|
|
96
|
+
# the current HEAD. only consults local remote-tracking refs -- never
|
|
97
|
+
# touches the network.
|
|
98
|
+
--default-base-ref() {
|
|
99
|
+
if [[ $WTCODE_USE_CURRENT_BRANCH == true ]]; then
|
|
100
|
+
git rev-parse HEAD
|
|
101
|
+
return
|
|
102
|
+
fi
|
|
103
|
+
local ref
|
|
104
|
+
for ref in origin/HEAD origin/main origin/master; do
|
|
105
|
+
git rev-parse --verify -q "$ref" &>/dev/null && { echo "$ref"; return; }
|
|
106
|
+
done
|
|
107
|
+
git rev-parse HEAD
|
|
108
|
+
}
|
|
109
|
+
|
|
77
110
|
###############################################################################
|
|
78
111
|
## --enter-git-worktree -- select branch and create/switch worktree
|
|
79
112
|
###############################################################################
|
|
@@ -129,9 +162,13 @@ WTCODE_CMDS_TO_TRY=(
|
|
|
129
162
|
printf '%s\t%s %s\t%s %s %s%s\n' \
|
|
130
163
|
"$branch" "$ind" "$name_shown" "$date_shown" "$hash_shown" "$upstream_shown" "$subject"
|
|
131
164
|
done |
|
|
132
|
-
fzf --ansi --color --tmux --print-query --delimiter=$'\t' --with-nth=2 --nth=1 \
|
|
165
|
+
fzf --ansi --color --tmux 90%,70% --print-query --delimiter=$'\t' --with-nth=2 --nth=1 \
|
|
133
166
|
--preview 'echo {3}' --preview-window 'down:2:wrap' \
|
|
134
|
-
--
|
|
167
|
+
--header "$(
|
|
168
|
+
echo '[wtcode] Select the worktree/branch or create new to launch your code tool in it.'
|
|
169
|
+
echo ' Typing colons `:` avoids selecting an existing one to create new with similar names.'
|
|
170
|
+
)" \
|
|
171
|
+
--prompt '> ' |
|
|
135
172
|
cut -f1 |
|
|
136
173
|
tail -1
|
|
137
174
|
)
|
|
@@ -230,9 +267,14 @@ WTCODE_CMDS_TO_TRY=(
|
|
|
230
267
|
--msg "creating worktree for branch: $branch_name"
|
|
231
268
|
git worktree add -B "$branch_name" "$worktree_path" "$(git rev-parse "$branch_name")"
|
|
232
269
|
else
|
|
233
|
-
# fork
|
|
234
|
-
|
|
235
|
-
|
|
270
|
+
# fork a base ref and create the new worktree: defaults to origin/HEAD
|
|
271
|
+
# (falling back to origin/main, origin/master, then the current HEAD);
|
|
272
|
+
# set WTCODE_USE_CURRENT_BRANCH=true to always fork from the current
|
|
273
|
+
# branch instead
|
|
274
|
+
local base_ref
|
|
275
|
+
base_ref=$(--default-base-ref)
|
|
276
|
+
--msg "creating worktree with new branch: $branch_name (from $base_ref)"
|
|
277
|
+
git worktree add -b "$branch_name" "$worktree_path" "$base_ref"
|
|
236
278
|
fi
|
|
237
279
|
cd "$worktree_path"
|
|
238
280
|
|
|
@@ -446,7 +488,7 @@ APPLESCRIPT
|
|
|
446
488
|
# when inside tmux, default to send-keys for command history access
|
|
447
489
|
# set WTCODE_TMUX_MODE=exec to opt out and exec directly
|
|
448
490
|
if [[ -n ${TMUX:-} ]] && type tmux &>/dev/null; then
|
|
449
|
-
local mode=$
|
|
491
|
+
local mode=$WTCODE_TMUX_MODE
|
|
450
492
|
|
|
451
493
|
case $mode in
|
|
452
494
|
send-keys|split-window|new-window)
|
|
@@ -485,7 +527,7 @@ APPLESCRIPT
|
|
|
485
527
|
# outside tmux: reuse the current tab/window if the terminal app supports
|
|
486
528
|
# it (see --terminal-send-keys). set WTCODE_TERMINAL_MODE=exec to opt out
|
|
487
529
|
if [[ -z ${TMUX:-} ]]; then
|
|
488
|
-
local mode=$
|
|
530
|
+
local mode=$WTCODE_TERMINAL_MODE
|
|
489
531
|
case $mode in
|
|
490
532
|
send-keys)
|
|
491
533
|
if --terminal-send-keys "$@"; then
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: wtcode
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.5.0
|
|
4
4
|
Summary: Launch your favorite code tool in a git worktree
|
|
5
5
|
Author-email: Jaeho Shin <netj@sparcs.org>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -82,6 +82,7 @@ WTCODE_CMD=cursor wtcode feature # use cursor as default tool
|
|
|
82
82
|
| Variable | Description |
|
|
83
83
|
|---|---|
|
|
84
84
|
| `WTCODE_CMD` | Default tool to launch (e.g., `claude`, `lazygit`, `vim`, `cursor`) |
|
|
85
|
+
| `WTCODE_USE_CURRENT_BRANCH` | When creating a brand-new branch, fork it from the current HEAD instead of the default: `origin/HEAD` (falling back to `origin/main`, then `origin/master`) |
|
|
85
86
|
| `WTCODE_DEBUG` | Enable debug tracing when set to any value |
|
|
86
87
|
| `GIT_WORKTREE_ROOT` | Override the directory where worktrees are created |
|
|
87
88
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|