wtcode 0.1.1__tar.gz → 0.1.3__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.1.1/wtcode.egg-info → wtcode-0.1.3}/PKG-INFO +12 -5
- {wtcode-0.1.1 → wtcode-0.1.3}/README.md +11 -4
- {wtcode-0.1.1 → wtcode-0.1.3}/pyproject.toml +1 -1
- {wtcode-0.1.1 → wtcode-0.1.3}/wtcode/__init__.py +1 -1
- {wtcode-0.1.1 → wtcode-0.1.3}/wtcode/wtcode.sh +49 -32
- {wtcode-0.1.1 → wtcode-0.1.3/wtcode.egg-info}/PKG-INFO +12 -5
- {wtcode-0.1.1 → wtcode-0.1.3}/LICENSE +0 -0
- {wtcode-0.1.1 → wtcode-0.1.3}/setup.cfg +0 -0
- {wtcode-0.1.1 → wtcode-0.1.3}/wtcode/__main__.py +0 -0
- {wtcode-0.1.1 → wtcode-0.1.3}/wtcode.egg-info/SOURCES.txt +0 -0
- {wtcode-0.1.1 → wtcode-0.1.3}/wtcode.egg-info/dependency_links.txt +0 -0
- {wtcode-0.1.1 → wtcode-0.1.3}/wtcode.egg-info/entry_points.txt +0 -0
- {wtcode-0.1.1 → wtcode-0.1.3}/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.1.
|
|
3
|
+
Version: 0.1.3
|
|
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
|
|
@@ -18,7 +18,7 @@ Dynamic: license-file
|
|
|
18
18
|
|
|
19
19
|
# wtcode
|
|
20
20
|
|
|
21
|
-
**
|
|
21
|
+
**Effortlessly launch your favorite code tool in a git worktree.**
|
|
22
22
|
|
|
23
23
|
*worktree code* / *what-the-code* -- streamlines git worktree selection, creation, and launching tools like [Claude Code](https://claude.ai/code), [lazygit](https://github.com/jesseduffield/lazygit), your editor, or any command.
|
|
24
24
|
|
|
@@ -33,15 +33,18 @@ brew install netj/tap/wtcode
|
|
|
33
33
|
### PyPI (via [uv](https://docs.astral.sh/uv/))
|
|
34
34
|
|
|
35
35
|
```sh
|
|
36
|
-
|
|
36
|
+
uv tool install wtcode
|
|
37
37
|
```
|
|
38
38
|
|
|
39
|
-
Or
|
|
39
|
+
Or try it without installing:
|
|
40
40
|
|
|
41
41
|
```sh
|
|
42
|
-
|
|
42
|
+
uvx wtcode
|
|
43
43
|
```
|
|
44
44
|
|
|
45
|
+
> **Note:** `uv tool install` is recommended over `uvx` for regular use.
|
|
46
|
+
> `uvx` keeps a parent `uv tool run` process alive, which can interfere with tools like tmux that detect the working directory from the process tree.
|
|
47
|
+
|
|
45
48
|
### From source
|
|
46
49
|
|
|
47
50
|
```sh
|
|
@@ -53,10 +56,13 @@ ln -s "$PWD/wtcode/wtcode.sh" /usr/local/bin/wtcode
|
|
|
53
56
|
|
|
54
57
|
```
|
|
55
58
|
wtcode [BRANCH] [CMD [CMD-ARGS...]]
|
|
59
|
+
wtcode --exec CMD [CMD-ARGS...]
|
|
56
60
|
```
|
|
57
61
|
|
|
58
62
|
- **`BRANCH`** -- Git branch or worktree name. If omitted and [fzf](https://github.com/junegunn/fzf) is available, interactively select one. Prefix with `:` to create a new branch (use `:::name` to avoid fzf matching the colons).
|
|
59
63
|
- **`CMD`** -- Command to launch in the worktree. Defaults to `$WTCODE_CMD`, or the first available of: `claude`, `aider`, `codex`, `$SHELL`.
|
|
64
|
+
- **`--exec`** -- Skip the branch argument; select interactively via fzf, then launch `CMD`.
|
|
65
|
+
- **`--help`** / **`--version`** -- Show help or version info.
|
|
60
66
|
|
|
61
67
|
### Examples
|
|
62
68
|
|
|
@@ -64,6 +70,7 @@ wtcode [BRANCH] [CMD [CMD-ARGS...]]
|
|
|
64
70
|
wtcode feature-x # launch default tool in feature-x worktree
|
|
65
71
|
wtcode feature-x lazygit # launch lazygit
|
|
66
72
|
wtcode feature-x claude --resume # launch claude with flags
|
|
73
|
+
wtcode --exec claude --resume # select interactively, launch claude --resume
|
|
67
74
|
wtcode :new-feature # create new branch and worktree
|
|
68
75
|
wtcode # interactive branch selection via fzf
|
|
69
76
|
WTCODE_CMD=cursor wtcode feature # use cursor as default tool
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# wtcode
|
|
2
2
|
|
|
3
|
-
**
|
|
3
|
+
**Effortlessly launch your favorite code tool in a git worktree.**
|
|
4
4
|
|
|
5
5
|
*worktree code* / *what-the-code* -- streamlines git worktree selection, creation, and launching tools like [Claude Code](https://claude.ai/code), [lazygit](https://github.com/jesseduffield/lazygit), your editor, or any command.
|
|
6
6
|
|
|
@@ -15,15 +15,18 @@ brew install netj/tap/wtcode
|
|
|
15
15
|
### PyPI (via [uv](https://docs.astral.sh/uv/))
|
|
16
16
|
|
|
17
17
|
```sh
|
|
18
|
-
|
|
18
|
+
uv tool install wtcode
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
-
Or
|
|
21
|
+
Or try it without installing:
|
|
22
22
|
|
|
23
23
|
```sh
|
|
24
|
-
|
|
24
|
+
uvx wtcode
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
+
> **Note:** `uv tool install` is recommended over `uvx` for regular use.
|
|
28
|
+
> `uvx` keeps a parent `uv tool run` process alive, which can interfere with tools like tmux that detect the working directory from the process tree.
|
|
29
|
+
|
|
27
30
|
### From source
|
|
28
31
|
|
|
29
32
|
```sh
|
|
@@ -35,10 +38,13 @@ ln -s "$PWD/wtcode/wtcode.sh" /usr/local/bin/wtcode
|
|
|
35
38
|
|
|
36
39
|
```
|
|
37
40
|
wtcode [BRANCH] [CMD [CMD-ARGS...]]
|
|
41
|
+
wtcode --exec CMD [CMD-ARGS...]
|
|
38
42
|
```
|
|
39
43
|
|
|
40
44
|
- **`BRANCH`** -- Git branch or worktree name. If omitted and [fzf](https://github.com/junegunn/fzf) is available, interactively select one. Prefix with `:` to create a new branch (use `:::name` to avoid fzf matching the colons).
|
|
41
45
|
- **`CMD`** -- Command to launch in the worktree. Defaults to `$WTCODE_CMD`, or the first available of: `claude`, `aider`, `codex`, `$SHELL`.
|
|
46
|
+
- **`--exec`** -- Skip the branch argument; select interactively via fzf, then launch `CMD`.
|
|
47
|
+
- **`--help`** / **`--version`** -- Show help or version info.
|
|
42
48
|
|
|
43
49
|
### Examples
|
|
44
50
|
|
|
@@ -46,6 +52,7 @@ wtcode [BRANCH] [CMD [CMD-ARGS...]]
|
|
|
46
52
|
wtcode feature-x # launch default tool in feature-x worktree
|
|
47
53
|
wtcode feature-x lazygit # launch lazygit
|
|
48
54
|
wtcode feature-x claude --resume # launch claude with flags
|
|
55
|
+
wtcode --exec claude --resume # select interactively, launch claude --resume
|
|
49
56
|
wtcode :new-feature # create new branch and worktree
|
|
50
57
|
wtcode # interactive branch selection via fzf
|
|
51
58
|
WTCODE_CMD=cursor wtcode feature # use cursor as default tool
|
|
@@ -8,14 +8,22 @@ shopt -s extglob
|
|
|
8
8
|
${WTCODE_DEBUG:+set -x}
|
|
9
9
|
|
|
10
10
|
--msg() { echo "wtcode: $*" >&2; }
|
|
11
|
+
--sanitize-branch-name() {
|
|
12
|
+
printf '%s' "$1" |
|
|
13
|
+
tr '[:upper:]' '[:lower:]' | # lowercase
|
|
14
|
+
sed 's/[^a-z0-9/_-]/-/g' | # replace non-alnum to hyphens
|
|
15
|
+
sed 's/--*/-/g' | # collapse consecutive hyphens
|
|
16
|
+
sed 's/^-//; s/-$//' # trim leading/trailing hyphens
|
|
17
|
+
}
|
|
11
18
|
|
|
12
|
-
WTCODE_VERSION=0.1.
|
|
19
|
+
WTCODE_VERSION=0.1.3
|
|
13
20
|
--version() { echo "wtcode $WTCODE_VERSION"; }
|
|
14
21
|
--help() {
|
|
15
22
|
cat <<USAGE
|
|
16
23
|
wtcode $WTCODE_VERSION -- launch a code tool in a git worktree
|
|
17
24
|
|
|
18
25
|
Usage: wtcode [BRANCH] [CMD [CMD-ARGS...]]
|
|
26
|
+
wtcode --exec CMD [CMD-ARGS...]
|
|
19
27
|
|
|
20
28
|
BRANCH Git branch or worktree name to switch to.
|
|
21
29
|
If omitted and fzf is available, interactively select one.
|
|
@@ -25,6 +33,8 @@ Usage: wtcode [BRANCH] [CMD [CMD-ARGS...]]
|
|
|
25
33
|
CMD Command to launch in the worktree (default: \$WTCODE_CMD,
|
|
26
34
|
or first available of: ${WTCODE_CMDS_TO_TRY[*]}, \$SHELL).
|
|
27
35
|
|
|
36
|
+
--exec Skip branch argument; select interactively, then launch CMD.
|
|
37
|
+
|
|
28
38
|
Environment variables:
|
|
29
39
|
WTCODE_CMD Default tool to launch (e.g., claude, lazygit, vim)
|
|
30
40
|
WTCODE_DEBUG Enable debug tracing when set
|
|
@@ -34,6 +44,7 @@ Examples:
|
|
|
34
44
|
wtcode feature-x # select/create worktree, launch default tool
|
|
35
45
|
wtcode feature-x lazygit # launch lazygit in the worktree
|
|
36
46
|
wtcode feature-x claude --resume # launch claude with --resume
|
|
47
|
+
wtcode --exec claude --resume # select interactively, launch claude --resume
|
|
37
48
|
wtcode :new-feature # create new branch and worktree
|
|
38
49
|
WTCODE_CMD=cursor wtcode feature # use cursor as the default tool
|
|
39
50
|
USAGE
|
|
@@ -48,9 +59,12 @@ WTCODE_CMDS_TO_TRY=(
|
|
|
48
59
|
)
|
|
49
60
|
|
|
50
61
|
###############################################################################
|
|
51
|
-
## --
|
|
62
|
+
## --enter-git-worktree -- select branch and create/switch worktree
|
|
52
63
|
###############################################################################
|
|
53
|
-
--
|
|
64
|
+
--enter-git-worktree() {
|
|
65
|
+
local branch_name=
|
|
66
|
+
|
|
67
|
+
# 1. determine which branch/worktree to use
|
|
54
68
|
if [[ $# -gt 0 ]]; then
|
|
55
69
|
branch_name=$1; shift
|
|
56
70
|
elif type fzf &>/dev/null; then
|
|
@@ -115,23 +129,22 @@ WTCODE_CMDS_TO_TRY=(
|
|
|
115
129
|
|
|
116
130
|
# check if branch name starts with ':' to force new branch creation
|
|
117
131
|
# supports multiple colons (e.g., :::my-branch) to avoid fzf matching
|
|
118
|
-
force_new_branch=false
|
|
132
|
+
local force_new_branch=false
|
|
119
133
|
if [[ $branch_name == :* ]]; then
|
|
120
134
|
force_new_branch=true
|
|
121
135
|
branch_name=${branch_name##+(:)}
|
|
122
136
|
: ${branch_name:?non-empty branch name required after ':'}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
)
|
|
137
|
+
fi
|
|
138
|
+
|
|
139
|
+
# sanitize free-form text into a valid git branch name
|
|
140
|
+
# (skip if it already matches an existing branch/ref to preserve case)
|
|
141
|
+
if $force_new_branch || ! git rev-parse --verify "$branch_name" &>/dev/null; then
|
|
142
|
+
branch_name=$(--sanitize-branch-name "$branch_name")
|
|
130
143
|
: ${branch_name:?branch name is empty after sanitization}
|
|
131
144
|
fi
|
|
132
145
|
|
|
133
146
|
# check if branch_name refers to a remote branch (e.g., origin/feature-x)
|
|
134
|
-
remote_branch=
|
|
147
|
+
local remote_branch=
|
|
135
148
|
if ! $force_new_branch; then
|
|
136
149
|
for remote in $(git remote); do
|
|
137
150
|
if [[ $branch_name == "$remote/"* ]]; then
|
|
@@ -142,15 +155,8 @@ WTCODE_CMDS_TO_TRY=(
|
|
|
142
155
|
done
|
|
143
156
|
fi
|
|
144
157
|
|
|
145
|
-
# remaining args are the command to launch
|
|
146
|
-
wtcode_cmd=("$@")
|
|
147
|
-
}
|
|
148
158
|
|
|
149
|
-
|
|
150
|
-
## --prepare-git-worktree -- create or switch to the worktree for $branch_name
|
|
151
|
-
###############################################################################
|
|
152
|
-
--prepare-git-worktree() {
|
|
153
|
-
# determine root of the worktree dirs
|
|
159
|
+
# 2. create or switch to the worktree
|
|
154
160
|
cd "$(git rev-parse --show-toplevel)"
|
|
155
161
|
: ${GIT_WORKTREE_ROOT:=$(
|
|
156
162
|
git_common_dir=$(git rev-parse --git-common-dir)
|
|
@@ -160,8 +166,7 @@ WTCODE_CMDS_TO_TRY=(
|
|
|
160
166
|
echo "$PWD"/../"$repo_name".worktrees
|
|
161
167
|
)}
|
|
162
168
|
|
|
163
|
-
|
|
164
|
-
worktree_path="$GIT_WORKTREE_ROOT"/"$branch_name"
|
|
169
|
+
local worktree_path="$GIT_WORKTREE_ROOT"/"$branch_name"
|
|
165
170
|
if [[ -e "$worktree_path"/.git ]]; then
|
|
166
171
|
--msg "using existing worktree: $worktree_path"
|
|
167
172
|
elif [[ -n ${remote_branch-} ]] && ! git rev-parse --verify "refs/heads/$branch_name" &>/dev/null; then
|
|
@@ -189,17 +194,21 @@ WTCODE_CMDS_TO_TRY=(
|
|
|
189
194
|
## --launch-code-tool -- resolve and exec the tool in the worktree
|
|
190
195
|
###############################################################################
|
|
191
196
|
--launch-code-tool() {
|
|
192
|
-
# resolve the command to launch if not specified
|
|
193
|
-
if [[
|
|
197
|
+
# resolve the command to launch if not specified
|
|
198
|
+
if [[ $# -eq 0 ]]; then
|
|
194
199
|
for _cmd in "${WTCODE_CMDS_TO_TRY[@]}"; do
|
|
195
|
-
[[ -n "$_cmd" ]] && type "$_cmd" &>/dev/null &&
|
|
200
|
+
[[ -n "$_cmd" ]] && type "$_cmd" &>/dev/null && set -- "$_cmd" && break
|
|
196
201
|
done
|
|
197
202
|
# fall back to an interactive shell
|
|
198
|
-
|
|
203
|
+
[[ $# -gt 0 ]] || set -- "${SHELL:-bash}"
|
|
199
204
|
fi
|
|
200
205
|
|
|
201
|
-
--msg "launching:
|
|
202
|
-
"$
|
|
206
|
+
--msg "launching: $*"
|
|
207
|
+
if [[ $(type -t "$1") == function ]]; then
|
|
208
|
+
"$@"
|
|
209
|
+
else
|
|
210
|
+
exec "$@"
|
|
211
|
+
fi
|
|
203
212
|
}
|
|
204
213
|
|
|
205
214
|
###############################################################################
|
|
@@ -222,7 +231,7 @@ claude() {
|
|
|
222
231
|
}
|
|
223
232
|
)
|
|
224
233
|
fi
|
|
225
|
-
exec
|
|
234
|
+
exec claude "$@"
|
|
226
235
|
}
|
|
227
236
|
|
|
228
237
|
###############################################################################
|
|
@@ -231,10 +240,18 @@ claude() {
|
|
|
231
240
|
|
|
232
241
|
-h() { --help "$@"; }
|
|
233
242
|
|
|
243
|
+
--exec() {
|
|
244
|
+
--enter-git-worktree
|
|
245
|
+
--launch-code-tool "$@"
|
|
246
|
+
}
|
|
247
|
+
|
|
234
248
|
--() {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
249
|
+
if [[ $# -gt 0 ]]; then
|
|
250
|
+
--enter-git-worktree "$1"; shift
|
|
251
|
+
else
|
|
252
|
+
--enter-git-worktree
|
|
253
|
+
fi
|
|
254
|
+
--launch-code-tool "$@"
|
|
238
255
|
}
|
|
239
256
|
|
|
240
257
|
# dispatch $1 as a function when it starts with -
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: wtcode
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.3
|
|
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
|
|
@@ -18,7 +18,7 @@ Dynamic: license-file
|
|
|
18
18
|
|
|
19
19
|
# wtcode
|
|
20
20
|
|
|
21
|
-
**
|
|
21
|
+
**Effortlessly launch your favorite code tool in a git worktree.**
|
|
22
22
|
|
|
23
23
|
*worktree code* / *what-the-code* -- streamlines git worktree selection, creation, and launching tools like [Claude Code](https://claude.ai/code), [lazygit](https://github.com/jesseduffield/lazygit), your editor, or any command.
|
|
24
24
|
|
|
@@ -33,15 +33,18 @@ brew install netj/tap/wtcode
|
|
|
33
33
|
### PyPI (via [uv](https://docs.astral.sh/uv/))
|
|
34
34
|
|
|
35
35
|
```sh
|
|
36
|
-
|
|
36
|
+
uv tool install wtcode
|
|
37
37
|
```
|
|
38
38
|
|
|
39
|
-
Or
|
|
39
|
+
Or try it without installing:
|
|
40
40
|
|
|
41
41
|
```sh
|
|
42
|
-
|
|
42
|
+
uvx wtcode
|
|
43
43
|
```
|
|
44
44
|
|
|
45
|
+
> **Note:** `uv tool install` is recommended over `uvx` for regular use.
|
|
46
|
+
> `uvx` keeps a parent `uv tool run` process alive, which can interfere with tools like tmux that detect the working directory from the process tree.
|
|
47
|
+
|
|
45
48
|
### From source
|
|
46
49
|
|
|
47
50
|
```sh
|
|
@@ -53,10 +56,13 @@ ln -s "$PWD/wtcode/wtcode.sh" /usr/local/bin/wtcode
|
|
|
53
56
|
|
|
54
57
|
```
|
|
55
58
|
wtcode [BRANCH] [CMD [CMD-ARGS...]]
|
|
59
|
+
wtcode --exec CMD [CMD-ARGS...]
|
|
56
60
|
```
|
|
57
61
|
|
|
58
62
|
- **`BRANCH`** -- Git branch or worktree name. If omitted and [fzf](https://github.com/junegunn/fzf) is available, interactively select one. Prefix with `:` to create a new branch (use `:::name` to avoid fzf matching the colons).
|
|
59
63
|
- **`CMD`** -- Command to launch in the worktree. Defaults to `$WTCODE_CMD`, or the first available of: `claude`, `aider`, `codex`, `$SHELL`.
|
|
64
|
+
- **`--exec`** -- Skip the branch argument; select interactively via fzf, then launch `CMD`.
|
|
65
|
+
- **`--help`** / **`--version`** -- Show help or version info.
|
|
60
66
|
|
|
61
67
|
### Examples
|
|
62
68
|
|
|
@@ -64,6 +70,7 @@ wtcode [BRANCH] [CMD [CMD-ARGS...]]
|
|
|
64
70
|
wtcode feature-x # launch default tool in feature-x worktree
|
|
65
71
|
wtcode feature-x lazygit # launch lazygit
|
|
66
72
|
wtcode feature-x claude --resume # launch claude with flags
|
|
73
|
+
wtcode --exec claude --resume # select interactively, launch claude --resume
|
|
67
74
|
wtcode :new-feature # create new branch and worktree
|
|
68
75
|
wtcode # interactive branch selection via fzf
|
|
69
76
|
WTCODE_CMD=cursor wtcode feature # use cursor as default tool
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|