edir 2.35__tar.gz → 2.37__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.
- {edir-2.35 → edir-2.37}/PKG-INFO +87 -33
- {edir-2.35 → edir-2.37}/README.md +86 -32
- {edir-2.35 → edir-2.37}/edir.egg-info/PKG-INFO +87 -33
- {edir-2.35 → edir-2.37}/edir.egg-info/SOURCES.txt +2 -0
- edir-2.37/edir.egg-info/scm_file_list.json +9 -0
- edir-2.37/edir.egg-info/scm_version.json +8 -0
- {edir-2.35 → edir-2.37}/edir.py +79 -22
- {edir-2.35 → edir-2.37}/justfile +1 -1
- {edir-2.35 → edir-2.37}/.gitignore +0 -0
- {edir-2.35 → edir-2.37}/edir.egg-info/dependency_links.txt +0 -0
- {edir-2.35 → edir-2.37}/edir.egg-info/entry_points.txt +0 -0
- {edir-2.35 → edir-2.37}/edir.egg-info/requires.txt +0 -0
- {edir-2.35 → edir-2.37}/edir.egg-info/top_level.txt +0 -0
- {edir-2.35 → edir-2.37}/pyproject.toml +0 -0
- {edir-2.35 → edir-2.37}/setup.cfg +0 -0
{edir-2.35 → edir-2.37}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: edir
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.37
|
|
4
4
|
Summary: Utility to rename, remove, and copy files/dirs using your editor
|
|
5
5
|
Author-email: Mark Blakeney <mark.blakeney@bullet-systems.net>
|
|
6
6
|
License-Expression: GPL-3.0-or-later
|
|
@@ -154,45 +154,49 @@ following ways:
|
|
|
154
154
|
19. `edir` filters out any duplicate paths you may inadvertently specify
|
|
155
155
|
on it's command line.
|
|
156
156
|
|
|
157
|
-
20. `edir`
|
|
157
|
+
20. `edir` provides an optional configuration file to set default `edir`
|
|
158
|
+
command line options. See [section below](#command-default-options).
|
|
159
|
+
|
|
160
|
+
21. `edir` always invokes a consistent duplicate renaming scheme. E.g. if
|
|
158
161
|
you rename `b`, `c`, `d` all to the same pre-existing name `a` then
|
|
159
|
-
`edir` will rename `b` to `a~`, `c` to `a~1`, `d` to `a~2`.
|
|
162
|
+
`edir` will rename `b` to `a~`, `c` to `a~1`, and `d` to `a~2`.
|
|
160
163
|
Depending on order of operations, `vidir` is not always consistent
|
|
161
|
-
about this, E.g. sometimes it creates a `a~1` with no `a
|
|
162
|
-
|
|
163
|
-
report/address?).
|
|
164
|
+
about this, E.g. sometimes it creates a `a~1` with no `a~`, or starts the
|
|
165
|
+
numbers with `a~2`. (these may be bugs in `vidir` that nobody has ever
|
|
166
|
+
bothered to report/address?).
|
|
167
|
+
|
|
168
|
+
22. Further to the previous item, `edir` allows you to change the format of the
|
|
169
|
+
name of copied files by specifying the `--copy-name-template` option. Refer
|
|
170
|
+
to the [section below](#custom-copied-file-template) for details.
|
|
164
171
|
|
|
165
|
-
|
|
172
|
+
23. `edir` creates the temporary editing file with a `.sh` suffix so
|
|
166
173
|
your EDITOR may syntax highlight the entries. Optionally, you can
|
|
167
174
|
change this default suffix.
|
|
168
175
|
|
|
169
|
-
|
|
176
|
+
24. `edir` provides an optional environment value to add custom options
|
|
170
177
|
to the invocation of your editor. See [section
|
|
171
178
|
below](#edir_editor-environment-variable).
|
|
172
179
|
|
|
173
|
-
|
|
174
|
-
command line options. See [section below](#command-default-options).
|
|
175
|
-
|
|
176
|
-
24. Contrary to what it's name implies, `vidir` actually respects your
|
|
180
|
+
25. Contrary to what it's name implies, `vidir` actually respects your
|
|
177
181
|
`$EDITOR` variable and runs your preferred editor like `edir` does
|
|
178
182
|
but `edir` has been given a generic name to make this more apparent.
|
|
179
183
|
If `$EDITOR` is not set then `edir` uses a default editor
|
|
180
184
|
appropriate to your system.
|
|
181
185
|
|
|
182
|
-
|
|
186
|
+
26. `vidir` returns status code 0 if all files successful, or 1 if any
|
|
183
187
|
error. `edir` returns 0 if all files successful, 1 if some had
|
|
184
188
|
error, or 2 if all had error.
|
|
185
189
|
|
|
186
|
-
|
|
190
|
+
27. `vidir` returns an error when attempting to rename across different
|
|
187
191
|
file systems, which `edir` allows.
|
|
188
192
|
|
|
189
|
-
|
|
193
|
+
28. By default, `edir` shows given paths relative to the current working
|
|
190
194
|
directory so that file names are shorter and easier to read/edit. `vidir`
|
|
191
195
|
shows absolute paths (if they are given like that on the command line, e.g.
|
|
192
196
|
by an external tool). You can disable this relative path behavior in `edir`
|
|
193
197
|
if you want.
|
|
194
198
|
|
|
195
|
-
|
|
199
|
+
29. `edir` always ensures editor line numbers have the same width (e.g.
|
|
196
200
|
`1` to `6` for 6 files, or `01` to `12` for 12 files, etc) so that
|
|
197
201
|
file names always line up justified. This facilitates block editing
|
|
198
202
|
of file names, e.g. using vim's [visual block
|
|
@@ -200,7 +204,7 @@ following ways:
|
|
|
200
204
|
do this so file names can be jagged wrt each other which makes block
|
|
201
205
|
editing awkward.
|
|
202
206
|
|
|
203
|
-
|
|
207
|
+
30. `edir` is very strict about the format of the lines you edit and
|
|
204
208
|
immediately exits with an error message (before changing anything)
|
|
205
209
|
if you format one of the lines incorrectly. All lines in the edited
|
|
206
210
|
list:
|
|
@@ -216,7 +220,7 @@ following ways:
|
|
|
216
220
|
line so an easy way to swap two file names is just to swap their
|
|
217
221
|
numbers.
|
|
218
222
|
|
|
219
|
-
|
|
223
|
+
31. `edir` always actions files consistently. The sequence of
|
|
220
224
|
operations applied is:
|
|
221
225
|
|
|
222
226
|
1. Deleted files are removed and all renamed files and directories
|
|
@@ -230,11 +234,11 @@ following ways:
|
|
|
230
234
|
|
|
231
235
|
4. Remaining deleted directories are removed.
|
|
232
236
|
|
|
233
|
-
In simple terms, remember that files are processed before
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
237
|
+
In simple terms, remember that files are processed before directories so
|
|
238
|
+
you can rename files into a different directory and then delete the
|
|
239
|
+
original directory, all in one edit. However in practice it is far **less
|
|
240
|
+
confusing and less risky** if you perform complicated renames and moves
|
|
241
|
+
across changed directories in distinct steps.
|
|
238
242
|
|
|
239
243
|
## Renames and Deletes in a GIT Repository
|
|
240
244
|
|
|
@@ -391,7 +395,8 @@ Type `edir -h` to view the usage summary:
|
|
|
391
395
|
usage: edir [-h] [-i] [-I] [-a] [-A] [-r] [-R] [-q] [-Q] [-G] [-g] [-t]
|
|
392
396
|
[-T] [--trash-program TRASH_PROGRAM] [-c] [-C] [-d DEPTH] [-F |
|
|
393
397
|
-D] [-L] [-N] [-M] [-S] [-O] [--OP OP] [-E] [-X] [-Y] [-Z]
|
|
394
|
-
[--suffix SUFFIX] [--
|
|
398
|
+
[--suffix SUFFIX] [--copy-name-template COPY_NAME_TEMPLATE]
|
|
399
|
+
[--no-relative] [-V] [--conf]
|
|
395
400
|
[args ...]
|
|
396
401
|
|
|
397
402
|
Command line utility to rename, remove, or copy files and directories directly
|
|
@@ -444,6 +449,10 @@ options:
|
|
|
444
449
|
group directories last (including when sorted)
|
|
445
450
|
-Z, --no-group-dirs negate the options to group directories
|
|
446
451
|
--suffix SUFFIX specify suffix for temp editor file, default=".sh"
|
|
452
|
+
--copy-name-template COPY_NAME_TEMPLATE
|
|
453
|
+
specify copy file/path name template (%F=filename,
|
|
454
|
+
%Nd, %nd(no zero) where "d" is starting number),
|
|
455
|
+
default="%F~%n1"
|
|
447
456
|
--no-relative do not forcibly show paths relative to current working
|
|
448
457
|
directory
|
|
449
458
|
-V, --version show edir version
|
|
@@ -460,23 +469,64 @@ your defaults.
|
|
|
460
469
|
You can use `edir` with [`sudo`][sudo] to rename, delete, or copy system files.
|
|
461
470
|
For improved convenience and security, `edir` runs the editing session as your
|
|
462
471
|
regular user, not as root - similar to how [`sudoedit`][sudoedit] works. This
|
|
463
|
-
approach allows you to use graphical editors (like VS Code), which
|
|
464
|
-
run as root. Use `sudo -E` so that your preferred editor
|
|
465
|
-
`$EDIR_EDITOR` or `$EDITOR` environment variable. For
|
|
466
|
-
delete files in `/etc` using VS Code:
|
|
472
|
+
approach allows you to use graphical editors (like VS Code or Zed etc), which
|
|
473
|
+
normally should not be run as root. Use `sudo -E` so that your preferred editor
|
|
474
|
+
is selected via your `$EDIR_EDITOR` or `$EDITOR` environment variable. For
|
|
475
|
+
example, to rename or delete files in `/etc` using VS Code:
|
|
467
476
|
|
|
468
477
|
```sh
|
|
469
478
|
$ export EDIR_EDITOR="code -nw"
|
|
470
479
|
$ sudo -E edir /etc
|
|
471
480
|
```
|
|
472
481
|
|
|
482
|
+
## Custom Copied File Template
|
|
483
|
+
|
|
484
|
+
When you duplicate a line to copy a file or directory, `edir` ensures the new
|
|
485
|
+
copy has a unique name. By default it uses the same scheme as `vidir`, i.e, if
|
|
486
|
+
you rename `b`, `c`, `d` all to the same pre-existing name `a` then `edir` will
|
|
487
|
+
rename:
|
|
488
|
+
|
|
489
|
+
b -> a~
|
|
490
|
+
c -> a~1
|
|
491
|
+
d -> a~2
|
|
492
|
+
|
|
493
|
+
The format of the copied file name is defined by the `edir` default setting for
|
|
494
|
+
`--copy-name-template="%F~%n1"` where `%F` is the original file name, `%n1`
|
|
495
|
+
means suppress showing the first copy number (i.e. `~` instead of `~1` as in the
|
|
496
|
+
above example) and then start the remaining copies from 1.
|
|
497
|
+
|
|
498
|
+
You can also specify `%Nd` instead of `%nd` in the template to always show the
|
|
499
|
+
copy number even for the first copy, e.g. `--copy-name-template="%F~%N1"` would
|
|
500
|
+
instead produce:
|
|
501
|
+
|
|
502
|
+
b -> a~1
|
|
503
|
+
c -> a~2
|
|
504
|
+
d -> a~3
|
|
505
|
+
|
|
506
|
+
Some example other settings of `--copy-name-template` follow:
|
|
507
|
+
|
|
508
|
+
`--copy-name-template="%F-%N2"`:
|
|
509
|
+
|
|
510
|
+
b -> a-2
|
|
511
|
+
c -> a-3
|
|
512
|
+
d -> a-4
|
|
513
|
+
|
|
514
|
+
`--copy-name-template="%F-copy-%n2"`:
|
|
515
|
+
|
|
516
|
+
b -> a-copy
|
|
517
|
+
c -> a-copy-2
|
|
518
|
+
d -> a-copy-3
|
|
519
|
+
|
|
520
|
+
You are likely to want to set `--copy-name-template` as a [default option](#command-default-options).
|
|
521
|
+
|
|
473
522
|
## Embed in Ranger File Manager
|
|
474
523
|
|
|
475
524
|
In many ways `edir` (and even `vidir`) is better than the [`ranger`][ranger]
|
|
476
525
|
terminal file manager
|
|
477
526
|
[`bulkrename`](https://github.com/ranger/ranger/wiki/Official-user-guide#bulk-renaming)
|
|
478
|
-
command which does not handle name swaps and clashes etc.
|
|
479
|
-
|
|
527
|
+
command which does not handle name swaps and clashes etc. Also, use `edir` to
|
|
528
|
+
delete or copy files, not just rename them. To add `edir` as a command within
|
|
529
|
+
[`ranger`][ranger], add or create the following in
|
|
480
530
|
`~/.config/ranger/commands.py`. Then run it from within [`ranger`][ranger] by
|
|
481
531
|
typing `:edir`.
|
|
482
532
|
|
|
@@ -499,8 +549,8 @@ class edir(Command):
|
|
|
499
549
|
## Use with Yazi File Manager
|
|
500
550
|
|
|
501
551
|
If you use [`yazi`][yazi] for your file manager then you don't need any special
|
|
502
|
-
configuration. Just type `:edir` from within [`yazi`][yazi] to
|
|
503
|
-
names in the current directory.
|
|
552
|
+
configuration. Just type `:edir` from within [`yazi`][yazi] to rename or delete
|
|
553
|
+
or copy file names in the current directory.
|
|
504
554
|
|
|
505
555
|
You can also replace the standard rename function (`r` key) in [`yazi`][yazi]
|
|
506
556
|
to use `edir` on selected files by adding the following to your
|
|
@@ -509,10 +559,14 @@ to use `edir` on selected files by adding the following to your
|
|
|
509
559
|
```toml
|
|
510
560
|
[[mgr.prepend_keymap]]
|
|
511
561
|
on = "r"
|
|
512
|
-
run = "shell --block -- edir -q %s"
|
|
562
|
+
run = "shell --block -- edir -d0 -q %s"
|
|
513
563
|
desc = "Run edir on selected files/dirs"
|
|
514
564
|
```
|
|
515
565
|
|
|
566
|
+
So press `r` on the current selection to rename (or delete or copy) that single
|
|
567
|
+
file name using `edir`. Alternately, select multiple files (or all files with
|
|
568
|
+
the `yazi` standard key binding `Ctrl+a`), before pressing `r`.
|
|
569
|
+
|
|
516
570
|
## License
|
|
517
571
|
|
|
518
572
|
Copyright (C) 2019 Mark Blakeney. This program is distributed under the
|
|
@@ -140,45 +140,49 @@ following ways:
|
|
|
140
140
|
19. `edir` filters out any duplicate paths you may inadvertently specify
|
|
141
141
|
on it's command line.
|
|
142
142
|
|
|
143
|
-
20. `edir`
|
|
143
|
+
20. `edir` provides an optional configuration file to set default `edir`
|
|
144
|
+
command line options. See [section below](#command-default-options).
|
|
145
|
+
|
|
146
|
+
21. `edir` always invokes a consistent duplicate renaming scheme. E.g. if
|
|
144
147
|
you rename `b`, `c`, `d` all to the same pre-existing name `a` then
|
|
145
|
-
`edir` will rename `b` to `a~`, `c` to `a~1`, `d` to `a~2`.
|
|
148
|
+
`edir` will rename `b` to `a~`, `c` to `a~1`, and `d` to `a~2`.
|
|
146
149
|
Depending on order of operations, `vidir` is not always consistent
|
|
147
|
-
about this, E.g. sometimes it creates a `a~1` with no `a
|
|
148
|
-
|
|
149
|
-
report/address?).
|
|
150
|
+
about this, E.g. sometimes it creates a `a~1` with no `a~`, or starts the
|
|
151
|
+
numbers with `a~2`. (these may be bugs in `vidir` that nobody has ever
|
|
152
|
+
bothered to report/address?).
|
|
153
|
+
|
|
154
|
+
22. Further to the previous item, `edir` allows you to change the format of the
|
|
155
|
+
name of copied files by specifying the `--copy-name-template` option. Refer
|
|
156
|
+
to the [section below](#custom-copied-file-template) for details.
|
|
150
157
|
|
|
151
|
-
|
|
158
|
+
23. `edir` creates the temporary editing file with a `.sh` suffix so
|
|
152
159
|
your EDITOR may syntax highlight the entries. Optionally, you can
|
|
153
160
|
change this default suffix.
|
|
154
161
|
|
|
155
|
-
|
|
162
|
+
24. `edir` provides an optional environment value to add custom options
|
|
156
163
|
to the invocation of your editor. See [section
|
|
157
164
|
below](#edir_editor-environment-variable).
|
|
158
165
|
|
|
159
|
-
|
|
160
|
-
command line options. See [section below](#command-default-options).
|
|
161
|
-
|
|
162
|
-
24. Contrary to what it's name implies, `vidir` actually respects your
|
|
166
|
+
25. Contrary to what it's name implies, `vidir` actually respects your
|
|
163
167
|
`$EDITOR` variable and runs your preferred editor like `edir` does
|
|
164
168
|
but `edir` has been given a generic name to make this more apparent.
|
|
165
169
|
If `$EDITOR` is not set then `edir` uses a default editor
|
|
166
170
|
appropriate to your system.
|
|
167
171
|
|
|
168
|
-
|
|
172
|
+
26. `vidir` returns status code 0 if all files successful, or 1 if any
|
|
169
173
|
error. `edir` returns 0 if all files successful, 1 if some had
|
|
170
174
|
error, or 2 if all had error.
|
|
171
175
|
|
|
172
|
-
|
|
176
|
+
27. `vidir` returns an error when attempting to rename across different
|
|
173
177
|
file systems, which `edir` allows.
|
|
174
178
|
|
|
175
|
-
|
|
179
|
+
28. By default, `edir` shows given paths relative to the current working
|
|
176
180
|
directory so that file names are shorter and easier to read/edit. `vidir`
|
|
177
181
|
shows absolute paths (if they are given like that on the command line, e.g.
|
|
178
182
|
by an external tool). You can disable this relative path behavior in `edir`
|
|
179
183
|
if you want.
|
|
180
184
|
|
|
181
|
-
|
|
185
|
+
29. `edir` always ensures editor line numbers have the same width (e.g.
|
|
182
186
|
`1` to `6` for 6 files, or `01` to `12` for 12 files, etc) so that
|
|
183
187
|
file names always line up justified. This facilitates block editing
|
|
184
188
|
of file names, e.g. using vim's [visual block
|
|
@@ -186,7 +190,7 @@ following ways:
|
|
|
186
190
|
do this so file names can be jagged wrt each other which makes block
|
|
187
191
|
editing awkward.
|
|
188
192
|
|
|
189
|
-
|
|
193
|
+
30. `edir` is very strict about the format of the lines you edit and
|
|
190
194
|
immediately exits with an error message (before changing anything)
|
|
191
195
|
if you format one of the lines incorrectly. All lines in the edited
|
|
192
196
|
list:
|
|
@@ -202,7 +206,7 @@ following ways:
|
|
|
202
206
|
line so an easy way to swap two file names is just to swap their
|
|
203
207
|
numbers.
|
|
204
208
|
|
|
205
|
-
|
|
209
|
+
31. `edir` always actions files consistently. The sequence of
|
|
206
210
|
operations applied is:
|
|
207
211
|
|
|
208
212
|
1. Deleted files are removed and all renamed files and directories
|
|
@@ -216,11 +220,11 @@ following ways:
|
|
|
216
220
|
|
|
217
221
|
4. Remaining deleted directories are removed.
|
|
218
222
|
|
|
219
|
-
In simple terms, remember that files are processed before
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
223
|
+
In simple terms, remember that files are processed before directories so
|
|
224
|
+
you can rename files into a different directory and then delete the
|
|
225
|
+
original directory, all in one edit. However in practice it is far **less
|
|
226
|
+
confusing and less risky** if you perform complicated renames and moves
|
|
227
|
+
across changed directories in distinct steps.
|
|
224
228
|
|
|
225
229
|
## Renames and Deletes in a GIT Repository
|
|
226
230
|
|
|
@@ -377,7 +381,8 @@ Type `edir -h` to view the usage summary:
|
|
|
377
381
|
usage: edir [-h] [-i] [-I] [-a] [-A] [-r] [-R] [-q] [-Q] [-G] [-g] [-t]
|
|
378
382
|
[-T] [--trash-program TRASH_PROGRAM] [-c] [-C] [-d DEPTH] [-F |
|
|
379
383
|
-D] [-L] [-N] [-M] [-S] [-O] [--OP OP] [-E] [-X] [-Y] [-Z]
|
|
380
|
-
[--suffix SUFFIX] [--
|
|
384
|
+
[--suffix SUFFIX] [--copy-name-template COPY_NAME_TEMPLATE]
|
|
385
|
+
[--no-relative] [-V] [--conf]
|
|
381
386
|
[args ...]
|
|
382
387
|
|
|
383
388
|
Command line utility to rename, remove, or copy files and directories directly
|
|
@@ -430,6 +435,10 @@ options:
|
|
|
430
435
|
group directories last (including when sorted)
|
|
431
436
|
-Z, --no-group-dirs negate the options to group directories
|
|
432
437
|
--suffix SUFFIX specify suffix for temp editor file, default=".sh"
|
|
438
|
+
--copy-name-template COPY_NAME_TEMPLATE
|
|
439
|
+
specify copy file/path name template (%F=filename,
|
|
440
|
+
%Nd, %nd(no zero) where "d" is starting number),
|
|
441
|
+
default="%F~%n1"
|
|
433
442
|
--no-relative do not forcibly show paths relative to current working
|
|
434
443
|
directory
|
|
435
444
|
-V, --version show edir version
|
|
@@ -446,23 +455,64 @@ your defaults.
|
|
|
446
455
|
You can use `edir` with [`sudo`][sudo] to rename, delete, or copy system files.
|
|
447
456
|
For improved convenience and security, `edir` runs the editing session as your
|
|
448
457
|
regular user, not as root - similar to how [`sudoedit`][sudoedit] works. This
|
|
449
|
-
approach allows you to use graphical editors (like VS Code), which
|
|
450
|
-
run as root. Use `sudo -E` so that your preferred editor
|
|
451
|
-
`$EDIR_EDITOR` or `$EDITOR` environment variable. For
|
|
452
|
-
delete files in `/etc` using VS Code:
|
|
458
|
+
approach allows you to use graphical editors (like VS Code or Zed etc), which
|
|
459
|
+
normally should not be run as root. Use `sudo -E` so that your preferred editor
|
|
460
|
+
is selected via your `$EDIR_EDITOR` or `$EDITOR` environment variable. For
|
|
461
|
+
example, to rename or delete files in `/etc` using VS Code:
|
|
453
462
|
|
|
454
463
|
```sh
|
|
455
464
|
$ export EDIR_EDITOR="code -nw"
|
|
456
465
|
$ sudo -E edir /etc
|
|
457
466
|
```
|
|
458
467
|
|
|
468
|
+
## Custom Copied File Template
|
|
469
|
+
|
|
470
|
+
When you duplicate a line to copy a file or directory, `edir` ensures the new
|
|
471
|
+
copy has a unique name. By default it uses the same scheme as `vidir`, i.e, if
|
|
472
|
+
you rename `b`, `c`, `d` all to the same pre-existing name `a` then `edir` will
|
|
473
|
+
rename:
|
|
474
|
+
|
|
475
|
+
b -> a~
|
|
476
|
+
c -> a~1
|
|
477
|
+
d -> a~2
|
|
478
|
+
|
|
479
|
+
The format of the copied file name is defined by the `edir` default setting for
|
|
480
|
+
`--copy-name-template="%F~%n1"` where `%F` is the original file name, `%n1`
|
|
481
|
+
means suppress showing the first copy number (i.e. `~` instead of `~1` as in the
|
|
482
|
+
above example) and then start the remaining copies from 1.
|
|
483
|
+
|
|
484
|
+
You can also specify `%Nd` instead of `%nd` in the template to always show the
|
|
485
|
+
copy number even for the first copy, e.g. `--copy-name-template="%F~%N1"` would
|
|
486
|
+
instead produce:
|
|
487
|
+
|
|
488
|
+
b -> a~1
|
|
489
|
+
c -> a~2
|
|
490
|
+
d -> a~3
|
|
491
|
+
|
|
492
|
+
Some example other settings of `--copy-name-template` follow:
|
|
493
|
+
|
|
494
|
+
`--copy-name-template="%F-%N2"`:
|
|
495
|
+
|
|
496
|
+
b -> a-2
|
|
497
|
+
c -> a-3
|
|
498
|
+
d -> a-4
|
|
499
|
+
|
|
500
|
+
`--copy-name-template="%F-copy-%n2"`:
|
|
501
|
+
|
|
502
|
+
b -> a-copy
|
|
503
|
+
c -> a-copy-2
|
|
504
|
+
d -> a-copy-3
|
|
505
|
+
|
|
506
|
+
You are likely to want to set `--copy-name-template` as a [default option](#command-default-options).
|
|
507
|
+
|
|
459
508
|
## Embed in Ranger File Manager
|
|
460
509
|
|
|
461
510
|
In many ways `edir` (and even `vidir`) is better than the [`ranger`][ranger]
|
|
462
511
|
terminal file manager
|
|
463
512
|
[`bulkrename`](https://github.com/ranger/ranger/wiki/Official-user-guide#bulk-renaming)
|
|
464
|
-
command which does not handle name swaps and clashes etc.
|
|
465
|
-
|
|
513
|
+
command which does not handle name swaps and clashes etc. Also, use `edir` to
|
|
514
|
+
delete or copy files, not just rename them. To add `edir` as a command within
|
|
515
|
+
[`ranger`][ranger], add or create the following in
|
|
466
516
|
`~/.config/ranger/commands.py`. Then run it from within [`ranger`][ranger] by
|
|
467
517
|
typing `:edir`.
|
|
468
518
|
|
|
@@ -485,8 +535,8 @@ class edir(Command):
|
|
|
485
535
|
## Use with Yazi File Manager
|
|
486
536
|
|
|
487
537
|
If you use [`yazi`][yazi] for your file manager then you don't need any special
|
|
488
|
-
configuration. Just type `:edir` from within [`yazi`][yazi] to
|
|
489
|
-
names in the current directory.
|
|
538
|
+
configuration. Just type `:edir` from within [`yazi`][yazi] to rename or delete
|
|
539
|
+
or copy file names in the current directory.
|
|
490
540
|
|
|
491
541
|
You can also replace the standard rename function (`r` key) in [`yazi`][yazi]
|
|
492
542
|
to use `edir` on selected files by adding the following to your
|
|
@@ -495,10 +545,14 @@ to use `edir` on selected files by adding the following to your
|
|
|
495
545
|
```toml
|
|
496
546
|
[[mgr.prepend_keymap]]
|
|
497
547
|
on = "r"
|
|
498
|
-
run = "shell --block -- edir -q %s"
|
|
548
|
+
run = "shell --block -- edir -d0 -q %s"
|
|
499
549
|
desc = "Run edir on selected files/dirs"
|
|
500
550
|
```
|
|
501
551
|
|
|
552
|
+
So press `r` on the current selection to rename (or delete or copy) that single
|
|
553
|
+
file name using `edir`. Alternately, select multiple files (or all files with
|
|
554
|
+
the `yazi` standard key binding `Ctrl+a`), before pressing `r`.
|
|
555
|
+
|
|
502
556
|
## License
|
|
503
557
|
|
|
504
558
|
Copyright (C) 2019 Mark Blakeney. This program is distributed under the
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: edir
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.37
|
|
4
4
|
Summary: Utility to rename, remove, and copy files/dirs using your editor
|
|
5
5
|
Author-email: Mark Blakeney <mark.blakeney@bullet-systems.net>
|
|
6
6
|
License-Expression: GPL-3.0-or-later
|
|
@@ -154,45 +154,49 @@ following ways:
|
|
|
154
154
|
19. `edir` filters out any duplicate paths you may inadvertently specify
|
|
155
155
|
on it's command line.
|
|
156
156
|
|
|
157
|
-
20. `edir`
|
|
157
|
+
20. `edir` provides an optional configuration file to set default `edir`
|
|
158
|
+
command line options. See [section below](#command-default-options).
|
|
159
|
+
|
|
160
|
+
21. `edir` always invokes a consistent duplicate renaming scheme. E.g. if
|
|
158
161
|
you rename `b`, `c`, `d` all to the same pre-existing name `a` then
|
|
159
|
-
`edir` will rename `b` to `a~`, `c` to `a~1`, `d` to `a~2`.
|
|
162
|
+
`edir` will rename `b` to `a~`, `c` to `a~1`, and `d` to `a~2`.
|
|
160
163
|
Depending on order of operations, `vidir` is not always consistent
|
|
161
|
-
about this, E.g. sometimes it creates a `a~1` with no `a
|
|
162
|
-
|
|
163
|
-
report/address?).
|
|
164
|
+
about this, E.g. sometimes it creates a `a~1` with no `a~`, or starts the
|
|
165
|
+
numbers with `a~2`. (these may be bugs in `vidir` that nobody has ever
|
|
166
|
+
bothered to report/address?).
|
|
167
|
+
|
|
168
|
+
22. Further to the previous item, `edir` allows you to change the format of the
|
|
169
|
+
name of copied files by specifying the `--copy-name-template` option. Refer
|
|
170
|
+
to the [section below](#custom-copied-file-template) for details.
|
|
164
171
|
|
|
165
|
-
|
|
172
|
+
23. `edir` creates the temporary editing file with a `.sh` suffix so
|
|
166
173
|
your EDITOR may syntax highlight the entries. Optionally, you can
|
|
167
174
|
change this default suffix.
|
|
168
175
|
|
|
169
|
-
|
|
176
|
+
24. `edir` provides an optional environment value to add custom options
|
|
170
177
|
to the invocation of your editor. See [section
|
|
171
178
|
below](#edir_editor-environment-variable).
|
|
172
179
|
|
|
173
|
-
|
|
174
|
-
command line options. See [section below](#command-default-options).
|
|
175
|
-
|
|
176
|
-
24. Contrary to what it's name implies, `vidir` actually respects your
|
|
180
|
+
25. Contrary to what it's name implies, `vidir` actually respects your
|
|
177
181
|
`$EDITOR` variable and runs your preferred editor like `edir` does
|
|
178
182
|
but `edir` has been given a generic name to make this more apparent.
|
|
179
183
|
If `$EDITOR` is not set then `edir` uses a default editor
|
|
180
184
|
appropriate to your system.
|
|
181
185
|
|
|
182
|
-
|
|
186
|
+
26. `vidir` returns status code 0 if all files successful, or 1 if any
|
|
183
187
|
error. `edir` returns 0 if all files successful, 1 if some had
|
|
184
188
|
error, or 2 if all had error.
|
|
185
189
|
|
|
186
|
-
|
|
190
|
+
27. `vidir` returns an error when attempting to rename across different
|
|
187
191
|
file systems, which `edir` allows.
|
|
188
192
|
|
|
189
|
-
|
|
193
|
+
28. By default, `edir` shows given paths relative to the current working
|
|
190
194
|
directory so that file names are shorter and easier to read/edit. `vidir`
|
|
191
195
|
shows absolute paths (if they are given like that on the command line, e.g.
|
|
192
196
|
by an external tool). You can disable this relative path behavior in `edir`
|
|
193
197
|
if you want.
|
|
194
198
|
|
|
195
|
-
|
|
199
|
+
29. `edir` always ensures editor line numbers have the same width (e.g.
|
|
196
200
|
`1` to `6` for 6 files, or `01` to `12` for 12 files, etc) so that
|
|
197
201
|
file names always line up justified. This facilitates block editing
|
|
198
202
|
of file names, e.g. using vim's [visual block
|
|
@@ -200,7 +204,7 @@ following ways:
|
|
|
200
204
|
do this so file names can be jagged wrt each other which makes block
|
|
201
205
|
editing awkward.
|
|
202
206
|
|
|
203
|
-
|
|
207
|
+
30. `edir` is very strict about the format of the lines you edit and
|
|
204
208
|
immediately exits with an error message (before changing anything)
|
|
205
209
|
if you format one of the lines incorrectly. All lines in the edited
|
|
206
210
|
list:
|
|
@@ -216,7 +220,7 @@ following ways:
|
|
|
216
220
|
line so an easy way to swap two file names is just to swap their
|
|
217
221
|
numbers.
|
|
218
222
|
|
|
219
|
-
|
|
223
|
+
31. `edir` always actions files consistently. The sequence of
|
|
220
224
|
operations applied is:
|
|
221
225
|
|
|
222
226
|
1. Deleted files are removed and all renamed files and directories
|
|
@@ -230,11 +234,11 @@ following ways:
|
|
|
230
234
|
|
|
231
235
|
4. Remaining deleted directories are removed.
|
|
232
236
|
|
|
233
|
-
In simple terms, remember that files are processed before
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
237
|
+
In simple terms, remember that files are processed before directories so
|
|
238
|
+
you can rename files into a different directory and then delete the
|
|
239
|
+
original directory, all in one edit. However in practice it is far **less
|
|
240
|
+
confusing and less risky** if you perform complicated renames and moves
|
|
241
|
+
across changed directories in distinct steps.
|
|
238
242
|
|
|
239
243
|
## Renames and Deletes in a GIT Repository
|
|
240
244
|
|
|
@@ -391,7 +395,8 @@ Type `edir -h` to view the usage summary:
|
|
|
391
395
|
usage: edir [-h] [-i] [-I] [-a] [-A] [-r] [-R] [-q] [-Q] [-G] [-g] [-t]
|
|
392
396
|
[-T] [--trash-program TRASH_PROGRAM] [-c] [-C] [-d DEPTH] [-F |
|
|
393
397
|
-D] [-L] [-N] [-M] [-S] [-O] [--OP OP] [-E] [-X] [-Y] [-Z]
|
|
394
|
-
[--suffix SUFFIX] [--
|
|
398
|
+
[--suffix SUFFIX] [--copy-name-template COPY_NAME_TEMPLATE]
|
|
399
|
+
[--no-relative] [-V] [--conf]
|
|
395
400
|
[args ...]
|
|
396
401
|
|
|
397
402
|
Command line utility to rename, remove, or copy files and directories directly
|
|
@@ -444,6 +449,10 @@ options:
|
|
|
444
449
|
group directories last (including when sorted)
|
|
445
450
|
-Z, --no-group-dirs negate the options to group directories
|
|
446
451
|
--suffix SUFFIX specify suffix for temp editor file, default=".sh"
|
|
452
|
+
--copy-name-template COPY_NAME_TEMPLATE
|
|
453
|
+
specify copy file/path name template (%F=filename,
|
|
454
|
+
%Nd, %nd(no zero) where "d" is starting number),
|
|
455
|
+
default="%F~%n1"
|
|
447
456
|
--no-relative do not forcibly show paths relative to current working
|
|
448
457
|
directory
|
|
449
458
|
-V, --version show edir version
|
|
@@ -460,23 +469,64 @@ your defaults.
|
|
|
460
469
|
You can use `edir` with [`sudo`][sudo] to rename, delete, or copy system files.
|
|
461
470
|
For improved convenience and security, `edir` runs the editing session as your
|
|
462
471
|
regular user, not as root - similar to how [`sudoedit`][sudoedit] works. This
|
|
463
|
-
approach allows you to use graphical editors (like VS Code), which
|
|
464
|
-
run as root. Use `sudo -E` so that your preferred editor
|
|
465
|
-
`$EDIR_EDITOR` or `$EDITOR` environment variable. For
|
|
466
|
-
delete files in `/etc` using VS Code:
|
|
472
|
+
approach allows you to use graphical editors (like VS Code or Zed etc), which
|
|
473
|
+
normally should not be run as root. Use `sudo -E` so that your preferred editor
|
|
474
|
+
is selected via your `$EDIR_EDITOR` or `$EDITOR` environment variable. For
|
|
475
|
+
example, to rename or delete files in `/etc` using VS Code:
|
|
467
476
|
|
|
468
477
|
```sh
|
|
469
478
|
$ export EDIR_EDITOR="code -nw"
|
|
470
479
|
$ sudo -E edir /etc
|
|
471
480
|
```
|
|
472
481
|
|
|
482
|
+
## Custom Copied File Template
|
|
483
|
+
|
|
484
|
+
When you duplicate a line to copy a file or directory, `edir` ensures the new
|
|
485
|
+
copy has a unique name. By default it uses the same scheme as `vidir`, i.e, if
|
|
486
|
+
you rename `b`, `c`, `d` all to the same pre-existing name `a` then `edir` will
|
|
487
|
+
rename:
|
|
488
|
+
|
|
489
|
+
b -> a~
|
|
490
|
+
c -> a~1
|
|
491
|
+
d -> a~2
|
|
492
|
+
|
|
493
|
+
The format of the copied file name is defined by the `edir` default setting for
|
|
494
|
+
`--copy-name-template="%F~%n1"` where `%F` is the original file name, `%n1`
|
|
495
|
+
means suppress showing the first copy number (i.e. `~` instead of `~1` as in the
|
|
496
|
+
above example) and then start the remaining copies from 1.
|
|
497
|
+
|
|
498
|
+
You can also specify `%Nd` instead of `%nd` in the template to always show the
|
|
499
|
+
copy number even for the first copy, e.g. `--copy-name-template="%F~%N1"` would
|
|
500
|
+
instead produce:
|
|
501
|
+
|
|
502
|
+
b -> a~1
|
|
503
|
+
c -> a~2
|
|
504
|
+
d -> a~3
|
|
505
|
+
|
|
506
|
+
Some example other settings of `--copy-name-template` follow:
|
|
507
|
+
|
|
508
|
+
`--copy-name-template="%F-%N2"`:
|
|
509
|
+
|
|
510
|
+
b -> a-2
|
|
511
|
+
c -> a-3
|
|
512
|
+
d -> a-4
|
|
513
|
+
|
|
514
|
+
`--copy-name-template="%F-copy-%n2"`:
|
|
515
|
+
|
|
516
|
+
b -> a-copy
|
|
517
|
+
c -> a-copy-2
|
|
518
|
+
d -> a-copy-3
|
|
519
|
+
|
|
520
|
+
You are likely to want to set `--copy-name-template` as a [default option](#command-default-options).
|
|
521
|
+
|
|
473
522
|
## Embed in Ranger File Manager
|
|
474
523
|
|
|
475
524
|
In many ways `edir` (and even `vidir`) is better than the [`ranger`][ranger]
|
|
476
525
|
terminal file manager
|
|
477
526
|
[`bulkrename`](https://github.com/ranger/ranger/wiki/Official-user-guide#bulk-renaming)
|
|
478
|
-
command which does not handle name swaps and clashes etc.
|
|
479
|
-
|
|
527
|
+
command which does not handle name swaps and clashes etc. Also, use `edir` to
|
|
528
|
+
delete or copy files, not just rename them. To add `edir` as a command within
|
|
529
|
+
[`ranger`][ranger], add or create the following in
|
|
480
530
|
`~/.config/ranger/commands.py`. Then run it from within [`ranger`][ranger] by
|
|
481
531
|
typing `:edir`.
|
|
482
532
|
|
|
@@ -499,8 +549,8 @@ class edir(Command):
|
|
|
499
549
|
## Use with Yazi File Manager
|
|
500
550
|
|
|
501
551
|
If you use [`yazi`][yazi] for your file manager then you don't need any special
|
|
502
|
-
configuration. Just type `:edir` from within [`yazi`][yazi] to
|
|
503
|
-
names in the current directory.
|
|
552
|
+
configuration. Just type `:edir` from within [`yazi`][yazi] to rename or delete
|
|
553
|
+
or copy file names in the current directory.
|
|
504
554
|
|
|
505
555
|
You can also replace the standard rename function (`r` key) in [`yazi`][yazi]
|
|
506
556
|
to use `edir` on selected files by adding the following to your
|
|
@@ -509,10 +559,14 @@ to use `edir` on selected files by adding the following to your
|
|
|
509
559
|
```toml
|
|
510
560
|
[[mgr.prepend_keymap]]
|
|
511
561
|
on = "r"
|
|
512
|
-
run = "shell --block -- edir -q %s"
|
|
562
|
+
run = "shell --block -- edir -d0 -q %s"
|
|
513
563
|
desc = "Run edir on selected files/dirs"
|
|
514
564
|
```
|
|
515
565
|
|
|
566
|
+
So press `r` on the current selection to rename (or delete or copy) that single
|
|
567
|
+
file name using `edir`. Alternately, select multiple files (or all files with
|
|
568
|
+
the `yazi` standard key binding `Ctrl+a`), before pressing `r`.
|
|
569
|
+
|
|
516
570
|
## License
|
|
517
571
|
|
|
518
572
|
Copyright (C) 2019 Mark Blakeney. This program is distributed under the
|
{edir-2.35 → edir-2.37}/edir.py
RENAMED
|
@@ -12,6 +12,7 @@ from __future__ import annotations
|
|
|
12
12
|
|
|
13
13
|
import itertools
|
|
14
14
|
import os
|
|
15
|
+
import re
|
|
15
16
|
import shlex
|
|
16
17
|
import shutil
|
|
17
18
|
import subprocess
|
|
@@ -19,6 +20,7 @@ import sys
|
|
|
19
20
|
import tempfile
|
|
20
21
|
from collections.abc import Callable, Iterable, Sequence
|
|
21
22
|
from pathlib import Path
|
|
23
|
+
from typing import NoReturn
|
|
22
24
|
|
|
23
25
|
import argparse_from_file as argparse
|
|
24
26
|
|
|
@@ -57,6 +59,7 @@ cwd = Path.cwd()
|
|
|
57
59
|
|
|
58
60
|
EDITORS = {'Windows': 'notepad', 'Darwin': 'open -e', 'default': 'vim'}
|
|
59
61
|
|
|
62
|
+
|
|
60
63
|
def get_default_editor() -> str:
|
|
61
64
|
"Return default editor for this system"
|
|
62
65
|
from platform import system
|
|
@@ -81,7 +84,7 @@ def make_editor_command(filename: str, sudo_user: str) -> tuple[str, list[str]]:
|
|
|
81
84
|
return editor, editcmd
|
|
82
85
|
|
|
83
86
|
|
|
84
|
-
def
|
|
87
|
+
def edit_file(editor: str, editcmd: list[str]) -> None:
|
|
85
88
|
"Run the editor command"
|
|
86
89
|
|
|
87
90
|
# Run the editor ..
|
|
@@ -96,6 +99,23 @@ def editfile(editor: str, editcmd: list[str]) -> None:
|
|
|
96
99
|
sys.exit(f'ERROR: "{editor}" returned error {res.returncode}')
|
|
97
100
|
|
|
98
101
|
|
|
102
|
+
def edit_file_conf(conf_file: Path) -> None:
|
|
103
|
+
"Edit the startup options configuration file"
|
|
104
|
+
conf_file.parent.mkdir(parents=True, exist_ok=True)
|
|
105
|
+
|
|
106
|
+
if not conf_file.is_file() or conf_file.stat().st_size == 0:
|
|
107
|
+
conf_file.write_text(
|
|
108
|
+
'# Add your default edir options, one option per line. Comments are ignored.\n'
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
editor = os.getenv('EDITOR') or get_default_editor()
|
|
112
|
+
edit_file(editor, [editor, str(conf_file)])
|
|
113
|
+
|
|
114
|
+
# Remove the edited config file if it is empty
|
|
115
|
+
if conf_file.is_file() and conf_file.stat().st_size == 0:
|
|
116
|
+
conf_file.unlink()
|
|
117
|
+
|
|
118
|
+
|
|
99
119
|
def log(
|
|
100
120
|
action: str, msg: str, error: str | None = None, *, prompt: bool = False
|
|
101
121
|
) -> None:
|
|
@@ -222,6 +242,46 @@ def removeprefix(s: str, prefix: str) -> str:
|
|
|
222
242
|
return s[len(prefix) :] if s.startswith(prefix) else s
|
|
223
243
|
|
|
224
244
|
|
|
245
|
+
class CopyNameTemplate:
|
|
246
|
+
"Class to manage copy file/path name template"
|
|
247
|
+
|
|
248
|
+
DEFAULT = '%F~%n1'
|
|
249
|
+
HELP = (
|
|
250
|
+
'specify copy file/path name template (%%F=filename, %%Nd, %%nd(no zero) '
|
|
251
|
+
'where "d" is starting number), default="%(default)s"'
|
|
252
|
+
)
|
|
253
|
+
|
|
254
|
+
def __init__(self, template: str) -> None:
|
|
255
|
+
"Create a template for copy file/path names from given name"
|
|
256
|
+
|
|
257
|
+
def _exit(msg: str) -> NoReturn:
|
|
258
|
+
sys.exit(f'ERROR: --copy-name-template "{template}" {msg}')
|
|
259
|
+
|
|
260
|
+
if '%F' not in template:
|
|
261
|
+
_exit('must contain "%F" for filename')
|
|
262
|
+
|
|
263
|
+
m = re.search(r'%[nN]\d+', template)
|
|
264
|
+
if not m:
|
|
265
|
+
_exit('must contain "%nd" or "%Nd" for count')
|
|
266
|
+
|
|
267
|
+
if len(m.groups()) > 1:
|
|
268
|
+
_exit('can contain only one "%nd" or "%Nd" specifier for count')
|
|
269
|
+
|
|
270
|
+
numstr = m.group(0)
|
|
271
|
+
self.count_start = int(numstr[2:])
|
|
272
|
+
self.include_first = numstr[1] == 'N'
|
|
273
|
+
|
|
274
|
+
if not self.include_first:
|
|
275
|
+
self.count_start -= 1
|
|
276
|
+
|
|
277
|
+
self.template = template.replace('%F', '{name}').replace(numstr, '{num}')
|
|
278
|
+
|
|
279
|
+
def create(self, name: str, num: int) -> str:
|
|
280
|
+
"Return a copy name from the template for given name and count"
|
|
281
|
+
numstr = str(num + self.count_start) if num > 0 or self.include_first else ''
|
|
282
|
+
return self.template.format(name=name, num=numstr)
|
|
283
|
+
|
|
284
|
+
|
|
225
285
|
class Fpath:
|
|
226
286
|
"Class to manage each instance of a file/dir"
|
|
227
287
|
|
|
@@ -260,10 +320,14 @@ class Fpath:
|
|
|
260
320
|
for c in itertools.count():
|
|
261
321
|
if not path.is_symlink() and not path.exists():
|
|
262
322
|
break
|
|
263
|
-
path = path.with_name(name
|
|
323
|
+
path = path.with_name(args._copy_name(name, c))
|
|
264
324
|
|
|
265
325
|
return path
|
|
266
326
|
|
|
327
|
+
def changed(self, newpath: Path | None = None) -> bool:
|
|
328
|
+
"Return True if path has been changed"
|
|
329
|
+
return str(newpath or self.newpath) != self.repr
|
|
330
|
+
|
|
267
331
|
def copy(self, pathdest: Path) -> str | None:
|
|
268
332
|
"Copy given pathsrc to pathdest"
|
|
269
333
|
if self.is_dir:
|
|
@@ -351,7 +415,7 @@ class Fpath:
|
|
|
351
415
|
"Log all pending changes for this path"
|
|
352
416
|
if not self.newpath:
|
|
353
417
|
log('remove', f'"{self.diagrepr}"{self.note}', prompt=True)
|
|
354
|
-
elif self.
|
|
418
|
+
elif self.changed():
|
|
355
419
|
log(
|
|
356
420
|
'rename',
|
|
357
421
|
f'"{self.diagrepr}" to "{self.newpath}{self.appdash}"',
|
|
@@ -481,7 +545,7 @@ class Fpath:
|
|
|
481
545
|
newpath = Path(pathstr)
|
|
482
546
|
|
|
483
547
|
if path.newpath:
|
|
484
|
-
if
|
|
548
|
+
if path.changed(newpath) and newpath not in path.copies:
|
|
485
549
|
path.copies.append(newpath)
|
|
486
550
|
else:
|
|
487
551
|
path.newpath = newpath
|
|
@@ -517,13 +581,13 @@ class Fpath:
|
|
|
517
581
|
shutil.chown(fpath, sudo_user)
|
|
518
582
|
|
|
519
583
|
# Invoke editor on file containing the list of paths
|
|
520
|
-
|
|
584
|
+
edit_file(editor, editcmd)
|
|
521
585
|
|
|
522
586
|
# Read the changed paths from the file
|
|
523
587
|
cls.readfile(fpath)
|
|
524
588
|
|
|
525
589
|
# Reduce paths to those that were removed or changed by the user
|
|
526
|
-
paths = [p for p in cls.paths if p.
|
|
590
|
+
paths = [p for p in cls.paths if p.changed() or p.copies]
|
|
527
591
|
|
|
528
592
|
if not paths:
|
|
529
593
|
return []
|
|
@@ -747,6 +811,11 @@ def main() -> int:
|
|
|
747
811
|
default=SUFFIX,
|
|
748
812
|
help='specify suffix for temp editor file, default="%(default)s"',
|
|
749
813
|
)
|
|
814
|
+
opt.add_argument(
|
|
815
|
+
'--copy-name-template',
|
|
816
|
+
default=CopyNameTemplate.DEFAULT,
|
|
817
|
+
help=CopyNameTemplate.HELP,
|
|
818
|
+
)
|
|
750
819
|
opt.add_argument(
|
|
751
820
|
'--no-relative',
|
|
752
821
|
action='store_true',
|
|
@@ -779,22 +848,8 @@ def main() -> int:
|
|
|
779
848
|
# Edit the configuration file and exit
|
|
780
849
|
if not (conf_file := opt.from_file_path):
|
|
781
850
|
opt.error('No configuration file path determined.')
|
|
782
|
-
return 1
|
|
783
|
-
|
|
784
|
-
conf_file.parent.mkdir(parents=True, exist_ok=True)
|
|
785
|
-
|
|
786
|
-
if not conf_file.is_file() or conf_file.stat().st_size == 0:
|
|
787
|
-
conf_file.write_text(
|
|
788
|
-
'# Add your default edir options, one option per line. Comments are ignored.\n'
|
|
789
|
-
)
|
|
790
|
-
|
|
791
|
-
editor = os.getenv('EDITOR') or get_default_editor()
|
|
792
|
-
editfile(editor, [editor, str(conf_file)])
|
|
793
|
-
|
|
794
|
-
# Remove the edited config file if it is empty
|
|
795
|
-
if conf_file.is_file() and conf_file.stat().st_size == 0:
|
|
796
|
-
conf_file.unlink()
|
|
797
851
|
|
|
852
|
+
edit_file_conf(conf_file)
|
|
798
853
|
return 0
|
|
799
854
|
|
|
800
855
|
if args.trash:
|
|
@@ -803,6 +858,8 @@ def main() -> int:
|
|
|
803
858
|
|
|
804
859
|
args.trash_program = args.trash_program.split()
|
|
805
860
|
|
|
861
|
+
args._copy_name = CopyNameTemplate(args.copy_name_template).create
|
|
862
|
+
|
|
806
863
|
# Check if we are in a git repo
|
|
807
864
|
if args.git != 0:
|
|
808
865
|
out, giterr = run(('git', 'ls-files'))
|
|
@@ -869,7 +926,7 @@ def main() -> int:
|
|
|
869
926
|
# files.
|
|
870
927
|
for p in paths:
|
|
871
928
|
if p.newpath:
|
|
872
|
-
if p.
|
|
929
|
+
if p.changed():
|
|
873
930
|
if err := p.rename_temp():
|
|
874
931
|
log('rename', f'"{p.diagrepr}" to "{p.newpath}{p.appdash}"', err)
|
|
875
932
|
elif not p.is_dir:
|
{edir-2.35 → edir-2.37}/justfile
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|