worktree-aid 1.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.
- worktree_aid-1.0/.gitignore +9 -0
- worktree_aid-1.0/PKG-INFO +305 -0
- worktree_aid-1.0/README.md +293 -0
- worktree_aid-1.0/justfile +23 -0
- worktree_aid-1.0/pyproject.toml +36 -0
- worktree_aid-1.0/setup.cfg +4 -0
- worktree_aid-1.0/worktree_aid.egg-info/PKG-INFO +305 -0
- worktree_aid-1.0/worktree_aid.egg-info/SOURCES.txt +13 -0
- worktree_aid-1.0/worktree_aid.egg-info/dependency_links.txt +1 -0
- worktree_aid-1.0/worktree_aid.egg-info/entry_points.txt +2 -0
- worktree_aid-1.0/worktree_aid.egg-info/requires.txt +1 -0
- worktree_aid-1.0/worktree_aid.egg-info/scm_file_list.json +9 -0
- worktree_aid-1.0/worktree_aid.egg-info/scm_version.json +8 -0
- worktree_aid-1.0/worktree_aid.egg-info/top_level.txt +1 -0
- worktree_aid-1.0/worktree_aid.py +567 -0
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: worktree-aid
|
|
3
|
+
Version: 1.0
|
|
4
|
+
Summary: Linux command line tool to aid creating, switching, and removing git worktrees
|
|
5
|
+
Author-email: Mark Blakeney <mark.blakeney@bullet-systems.net>
|
|
6
|
+
License-Expression: GPL-3.0-or-later
|
|
7
|
+
Project-URL: Homepage, https://github.com/bulletmark/worktree-aid
|
|
8
|
+
Keywords: git,worktree,fzf
|
|
9
|
+
Requires-Python: >=3.10
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
Requires-Dist: coolname
|
|
12
|
+
|
|
13
|
+
# worktree-aid
|
|
14
|
+
[](https://pypi.org/project/worktree-aid/)
|
|
15
|
+
[](https://aur.archlinux.org/packages/worktree-aid/)
|
|
16
|
+
|
|
17
|
+
This is a Linux command line tool to conveniently add, remove, and change
|
|
18
|
+
directories for [git worktrees][gitw]. A [fuzzy finder][fzf] is used to show
|
|
19
|
+
current worktrees and prompt user for the name if not given.
|
|
20
|
+
|
|
21
|
+
After following the instructions in the [Installation](#installation-or-upgrade)
|
|
22
|
+
and [Setup](#setup) sections below, an `wt` shell command/alias is available to
|
|
23
|
+
use to manage git worktrees. There are 3 commands typically used:
|
|
24
|
+
|
|
25
|
+
- `wt add` (or `wt a`) to add a new worktree + branch and automatically cd to
|
|
26
|
+
it. If you don't specify a worktree name, a new unique name will be
|
|
27
|
+
automatically created for you.
|
|
28
|
+
|
|
29
|
+
- `wt cd` (or `wt c`) to change directory to a specified worktree. You can use
|
|
30
|
+
`/` as a shortcut to the toplevel repository directory. If you don't specify a
|
|
31
|
+
worktree name, then a [fuzzy finder][fzf] will prompt you with a list of
|
|
32
|
+
worktrees to select from and be cd'd to.
|
|
33
|
+
|
|
34
|
+
- `wt rm` (or `wt r`) to remove a worktree + branch. If you don't specify a
|
|
35
|
+
worktree name, then a [fuzzy finder][fzf] will prompt you with a list of
|
|
36
|
+
worktrees to select from. The current worktree is first in the list and is the
|
|
37
|
+
default selection to remove. If you delete the current worktree then you will
|
|
38
|
+
be automatically cd'd to the toplevel repository directory.
|
|
39
|
+
|
|
40
|
+
There are some other options and commands available, as described in later
|
|
41
|
+
sections. Type `wt` to see an overall help/usage summary, or `wt <command> -h`
|
|
42
|
+
to see specific help/usage for any individual command.
|
|
43
|
+
|
|
44
|
+
The project homepage and latest documentation is at
|
|
45
|
+
https://github.com/bulletmark/worktree-aid.
|
|
46
|
+
|
|
47
|
+
## Usage
|
|
48
|
+
|
|
49
|
+
Type `wt` or `wt -h` to view the usage summary:
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
usage: wt [-B BASEDIR] [-R] [-U] [-F FUZZY] [-h] [-v]
|
|
53
|
+
{add,a,rm,r,cd,c,ls,l,init} ...
|
|
54
|
+
|
|
55
|
+
Linux command line tool to conveniently add, remove, and change directories
|
|
56
|
+
for git worktrees. Prompts user to select worktree using fuzzy finder if no
|
|
57
|
+
worktree name is given.
|
|
58
|
+
|
|
59
|
+
options:
|
|
60
|
+
-B, --basedir BASEDIR
|
|
61
|
+
base directory for newly added worktrees,
|
|
62
|
+
default="../worktrees/{repo}".
|
|
63
|
+
-R, --relative display worktree paths relative instead of absolute
|
|
64
|
+
-U, --no-user do not substitute "~" for home directory
|
|
65
|
+
-F, --fuzzy FUZZY fuzzy finder program, default="fzf"
|
|
66
|
+
-h, --help show help message and exit
|
|
67
|
+
-v, --version show program version and exit
|
|
68
|
+
|
|
69
|
+
Commands:
|
|
70
|
+
{add,a,rm,r,cd,c,ls,l,init}
|
|
71
|
+
add (a) Add new worktree + branch.
|
|
72
|
+
rm (r) Remove worktree + branch.
|
|
73
|
+
cd (c) Change directory to specified worktree.
|
|
74
|
+
ls (l) List current worktrees.
|
|
75
|
+
init Output shell initialization code.
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Type `wt <command> -h` to see specific help/usage for any
|
|
79
|
+
individual command:
|
|
80
|
+
|
|
81
|
+
### Command `add`
|
|
82
|
+
|
|
83
|
+
```
|
|
84
|
+
usage: wt add [-h] [-d] [worktree]
|
|
85
|
+
|
|
86
|
+
Add new worktree + branch.
|
|
87
|
+
|
|
88
|
+
positional arguments:
|
|
89
|
+
worktree new worktree + branch to add. A name is automatically created
|
|
90
|
+
if not specified.
|
|
91
|
+
|
|
92
|
+
options:
|
|
93
|
+
-h, --help show help message and exit
|
|
94
|
+
-d, --detach add detached worktree only, i.e. without adding a new branch
|
|
95
|
+
|
|
96
|
+
aliases: a
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Command `rm`
|
|
100
|
+
|
|
101
|
+
```
|
|
102
|
+
usage: wt rm [-h] [-k] [-f] [worktree]
|
|
103
|
+
|
|
104
|
+
Remove worktree + branch.
|
|
105
|
+
|
|
106
|
+
positional arguments:
|
|
107
|
+
worktree worktree + branch name to remove. If not specified then
|
|
108
|
+
fuzzy finder will prompt with a list of worktrees.
|
|
109
|
+
|
|
110
|
+
options:
|
|
111
|
+
-h, --help show help message and exit
|
|
112
|
+
-k, --keep-branch remove worktree but keep branch
|
|
113
|
+
-f, --force force removal of worktree + branch even if untracked or
|
|
114
|
+
unmerged changes exist.
|
|
115
|
+
|
|
116
|
+
aliases: r
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Command `cd`
|
|
120
|
+
|
|
121
|
+
```
|
|
122
|
+
usage: wt cd [-h] [worktree]
|
|
123
|
+
|
|
124
|
+
Change directory to specified worktree.
|
|
125
|
+
|
|
126
|
+
positional arguments:
|
|
127
|
+
worktree Worktree name to change directory to. If not specified then
|
|
128
|
+
fuzzy finder will prompt with a list of worktrees.
|
|
129
|
+
|
|
130
|
+
options:
|
|
131
|
+
-h, --help show help message and exit
|
|
132
|
+
|
|
133
|
+
aliases: c
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### Command `ls`
|
|
137
|
+
|
|
138
|
+
```
|
|
139
|
+
usage: wt ls [-h]
|
|
140
|
+
|
|
141
|
+
List current worktrees.
|
|
142
|
+
|
|
143
|
+
options:
|
|
144
|
+
-h, --help show help message and exit
|
|
145
|
+
|
|
146
|
+
aliases: l
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### Command `init`
|
|
150
|
+
|
|
151
|
+
```
|
|
152
|
+
usage: wt init [-h] [command]
|
|
153
|
+
|
|
154
|
+
Output shell initialization code. Must be invoked using `source <(worktree-
|
|
155
|
+
aid)` in your shell `~/.bashrc` or `~/.zshrc` initialization file to create
|
|
156
|
+
the shell alias/function by which you invoke this program.
|
|
157
|
+
|
|
158
|
+
positional arguments:
|
|
159
|
+
command alternative command name, and optional default arguments,
|
|
160
|
+
default="wt"
|
|
161
|
+
|
|
162
|
+
options:
|
|
163
|
+
-h, --help show help message and exit
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## Installation or Upgrade
|
|
167
|
+
|
|
168
|
+
Python 3.10 or later is required. Install using [`uv tool`][uvtool]:
|
|
169
|
+
|
|
170
|
+
```sh
|
|
171
|
+
$ uv tool install worktree-aid
|
|
172
|
+
|
|
173
|
+
# To upgrade:
|
|
174
|
+
$ uv tool upgrade worktree-aid
|
|
175
|
+
|
|
176
|
+
# To uninstall:
|
|
177
|
+
$ uv tool uninstall worktree-aid
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
Or, on Arch Linux:
|
|
181
|
+
|
|
182
|
+
```sh
|
|
183
|
+
$ yay -S worktree-aid # or your preferred AUR helper
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
You also need to install a fuzzy finder program such as [`fzf`][fzf] which is
|
|
187
|
+
the default used by `worktree-aid`. See [fuzzy finder installation
|
|
188
|
+
instructions](fuzzy-finder-installation) for possible alternatives.
|
|
189
|
+
|
|
190
|
+
## Setup
|
|
191
|
+
|
|
192
|
+
A user who wants to use `worktree-aid` must add the following line to their
|
|
193
|
+
`~/.bashrc` (`bash` user) or `~/.zshrc` (`zsh` user). Ensure it is added
|
|
194
|
+
after where your PATH is set up so that the command `worktree-aid` can be found. This
|
|
195
|
+
creates the `wt` wrapper command in your interactive shell session as a tiny
|
|
196
|
+
function.
|
|
197
|
+
|
|
198
|
+
```sh
|
|
199
|
+
source <(worktree-aid init)
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
Then log out and back in again to be able to use the new `wt` function in your
|
|
203
|
+
shell.
|
|
204
|
+
|
|
205
|
+
## Alternative Command Name
|
|
206
|
+
|
|
207
|
+
You can use an alternative command name instead of the default `wt` if you
|
|
208
|
+
prefer. To do this, simply append your desired command name as the first
|
|
209
|
+
argument to the `worktree-aid init` option in your shell initialization code.
|
|
210
|
+
|
|
211
|
+
E.g, to use the command name `wx` rather than the default `wt`, use the
|
|
212
|
+
following in your `~/.bashrc` or `~/.zshrc` file:
|
|
213
|
+
|
|
214
|
+
```sh
|
|
215
|
+
source <(worktree-aid init wx)
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
Then log out/in, and then use `wx` command instead of the default `wt`.
|
|
219
|
+
|
|
220
|
+
## Default Options
|
|
221
|
+
|
|
222
|
+
You can also set default `worktree-aid` options by appending options in the shell
|
|
223
|
+
initialization code, e.g:
|
|
224
|
+
|
|
225
|
+
```sh
|
|
226
|
+
source <(worktree-aid init "wt -R")
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
The above sets `-R` (for relative display of worktree directories) as default for your
|
|
230
|
+
`wt` command.
|
|
231
|
+
|
|
232
|
+
The following options are sensible candidates to set as default options:
|
|
233
|
+
|
|
234
|
+
- `-B/--basedir`,
|
|
235
|
+
- `-R/--relative`,
|
|
236
|
+
- `-U/--no-user`,
|
|
237
|
+
- `-F/--fuzzy`.
|
|
238
|
+
|
|
239
|
+
## Worktree Base Directory
|
|
240
|
+
|
|
241
|
+
The `-B/--basedir` option allows you to specify a base directory for newly added
|
|
242
|
+
worktrees. It is set to a default as below but you can change this to any
|
|
243
|
+
directory you like. It can be absolute or relative where relative paths are
|
|
244
|
+
relative to base repository directory.
|
|
245
|
+
|
|
246
|
+
- Default is `-B ../worktrees/{repo}` which is the same as the [Zed] editor uses.
|
|
247
|
+
- E.g. can use `-B ../{repo}.worktrees` which is same as [VS Code] uses.
|
|
248
|
+
- E.g. can use `-B ~/worktrees/{repo}` to put all worktrees in a subdirectory of your home directory.
|
|
249
|
+
|
|
250
|
+
The following place-markers can be used in the definition of the base directory:
|
|
251
|
+
|
|
252
|
+
- `{repo}`: Substituted with the base name of the repository.
|
|
253
|
+
- `{user}`: Substituted with the name of the user.
|
|
254
|
+
- `{home}`: Substituted with the home directory of the user (also can use `~` at start of a path).
|
|
255
|
+
|
|
256
|
+
Most likely if you will want to set a custom basedir then you will set `-B` as a
|
|
257
|
+
[default option](#default-options).
|
|
258
|
+
|
|
259
|
+
## Display as Relative Worktree Directories
|
|
260
|
+
|
|
261
|
+
The `git worktree list` command displays absolute directory paths, and
|
|
262
|
+
`worktree-aid` does also by default, but many users prefer them displayed as
|
|
263
|
+
shorter relative paths. The Git worktree command does not provide this but you
|
|
264
|
+
can enable it in `worktree-aid` by adding the `-R/--relative` option, e.g:
|
|
265
|
+
|
|
266
|
+
```sh
|
|
267
|
+
$ wt l
|
|
268
|
+
../development 9796714 [development]
|
|
269
|
+
../milestone1 bc921b8 [milestone1]
|
|
270
|
+
../test e6d965a [test]
|
|
271
|
+
. f76b8e0 [main]
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
Most likely you will want to set `-R` as a [default option](#default-options).
|
|
275
|
+
|
|
276
|
+
## Fuzzy Finder Integration
|
|
277
|
+
|
|
278
|
+
[`fzf`][fzf] is the default fuzzy finder used by `worktree-aid`, but you can use
|
|
279
|
+
any of the popular other command line fuzzy search finders such as [`sk`][skim],
|
|
280
|
+
[`tv`][television], or [`fzy`][fzy].
|
|
281
|
+
|
|
282
|
+
E.g. to use [`sk`][skim], put this in your `~/.bashrc` or `~/.zshrc` file:
|
|
283
|
+
|
|
284
|
+
```sh
|
|
285
|
+
source <(worktree-aid init "wt -F sk")
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
You can also get fancy and add preview options etc to your fuzzy finder command line.
|
|
289
|
+
Most likely you will want to set `-F` as a [default option](#default-options).
|
|
290
|
+
|
|
291
|
+
## License
|
|
292
|
+
|
|
293
|
+
GPL-3.0-or-later.
|
|
294
|
+
|
|
295
|
+
[gitw]: https://git-scm.com/docs/git-worktree
|
|
296
|
+
[worktree-aid]: https://github.com/bulletmark/worktree-aid
|
|
297
|
+
[PyPI]: https://pypi.org/project/worktree-aid
|
|
298
|
+
[AUR]: https://aur.archlinux.org/packages/worktree-aid
|
|
299
|
+
[uvtool]: https://docs.astral.sh/uv/guides/tools/#installing-tools
|
|
300
|
+
[fzf]: https://github.com/junegunn/fzf
|
|
301
|
+
[fzy]: https://github.com/jhawthorn/fzy
|
|
302
|
+
[skim]: https://github.com/skim-rs/skim
|
|
303
|
+
[television]: https://github.com/alexpasmantier/television
|
|
304
|
+
[Zed]: https://zed.dev/
|
|
305
|
+
[VS Code]: https://code.visualstudio.com/
|
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
# worktree-aid
|
|
2
|
+
[](https://pypi.org/project/worktree-aid/)
|
|
3
|
+
[](https://aur.archlinux.org/packages/worktree-aid/)
|
|
4
|
+
|
|
5
|
+
This is a Linux command line tool to conveniently add, remove, and change
|
|
6
|
+
directories for [git worktrees][gitw]. A [fuzzy finder][fzf] is used to show
|
|
7
|
+
current worktrees and prompt user for the name if not given.
|
|
8
|
+
|
|
9
|
+
After following the instructions in the [Installation](#installation-or-upgrade)
|
|
10
|
+
and [Setup](#setup) sections below, an `wt` shell command/alias is available to
|
|
11
|
+
use to manage git worktrees. There are 3 commands typically used:
|
|
12
|
+
|
|
13
|
+
- `wt add` (or `wt a`) to add a new worktree + branch and automatically cd to
|
|
14
|
+
it. If you don't specify a worktree name, a new unique name will be
|
|
15
|
+
automatically created for you.
|
|
16
|
+
|
|
17
|
+
- `wt cd` (or `wt c`) to change directory to a specified worktree. You can use
|
|
18
|
+
`/` as a shortcut to the toplevel repository directory. If you don't specify a
|
|
19
|
+
worktree name, then a [fuzzy finder][fzf] will prompt you with a list of
|
|
20
|
+
worktrees to select from and be cd'd to.
|
|
21
|
+
|
|
22
|
+
- `wt rm` (or `wt r`) to remove a worktree + branch. If you don't specify a
|
|
23
|
+
worktree name, then a [fuzzy finder][fzf] will prompt you with a list of
|
|
24
|
+
worktrees to select from. The current worktree is first in the list and is the
|
|
25
|
+
default selection to remove. If you delete the current worktree then you will
|
|
26
|
+
be automatically cd'd to the toplevel repository directory.
|
|
27
|
+
|
|
28
|
+
There are some other options and commands available, as described in later
|
|
29
|
+
sections. Type `wt` to see an overall help/usage summary, or `wt <command> -h`
|
|
30
|
+
to see specific help/usage for any individual command.
|
|
31
|
+
|
|
32
|
+
The project homepage and latest documentation is at
|
|
33
|
+
https://github.com/bulletmark/worktree-aid.
|
|
34
|
+
|
|
35
|
+
## Usage
|
|
36
|
+
|
|
37
|
+
Type `wt` or `wt -h` to view the usage summary:
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
usage: wt [-B BASEDIR] [-R] [-U] [-F FUZZY] [-h] [-v]
|
|
41
|
+
{add,a,rm,r,cd,c,ls,l,init} ...
|
|
42
|
+
|
|
43
|
+
Linux command line tool to conveniently add, remove, and change directories
|
|
44
|
+
for git worktrees. Prompts user to select worktree using fuzzy finder if no
|
|
45
|
+
worktree name is given.
|
|
46
|
+
|
|
47
|
+
options:
|
|
48
|
+
-B, --basedir BASEDIR
|
|
49
|
+
base directory for newly added worktrees,
|
|
50
|
+
default="../worktrees/{repo}".
|
|
51
|
+
-R, --relative display worktree paths relative instead of absolute
|
|
52
|
+
-U, --no-user do not substitute "~" for home directory
|
|
53
|
+
-F, --fuzzy FUZZY fuzzy finder program, default="fzf"
|
|
54
|
+
-h, --help show help message and exit
|
|
55
|
+
-v, --version show program version and exit
|
|
56
|
+
|
|
57
|
+
Commands:
|
|
58
|
+
{add,a,rm,r,cd,c,ls,l,init}
|
|
59
|
+
add (a) Add new worktree + branch.
|
|
60
|
+
rm (r) Remove worktree + branch.
|
|
61
|
+
cd (c) Change directory to specified worktree.
|
|
62
|
+
ls (l) List current worktrees.
|
|
63
|
+
init Output shell initialization code.
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Type `wt <command> -h` to see specific help/usage for any
|
|
67
|
+
individual command:
|
|
68
|
+
|
|
69
|
+
### Command `add`
|
|
70
|
+
|
|
71
|
+
```
|
|
72
|
+
usage: wt add [-h] [-d] [worktree]
|
|
73
|
+
|
|
74
|
+
Add new worktree + branch.
|
|
75
|
+
|
|
76
|
+
positional arguments:
|
|
77
|
+
worktree new worktree + branch to add. A name is automatically created
|
|
78
|
+
if not specified.
|
|
79
|
+
|
|
80
|
+
options:
|
|
81
|
+
-h, --help show help message and exit
|
|
82
|
+
-d, --detach add detached worktree only, i.e. without adding a new branch
|
|
83
|
+
|
|
84
|
+
aliases: a
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Command `rm`
|
|
88
|
+
|
|
89
|
+
```
|
|
90
|
+
usage: wt rm [-h] [-k] [-f] [worktree]
|
|
91
|
+
|
|
92
|
+
Remove worktree + branch.
|
|
93
|
+
|
|
94
|
+
positional arguments:
|
|
95
|
+
worktree worktree + branch name to remove. If not specified then
|
|
96
|
+
fuzzy finder will prompt with a list of worktrees.
|
|
97
|
+
|
|
98
|
+
options:
|
|
99
|
+
-h, --help show help message and exit
|
|
100
|
+
-k, --keep-branch remove worktree but keep branch
|
|
101
|
+
-f, --force force removal of worktree + branch even if untracked or
|
|
102
|
+
unmerged changes exist.
|
|
103
|
+
|
|
104
|
+
aliases: r
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Command `cd`
|
|
108
|
+
|
|
109
|
+
```
|
|
110
|
+
usage: wt cd [-h] [worktree]
|
|
111
|
+
|
|
112
|
+
Change directory to specified worktree.
|
|
113
|
+
|
|
114
|
+
positional arguments:
|
|
115
|
+
worktree Worktree name to change directory to. If not specified then
|
|
116
|
+
fuzzy finder will prompt with a list of worktrees.
|
|
117
|
+
|
|
118
|
+
options:
|
|
119
|
+
-h, --help show help message and exit
|
|
120
|
+
|
|
121
|
+
aliases: c
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
### Command `ls`
|
|
125
|
+
|
|
126
|
+
```
|
|
127
|
+
usage: wt ls [-h]
|
|
128
|
+
|
|
129
|
+
List current worktrees.
|
|
130
|
+
|
|
131
|
+
options:
|
|
132
|
+
-h, --help show help message and exit
|
|
133
|
+
|
|
134
|
+
aliases: l
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Command `init`
|
|
138
|
+
|
|
139
|
+
```
|
|
140
|
+
usage: wt init [-h] [command]
|
|
141
|
+
|
|
142
|
+
Output shell initialization code. Must be invoked using `source <(worktree-
|
|
143
|
+
aid)` in your shell `~/.bashrc` or `~/.zshrc` initialization file to create
|
|
144
|
+
the shell alias/function by which you invoke this program.
|
|
145
|
+
|
|
146
|
+
positional arguments:
|
|
147
|
+
command alternative command name, and optional default arguments,
|
|
148
|
+
default="wt"
|
|
149
|
+
|
|
150
|
+
options:
|
|
151
|
+
-h, --help show help message and exit
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
## Installation or Upgrade
|
|
155
|
+
|
|
156
|
+
Python 3.10 or later is required. Install using [`uv tool`][uvtool]:
|
|
157
|
+
|
|
158
|
+
```sh
|
|
159
|
+
$ uv tool install worktree-aid
|
|
160
|
+
|
|
161
|
+
# To upgrade:
|
|
162
|
+
$ uv tool upgrade worktree-aid
|
|
163
|
+
|
|
164
|
+
# To uninstall:
|
|
165
|
+
$ uv tool uninstall worktree-aid
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
Or, on Arch Linux:
|
|
169
|
+
|
|
170
|
+
```sh
|
|
171
|
+
$ yay -S worktree-aid # or your preferred AUR helper
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
You also need to install a fuzzy finder program such as [`fzf`][fzf] which is
|
|
175
|
+
the default used by `worktree-aid`. See [fuzzy finder installation
|
|
176
|
+
instructions](fuzzy-finder-installation) for possible alternatives.
|
|
177
|
+
|
|
178
|
+
## Setup
|
|
179
|
+
|
|
180
|
+
A user who wants to use `worktree-aid` must add the following line to their
|
|
181
|
+
`~/.bashrc` (`bash` user) or `~/.zshrc` (`zsh` user). Ensure it is added
|
|
182
|
+
after where your PATH is set up so that the command `worktree-aid` can be found. This
|
|
183
|
+
creates the `wt` wrapper command in your interactive shell session as a tiny
|
|
184
|
+
function.
|
|
185
|
+
|
|
186
|
+
```sh
|
|
187
|
+
source <(worktree-aid init)
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
Then log out and back in again to be able to use the new `wt` function in your
|
|
191
|
+
shell.
|
|
192
|
+
|
|
193
|
+
## Alternative Command Name
|
|
194
|
+
|
|
195
|
+
You can use an alternative command name instead of the default `wt` if you
|
|
196
|
+
prefer. To do this, simply append your desired command name as the first
|
|
197
|
+
argument to the `worktree-aid init` option in your shell initialization code.
|
|
198
|
+
|
|
199
|
+
E.g, to use the command name `wx` rather than the default `wt`, use the
|
|
200
|
+
following in your `~/.bashrc` or `~/.zshrc` file:
|
|
201
|
+
|
|
202
|
+
```sh
|
|
203
|
+
source <(worktree-aid init wx)
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
Then log out/in, and then use `wx` command instead of the default `wt`.
|
|
207
|
+
|
|
208
|
+
## Default Options
|
|
209
|
+
|
|
210
|
+
You can also set default `worktree-aid` options by appending options in the shell
|
|
211
|
+
initialization code, e.g:
|
|
212
|
+
|
|
213
|
+
```sh
|
|
214
|
+
source <(worktree-aid init "wt -R")
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
The above sets `-R` (for relative display of worktree directories) as default for your
|
|
218
|
+
`wt` command.
|
|
219
|
+
|
|
220
|
+
The following options are sensible candidates to set as default options:
|
|
221
|
+
|
|
222
|
+
- `-B/--basedir`,
|
|
223
|
+
- `-R/--relative`,
|
|
224
|
+
- `-U/--no-user`,
|
|
225
|
+
- `-F/--fuzzy`.
|
|
226
|
+
|
|
227
|
+
## Worktree Base Directory
|
|
228
|
+
|
|
229
|
+
The `-B/--basedir` option allows you to specify a base directory for newly added
|
|
230
|
+
worktrees. It is set to a default as below but you can change this to any
|
|
231
|
+
directory you like. It can be absolute or relative where relative paths are
|
|
232
|
+
relative to base repository directory.
|
|
233
|
+
|
|
234
|
+
- Default is `-B ../worktrees/{repo}` which is the same as the [Zed] editor uses.
|
|
235
|
+
- E.g. can use `-B ../{repo}.worktrees` which is same as [VS Code] uses.
|
|
236
|
+
- E.g. can use `-B ~/worktrees/{repo}` to put all worktrees in a subdirectory of your home directory.
|
|
237
|
+
|
|
238
|
+
The following place-markers can be used in the definition of the base directory:
|
|
239
|
+
|
|
240
|
+
- `{repo}`: Substituted with the base name of the repository.
|
|
241
|
+
- `{user}`: Substituted with the name of the user.
|
|
242
|
+
- `{home}`: Substituted with the home directory of the user (also can use `~` at start of a path).
|
|
243
|
+
|
|
244
|
+
Most likely if you will want to set a custom basedir then you will set `-B` as a
|
|
245
|
+
[default option](#default-options).
|
|
246
|
+
|
|
247
|
+
## Display as Relative Worktree Directories
|
|
248
|
+
|
|
249
|
+
The `git worktree list` command displays absolute directory paths, and
|
|
250
|
+
`worktree-aid` does also by default, but many users prefer them displayed as
|
|
251
|
+
shorter relative paths. The Git worktree command does not provide this but you
|
|
252
|
+
can enable it in `worktree-aid` by adding the `-R/--relative` option, e.g:
|
|
253
|
+
|
|
254
|
+
```sh
|
|
255
|
+
$ wt l
|
|
256
|
+
../development 9796714 [development]
|
|
257
|
+
../milestone1 bc921b8 [milestone1]
|
|
258
|
+
../test e6d965a [test]
|
|
259
|
+
. f76b8e0 [main]
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
Most likely you will want to set `-R` as a [default option](#default-options).
|
|
263
|
+
|
|
264
|
+
## Fuzzy Finder Integration
|
|
265
|
+
|
|
266
|
+
[`fzf`][fzf] is the default fuzzy finder used by `worktree-aid`, but you can use
|
|
267
|
+
any of the popular other command line fuzzy search finders such as [`sk`][skim],
|
|
268
|
+
[`tv`][television], or [`fzy`][fzy].
|
|
269
|
+
|
|
270
|
+
E.g. to use [`sk`][skim], put this in your `~/.bashrc` or `~/.zshrc` file:
|
|
271
|
+
|
|
272
|
+
```sh
|
|
273
|
+
source <(worktree-aid init "wt -F sk")
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
You can also get fancy and add preview options etc to your fuzzy finder command line.
|
|
277
|
+
Most likely you will want to set `-F` as a [default option](#default-options).
|
|
278
|
+
|
|
279
|
+
## License
|
|
280
|
+
|
|
281
|
+
GPL-3.0-or-later.
|
|
282
|
+
|
|
283
|
+
[gitw]: https://git-scm.com/docs/git-worktree
|
|
284
|
+
[worktree-aid]: https://github.com/bulletmark/worktree-aid
|
|
285
|
+
[PyPI]: https://pypi.org/project/worktree-aid
|
|
286
|
+
[AUR]: https://aur.archlinux.org/packages/worktree-aid
|
|
287
|
+
[uvtool]: https://docs.astral.sh/uv/guides/tools/#installing-tools
|
|
288
|
+
[fzf]: https://github.com/junegunn/fzf
|
|
289
|
+
[fzy]: https://github.com/jhawthorn/fzy
|
|
290
|
+
[skim]: https://github.com/skim-rs/skim
|
|
291
|
+
[television]: https://github.com/alexpasmantier/television
|
|
292
|
+
[Zed]: https://zed.dev/
|
|
293
|
+
[VS Code]: https://code.visualstudio.com/
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
PYFILES := `echo *.py`
|
|
2
|
+
|
|
3
|
+
check:
|
|
4
|
+
ruff check {{PYFILES}}
|
|
5
|
+
ty check {{PYFILES}}
|
|
6
|
+
vermin -vv --no-tips -i {{PYFILES}}
|
|
7
|
+
#md-link-checker
|
|
8
|
+
|
|
9
|
+
build:
|
|
10
|
+
rm -rf dist
|
|
11
|
+
uv build
|
|
12
|
+
|
|
13
|
+
upload: build
|
|
14
|
+
uv-publish
|
|
15
|
+
|
|
16
|
+
doc:
|
|
17
|
+
update-readme-usage -A -S "s/worktree-aid/wt/g"
|
|
18
|
+
|
|
19
|
+
format:
|
|
20
|
+
ruff check --select I --fix {{PYFILES}} && ruff format {{PYFILES}}
|
|
21
|
+
|
|
22
|
+
clean:
|
|
23
|
+
@rm -vrf uv.lock *.egg-info build/ dist/ __pycache__/
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0", "setuptools-scm[toml]>=6.2"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "worktree-aid"
|
|
7
|
+
description = "Linux command line tool to aid creating, switching, and removing git worktrees"
|
|
8
|
+
readme = "README.md"
|
|
9
|
+
license = "GPL-3.0-or-later"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
keywords = ["git", "worktree", "fzf"]
|
|
12
|
+
dynamic = ["version"]
|
|
13
|
+
dependencies = [
|
|
14
|
+
"coolname",
|
|
15
|
+
]
|
|
16
|
+
|
|
17
|
+
[[project.authors]]
|
|
18
|
+
name = "Mark Blakeney"
|
|
19
|
+
email = "mark.blakeney@bullet-systems.net"
|
|
20
|
+
|
|
21
|
+
[project.urls]
|
|
22
|
+
Homepage = "https://github.com/bulletmark/worktree-aid"
|
|
23
|
+
|
|
24
|
+
[project.scripts]
|
|
25
|
+
worktree-aid = "worktree_aid:main"
|
|
26
|
+
|
|
27
|
+
[tool.setuptools_scm]
|
|
28
|
+
version_scheme = "post-release"
|
|
29
|
+
|
|
30
|
+
[tool.ruff.format]
|
|
31
|
+
quote-style = "single"
|
|
32
|
+
|
|
33
|
+
[tool.ruff.lint]
|
|
34
|
+
ignore = ["SIM115", "SIM905", "BLE001", "PLW1510"]
|
|
35
|
+
|
|
36
|
+
# vim:se sw=2:
|