edir 2.33__tar.gz → 2.35__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.33/edir.egg-info → edir-2.35}/PKG-INFO +68 -33
- {edir-2.33 → edir-2.35}/README.md +66 -32
- {edir-2.33 → edir-2.35/edir.egg-info}/PKG-INFO +68 -33
- {edir-2.33 → edir-2.35}/edir.egg-info/SOURCES.txt +1 -1
- {edir-2.33 → edir-2.35}/edir.egg-info/requires.txt +1 -0
- {edir-2.33 → edir-2.35}/edir.py +113 -19
- edir-2.35/justfile +23 -0
- {edir-2.33 → edir-2.35}/pyproject.toml +1 -0
- edir-2.33/Makefile +0 -25
- {edir-2.33 → edir-2.35}/.gitignore +0 -0
- {edir-2.33 → edir-2.35}/edir.egg-info/dependency_links.txt +0 -0
- {edir-2.33 → edir-2.35}/edir.egg-info/entry_points.txt +0 -0
- {edir-2.33 → edir-2.35}/edir.egg-info/top_level.txt +0 -0
- {edir-2.33 → edir-2.35}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: edir
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.35
|
|
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
|
|
@@ -10,6 +10,7 @@ Classifier: Programming Language :: Python :: 3
|
|
|
10
10
|
Requires-Python: >=3.8
|
|
11
11
|
Description-Content-Type: text/markdown
|
|
12
12
|
Requires-Dist: argparse-from-file
|
|
13
|
+
Requires-Dist: natsort
|
|
13
14
|
|
|
14
15
|
## EDIR - Rename, Remove, and Copy Files and Directories Using Your Editor
|
|
15
16
|
[](https://pypi.org/project/edir/)
|
|
@@ -127,9 +128,9 @@ following ways:
|
|
|
127
128
|
|
|
128
129
|
14. `edir` adds a `-d/--depth` option to edit to the specified directory
|
|
129
130
|
depth. The default is 1 so `edir a` (if a is a directory) will edit
|
|
130
|
-
names to `a/*`, `edir -d2 a` will edit names to `a/*/*`, etc.
|
|
131
|
-
-d0 a` will just edit the `a` name directly. Can specify `-d -1`
|
|
132
|
-
edit to all depths (or use a large positive number).
|
|
131
|
+
names to `a/*`, `edir -d2 a` will edit names to `a/*/*`, etc.
|
|
132
|
+
`edir -d0 a` will just edit the `a` name directly. Can specify `-d -1`
|
|
133
|
+
to edit to all depths (or use a large positive number).
|
|
133
134
|
|
|
134
135
|
15. `edir` adds a [`-t/--trash` option](#using-trash) to remove to your
|
|
135
136
|
[Trash][trash].
|
|
@@ -139,9 +140,9 @@ following ways:
|
|
|
139
140
|
do deletions but you can specify any alternative trash program, see
|
|
140
141
|
[section below](#using-trash).
|
|
141
142
|
|
|
142
|
-
16. `edir` adds `-N/--sort-name
|
|
143
|
-
to sort the paths when listed in your editor.
|
|
144
|
-
`-E/--sort-reverse` option to reverse the order.
|
|
143
|
+
16. `edir` adds `-N/--sort-name`, `-M/--sort-time`, `-S/--sort-size`, and
|
|
144
|
+
`-O/--sort-natural` options to sort the paths when listed in your editor.
|
|
145
|
+
There is also a `-E/--sort-reverse` option to reverse the order.
|
|
145
146
|
|
|
146
147
|
17. `edir` adds `-X/--group-dirs-first` and `-Y/--group-dirs-last`
|
|
147
148
|
options to display directories grouped together, either first or
|
|
@@ -185,7 +186,13 @@ following ways:
|
|
|
185
186
|
26. `vidir` returns an error when attempting to rename across different
|
|
186
187
|
file systems, which `edir` allows.
|
|
187
188
|
|
|
188
|
-
27. `edir`
|
|
189
|
+
27. By default, `edir` shows given paths relative to the current working
|
|
190
|
+
directory so that file names are shorter and easier to read/edit. `vidir`
|
|
191
|
+
shows absolute paths (if they are given like that on the command line, e.g.
|
|
192
|
+
by an external tool). You can disable this relative path behavior in `edir`
|
|
193
|
+
if you want.
|
|
194
|
+
|
|
195
|
+
28. `edir` always ensures editor line numbers have the same width (e.g.
|
|
189
196
|
`1` to `6` for 6 files, or `01` to `12` for 12 files, etc) so that
|
|
190
197
|
file names always line up justified. This facilitates block editing
|
|
191
198
|
of file names, e.g. using vim's [visual block
|
|
@@ -193,7 +200,7 @@ following ways:
|
|
|
193
200
|
do this so file names can be jagged wrt each other which makes block
|
|
194
201
|
editing awkward.
|
|
195
202
|
|
|
196
|
-
|
|
203
|
+
29. `edir` is very strict about the format of the lines you edit and
|
|
197
204
|
immediately exits with an error message (before changing anything)
|
|
198
205
|
if you format one of the lines incorrectly. All lines in the edited
|
|
199
206
|
list:
|
|
@@ -209,7 +216,7 @@ following ways:
|
|
|
209
216
|
line so an easy way to swap two file names is just to swap their
|
|
210
217
|
numbers.
|
|
211
218
|
|
|
212
|
-
|
|
219
|
+
30. `edir` always actions files consistently. The sequence of
|
|
213
220
|
operations applied is:
|
|
214
221
|
|
|
215
222
|
1. Deleted files are removed and all renamed files and directories
|
|
@@ -260,7 +267,7 @@ temporarily.
|
|
|
260
267
|
|
|
261
268
|
You can specify an alternative trash program, e.g.
|
|
262
269
|
[`trash-d`](https://github.com/rushsteve1/trash-d), or
|
|
263
|
-
[`gio trash`](https://man.archlinux.org/man/gio.1
|
|
270
|
+
[`gio trash`](https://man.archlinux.org/man/gio.1), or
|
|
264
271
|
[`gtrash put`](https://github.com/umlx5h/gtrash),
|
|
265
272
|
by setting the `--trash-program` option. Most likely you
|
|
266
273
|
want to set this as a [default option](#command-default-options).
|
|
@@ -338,12 +345,16 @@ command line arguments. Comments in the file (i.e. starting with a `#`)
|
|
|
338
345
|
are ignored. Type `edir -h` to see all [supported
|
|
339
346
|
options](#command-line-options).
|
|
340
347
|
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
348
|
+
Some options, e.g. `--recurse`, which can be set as a default option, provide
|
|
349
|
+
another "on-the-fly" negation option to temporarily override and disable the
|
|
350
|
+
default using the command line. E.g. use `-R` to override default `--recurse`.
|
|
351
|
+
See the usage summary for details.
|
|
352
|
+
|
|
353
|
+
You can conveniently edit your default options file using the `--conf` option:
|
|
354
|
+
|
|
355
|
+
```sh
|
|
356
|
+
$ edir --conf
|
|
357
|
+
```
|
|
347
358
|
|
|
348
359
|
## Examples
|
|
349
360
|
|
|
@@ -379,8 +390,8 @@ Type `edir -h` to view the usage summary:
|
|
|
379
390
|
```
|
|
380
391
|
usage: edir [-h] [-i] [-I] [-a] [-A] [-r] [-R] [-q] [-Q] [-G] [-g] [-t]
|
|
381
392
|
[-T] [--trash-program TRASH_PROGRAM] [-c] [-C] [-d DEPTH] [-F |
|
|
382
|
-
-D] [-L] [-N] [-M] [-S] [-E] [-X] [-Y] [-Z]
|
|
383
|
-
[-V]
|
|
393
|
+
-D] [-L] [-N] [-M] [-S] [-O] [--OP OP] [-E] [-X] [-Y] [-Z]
|
|
394
|
+
[--suffix SUFFIX] [--no-relative] [-V] [--conf]
|
|
384
395
|
[args ...]
|
|
385
396
|
|
|
386
397
|
Command line utility to rename, remove, or copy files and directories directly
|
|
@@ -420,32 +431,42 @@ options:
|
|
|
420
431
|
-N, --sort-name sort paths in file by name, alphabetically
|
|
421
432
|
-M, --sort-time sort paths in file by time, oldest first
|
|
422
433
|
-S, --sort-size sort paths in file by size, smallest first
|
|
423
|
-
-
|
|
434
|
+
-O, --sort-natural sort paths using natural sort (using natsort package)
|
|
435
|
+
--OP, --sort-natural-opt OP
|
|
436
|
+
pass given option[s] to natsort, optionally
|
|
437
|
+
delimitered by "," or "|", see options at
|
|
438
|
+
https://natsort.readthedocs.io/en/stable/api.html#the-
|
|
439
|
+
ns-enum
|
|
440
|
+
-E, --sort-reverse sort paths (by name/time/size/natural) in reverse
|
|
424
441
|
-X, --group-dirs-first
|
|
425
442
|
group directories first (including when sorted)
|
|
426
443
|
-Y, --group-dirs-last
|
|
427
444
|
group directories last (including when sorted)
|
|
428
445
|
-Z, --no-group-dirs negate the options to group directories
|
|
429
446
|
--suffix SUFFIX specify suffix for temp editor file, default=".sh"
|
|
447
|
+
--no-relative do not forcibly show paths relative to current working
|
|
448
|
+
directory
|
|
430
449
|
-V, --version show edir version
|
|
450
|
+
--conf just invoke your editor on your startup options
|
|
451
|
+
configuration file
|
|
431
452
|
|
|
432
|
-
Note you can set default starting options in
|
|
433
|
-
|
|
434
|
-
|
|
453
|
+
Note you can set default starting options in ~/.config/edir-flags.conf. The
|
|
454
|
+
negation options (i.e. the --no-* options) allow you to temporarily override
|
|
455
|
+
your defaults.
|
|
435
456
|
```
|
|
436
457
|
|
|
437
458
|
## Running with sudo
|
|
438
459
|
|
|
439
|
-
You can use `edir` with `sudo` to rename, delete, or copy system files.
|
|
440
|
-
improved security, `edir` runs the editing session as your
|
|
441
|
-
root - similar to how `sudoedit` works. This
|
|
442
|
-
graphical editors (like VS Code), which should not be
|
|
443
|
-
so that your preferred editor is selected via your
|
|
444
|
-
environment variable. For example, to rename or
|
|
445
|
-
Code:
|
|
460
|
+
You can use `edir` with [`sudo`][sudo] to rename, delete, or copy system files.
|
|
461
|
+
For improved convenience and security, `edir` runs the editing session as your
|
|
462
|
+
regular user, not as root - similar to how [`sudoedit`][sudoedit] works. This
|
|
463
|
+
approach allows you to use graphical editors (like VS Code), which should not be
|
|
464
|
+
run as root. Use `sudo -E` so that your preferred editor is selected via your
|
|
465
|
+
`$EDIR_EDITOR` or `$EDITOR` environment variable. For example, to rename or
|
|
466
|
+
delete files in `/etc` using VS Code:
|
|
446
467
|
|
|
447
468
|
```sh
|
|
448
|
-
$ export EDIR_EDITOR="code -
|
|
469
|
+
$ export EDIR_EDITOR="code -nw"
|
|
449
470
|
$ sudo -E edir /etc
|
|
450
471
|
```
|
|
451
472
|
|
|
@@ -478,7 +499,19 @@ class edir(Command):
|
|
|
478
499
|
## Use with Yazi File Manager
|
|
479
500
|
|
|
480
501
|
If you use [`yazi`][yazi] for your file manager then you don't need any special
|
|
481
|
-
configuration. Just type `:edir` from within [`yazi`][yazi]
|
|
502
|
+
configuration. Just type `:edir` from within [`yazi`][yazi] to edit all file
|
|
503
|
+
names in the current directory.
|
|
504
|
+
|
|
505
|
+
You can also replace the standard rename function (`r` key) in [`yazi`][yazi]
|
|
506
|
+
to use `edir` on selected files by adding the following to your
|
|
507
|
+
`~/.config/yazi/keymap.toml` file:
|
|
508
|
+
|
|
509
|
+
```toml
|
|
510
|
+
[[mgr.prepend_keymap]]
|
|
511
|
+
on = "r"
|
|
512
|
+
run = "shell --block -- edir -q %s"
|
|
513
|
+
desc = "Run edir on selected files/dirs"
|
|
514
|
+
```
|
|
482
515
|
|
|
483
516
|
## License
|
|
484
517
|
|
|
@@ -499,6 +532,8 @@ License at <https://opensource.org/license/gpl-3-0> for more details.
|
|
|
499
532
|
[uvtool]: https://docs.astral.sh/uv/guides/tools/#installing-tools
|
|
500
533
|
[ranger]: https://ranger.github.io/
|
|
501
534
|
[yazi]: https://yazi-rs.github.io/
|
|
502
|
-
[trash]: https://
|
|
535
|
+
[trash]: https://www.freedesktop.org/wiki/Specifications/trash-spec/
|
|
536
|
+
[sudo]: https://man7.org/linux/man-pages/man8/sudo.8.html
|
|
537
|
+
[sudoedit]: https://man7.org/linux/man-pages/man8/sudoedit.8.html
|
|
503
538
|
|
|
504
539
|
<!-- vim: se ai syn=markdown: -->
|
|
@@ -114,9 +114,9 @@ following ways:
|
|
|
114
114
|
|
|
115
115
|
14. `edir` adds a `-d/--depth` option to edit to the specified directory
|
|
116
116
|
depth. The default is 1 so `edir a` (if a is a directory) will edit
|
|
117
|
-
names to `a/*`, `edir -d2 a` will edit names to `a/*/*`, etc.
|
|
118
|
-
-d0 a` will just edit the `a` name directly. Can specify `-d -1`
|
|
119
|
-
edit to all depths (or use a large positive number).
|
|
117
|
+
names to `a/*`, `edir -d2 a` will edit names to `a/*/*`, etc.
|
|
118
|
+
`edir -d0 a` will just edit the `a` name directly. Can specify `-d -1`
|
|
119
|
+
to edit to all depths (or use a large positive number).
|
|
120
120
|
|
|
121
121
|
15. `edir` adds a [`-t/--trash` option](#using-trash) to remove to your
|
|
122
122
|
[Trash][trash].
|
|
@@ -126,9 +126,9 @@ following ways:
|
|
|
126
126
|
do deletions but you can specify any alternative trash program, see
|
|
127
127
|
[section below](#using-trash).
|
|
128
128
|
|
|
129
|
-
16. `edir` adds `-N/--sort-name
|
|
130
|
-
to sort the paths when listed in your editor.
|
|
131
|
-
`-E/--sort-reverse` option to reverse the order.
|
|
129
|
+
16. `edir` adds `-N/--sort-name`, `-M/--sort-time`, `-S/--sort-size`, and
|
|
130
|
+
`-O/--sort-natural` options to sort the paths when listed in your editor.
|
|
131
|
+
There is also a `-E/--sort-reverse` option to reverse the order.
|
|
132
132
|
|
|
133
133
|
17. `edir` adds `-X/--group-dirs-first` and `-Y/--group-dirs-last`
|
|
134
134
|
options to display directories grouped together, either first or
|
|
@@ -172,7 +172,13 @@ following ways:
|
|
|
172
172
|
26. `vidir` returns an error when attempting to rename across different
|
|
173
173
|
file systems, which `edir` allows.
|
|
174
174
|
|
|
175
|
-
27. `edir`
|
|
175
|
+
27. By default, `edir` shows given paths relative to the current working
|
|
176
|
+
directory so that file names are shorter and easier to read/edit. `vidir`
|
|
177
|
+
shows absolute paths (if they are given like that on the command line, e.g.
|
|
178
|
+
by an external tool). You can disable this relative path behavior in `edir`
|
|
179
|
+
if you want.
|
|
180
|
+
|
|
181
|
+
28. `edir` always ensures editor line numbers have the same width (e.g.
|
|
176
182
|
`1` to `6` for 6 files, or `01` to `12` for 12 files, etc) so that
|
|
177
183
|
file names always line up justified. This facilitates block editing
|
|
178
184
|
of file names, e.g. using vim's [visual block
|
|
@@ -180,7 +186,7 @@ following ways:
|
|
|
180
186
|
do this so file names can be jagged wrt each other which makes block
|
|
181
187
|
editing awkward.
|
|
182
188
|
|
|
183
|
-
|
|
189
|
+
29. `edir` is very strict about the format of the lines you edit and
|
|
184
190
|
immediately exits with an error message (before changing anything)
|
|
185
191
|
if you format one of the lines incorrectly. All lines in the edited
|
|
186
192
|
list:
|
|
@@ -196,7 +202,7 @@ following ways:
|
|
|
196
202
|
line so an easy way to swap two file names is just to swap their
|
|
197
203
|
numbers.
|
|
198
204
|
|
|
199
|
-
|
|
205
|
+
30. `edir` always actions files consistently. The sequence of
|
|
200
206
|
operations applied is:
|
|
201
207
|
|
|
202
208
|
1. Deleted files are removed and all renamed files and directories
|
|
@@ -247,7 +253,7 @@ temporarily.
|
|
|
247
253
|
|
|
248
254
|
You can specify an alternative trash program, e.g.
|
|
249
255
|
[`trash-d`](https://github.com/rushsteve1/trash-d), or
|
|
250
|
-
[`gio trash`](https://man.archlinux.org/man/gio.1
|
|
256
|
+
[`gio trash`](https://man.archlinux.org/man/gio.1), or
|
|
251
257
|
[`gtrash put`](https://github.com/umlx5h/gtrash),
|
|
252
258
|
by setting the `--trash-program` option. Most likely you
|
|
253
259
|
want to set this as a [default option](#command-default-options).
|
|
@@ -325,12 +331,16 @@ command line arguments. Comments in the file (i.e. starting with a `#`)
|
|
|
325
331
|
are ignored. Type `edir -h` to see all [supported
|
|
326
332
|
options](#command-line-options).
|
|
327
333
|
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
+
Some options, e.g. `--recurse`, which can be set as a default option, provide
|
|
335
|
+
another "on-the-fly" negation option to temporarily override and disable the
|
|
336
|
+
default using the command line. E.g. use `-R` to override default `--recurse`.
|
|
337
|
+
See the usage summary for details.
|
|
338
|
+
|
|
339
|
+
You can conveniently edit your default options file using the `--conf` option:
|
|
340
|
+
|
|
341
|
+
```sh
|
|
342
|
+
$ edir --conf
|
|
343
|
+
```
|
|
334
344
|
|
|
335
345
|
## Examples
|
|
336
346
|
|
|
@@ -366,8 +376,8 @@ Type `edir -h` to view the usage summary:
|
|
|
366
376
|
```
|
|
367
377
|
usage: edir [-h] [-i] [-I] [-a] [-A] [-r] [-R] [-q] [-Q] [-G] [-g] [-t]
|
|
368
378
|
[-T] [--trash-program TRASH_PROGRAM] [-c] [-C] [-d DEPTH] [-F |
|
|
369
|
-
-D] [-L] [-N] [-M] [-S] [-E] [-X] [-Y] [-Z]
|
|
370
|
-
[-V]
|
|
379
|
+
-D] [-L] [-N] [-M] [-S] [-O] [--OP OP] [-E] [-X] [-Y] [-Z]
|
|
380
|
+
[--suffix SUFFIX] [--no-relative] [-V] [--conf]
|
|
371
381
|
[args ...]
|
|
372
382
|
|
|
373
383
|
Command line utility to rename, remove, or copy files and directories directly
|
|
@@ -407,32 +417,42 @@ options:
|
|
|
407
417
|
-N, --sort-name sort paths in file by name, alphabetically
|
|
408
418
|
-M, --sort-time sort paths in file by time, oldest first
|
|
409
419
|
-S, --sort-size sort paths in file by size, smallest first
|
|
410
|
-
-
|
|
420
|
+
-O, --sort-natural sort paths using natural sort (using natsort package)
|
|
421
|
+
--OP, --sort-natural-opt OP
|
|
422
|
+
pass given option[s] to natsort, optionally
|
|
423
|
+
delimitered by "," or "|", see options at
|
|
424
|
+
https://natsort.readthedocs.io/en/stable/api.html#the-
|
|
425
|
+
ns-enum
|
|
426
|
+
-E, --sort-reverse sort paths (by name/time/size/natural) in reverse
|
|
411
427
|
-X, --group-dirs-first
|
|
412
428
|
group directories first (including when sorted)
|
|
413
429
|
-Y, --group-dirs-last
|
|
414
430
|
group directories last (including when sorted)
|
|
415
431
|
-Z, --no-group-dirs negate the options to group directories
|
|
416
432
|
--suffix SUFFIX specify suffix for temp editor file, default=".sh"
|
|
433
|
+
--no-relative do not forcibly show paths relative to current working
|
|
434
|
+
directory
|
|
417
435
|
-V, --version show edir version
|
|
436
|
+
--conf just invoke your editor on your startup options
|
|
437
|
+
configuration file
|
|
418
438
|
|
|
419
|
-
Note you can set default starting options in
|
|
420
|
-
|
|
421
|
-
|
|
439
|
+
Note you can set default starting options in ~/.config/edir-flags.conf. The
|
|
440
|
+
negation options (i.e. the --no-* options) allow you to temporarily override
|
|
441
|
+
your defaults.
|
|
422
442
|
```
|
|
423
443
|
|
|
424
444
|
## Running with sudo
|
|
425
445
|
|
|
426
|
-
You can use `edir` with `sudo` to rename, delete, or copy system files.
|
|
427
|
-
improved security, `edir` runs the editing session as your
|
|
428
|
-
root - similar to how `sudoedit` works. This
|
|
429
|
-
graphical editors (like VS Code), which should not be
|
|
430
|
-
so that your preferred editor is selected via your
|
|
431
|
-
environment variable. For example, to rename or
|
|
432
|
-
Code:
|
|
446
|
+
You can use `edir` with [`sudo`][sudo] to rename, delete, or copy system files.
|
|
447
|
+
For improved convenience and security, `edir` runs the editing session as your
|
|
448
|
+
regular user, not as root - similar to how [`sudoedit`][sudoedit] works. This
|
|
449
|
+
approach allows you to use graphical editors (like VS Code), which should not be
|
|
450
|
+
run as root. Use `sudo -E` so that your preferred editor is selected via your
|
|
451
|
+
`$EDIR_EDITOR` or `$EDITOR` environment variable. For example, to rename or
|
|
452
|
+
delete files in `/etc` using VS Code:
|
|
433
453
|
|
|
434
454
|
```sh
|
|
435
|
-
$ export EDIR_EDITOR="code -
|
|
455
|
+
$ export EDIR_EDITOR="code -nw"
|
|
436
456
|
$ sudo -E edir /etc
|
|
437
457
|
```
|
|
438
458
|
|
|
@@ -465,7 +485,19 @@ class edir(Command):
|
|
|
465
485
|
## Use with Yazi File Manager
|
|
466
486
|
|
|
467
487
|
If you use [`yazi`][yazi] for your file manager then you don't need any special
|
|
468
|
-
configuration. Just type `:edir` from within [`yazi`][yazi]
|
|
488
|
+
configuration. Just type `:edir` from within [`yazi`][yazi] to edit all file
|
|
489
|
+
names in the current directory.
|
|
490
|
+
|
|
491
|
+
You can also replace the standard rename function (`r` key) in [`yazi`][yazi]
|
|
492
|
+
to use `edir` on selected files by adding the following to your
|
|
493
|
+
`~/.config/yazi/keymap.toml` file:
|
|
494
|
+
|
|
495
|
+
```toml
|
|
496
|
+
[[mgr.prepend_keymap]]
|
|
497
|
+
on = "r"
|
|
498
|
+
run = "shell --block -- edir -q %s"
|
|
499
|
+
desc = "Run edir on selected files/dirs"
|
|
500
|
+
```
|
|
469
501
|
|
|
470
502
|
## License
|
|
471
503
|
|
|
@@ -486,6 +518,8 @@ License at <https://opensource.org/license/gpl-3-0> for more details.
|
|
|
486
518
|
[uvtool]: https://docs.astral.sh/uv/guides/tools/#installing-tools
|
|
487
519
|
[ranger]: https://ranger.github.io/
|
|
488
520
|
[yazi]: https://yazi-rs.github.io/
|
|
489
|
-
[trash]: https://
|
|
521
|
+
[trash]: https://www.freedesktop.org/wiki/Specifications/trash-spec/
|
|
522
|
+
[sudo]: https://man7.org/linux/man-pages/man8/sudo.8.html
|
|
523
|
+
[sudoedit]: https://man7.org/linux/man-pages/man8/sudoedit.8.html
|
|
490
524
|
|
|
491
525
|
<!-- vim: se ai syn=markdown: -->
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: edir
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.35
|
|
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
|
|
@@ -10,6 +10,7 @@ Classifier: Programming Language :: Python :: 3
|
|
|
10
10
|
Requires-Python: >=3.8
|
|
11
11
|
Description-Content-Type: text/markdown
|
|
12
12
|
Requires-Dist: argparse-from-file
|
|
13
|
+
Requires-Dist: natsort
|
|
13
14
|
|
|
14
15
|
## EDIR - Rename, Remove, and Copy Files and Directories Using Your Editor
|
|
15
16
|
[](https://pypi.org/project/edir/)
|
|
@@ -127,9 +128,9 @@ following ways:
|
|
|
127
128
|
|
|
128
129
|
14. `edir` adds a `-d/--depth` option to edit to the specified directory
|
|
129
130
|
depth. The default is 1 so `edir a` (if a is a directory) will edit
|
|
130
|
-
names to `a/*`, `edir -d2 a` will edit names to `a/*/*`, etc.
|
|
131
|
-
-d0 a` will just edit the `a` name directly. Can specify `-d -1`
|
|
132
|
-
edit to all depths (or use a large positive number).
|
|
131
|
+
names to `a/*`, `edir -d2 a` will edit names to `a/*/*`, etc.
|
|
132
|
+
`edir -d0 a` will just edit the `a` name directly. Can specify `-d -1`
|
|
133
|
+
to edit to all depths (or use a large positive number).
|
|
133
134
|
|
|
134
135
|
15. `edir` adds a [`-t/--trash` option](#using-trash) to remove to your
|
|
135
136
|
[Trash][trash].
|
|
@@ -139,9 +140,9 @@ following ways:
|
|
|
139
140
|
do deletions but you can specify any alternative trash program, see
|
|
140
141
|
[section below](#using-trash).
|
|
141
142
|
|
|
142
|
-
16. `edir` adds `-N/--sort-name
|
|
143
|
-
to sort the paths when listed in your editor.
|
|
144
|
-
`-E/--sort-reverse` option to reverse the order.
|
|
143
|
+
16. `edir` adds `-N/--sort-name`, `-M/--sort-time`, `-S/--sort-size`, and
|
|
144
|
+
`-O/--sort-natural` options to sort the paths when listed in your editor.
|
|
145
|
+
There is also a `-E/--sort-reverse` option to reverse the order.
|
|
145
146
|
|
|
146
147
|
17. `edir` adds `-X/--group-dirs-first` and `-Y/--group-dirs-last`
|
|
147
148
|
options to display directories grouped together, either first or
|
|
@@ -185,7 +186,13 @@ following ways:
|
|
|
185
186
|
26. `vidir` returns an error when attempting to rename across different
|
|
186
187
|
file systems, which `edir` allows.
|
|
187
188
|
|
|
188
|
-
27. `edir`
|
|
189
|
+
27. By default, `edir` shows given paths relative to the current working
|
|
190
|
+
directory so that file names are shorter and easier to read/edit. `vidir`
|
|
191
|
+
shows absolute paths (if they are given like that on the command line, e.g.
|
|
192
|
+
by an external tool). You can disable this relative path behavior in `edir`
|
|
193
|
+
if you want.
|
|
194
|
+
|
|
195
|
+
28. `edir` always ensures editor line numbers have the same width (e.g.
|
|
189
196
|
`1` to `6` for 6 files, or `01` to `12` for 12 files, etc) so that
|
|
190
197
|
file names always line up justified. This facilitates block editing
|
|
191
198
|
of file names, e.g. using vim's [visual block
|
|
@@ -193,7 +200,7 @@ following ways:
|
|
|
193
200
|
do this so file names can be jagged wrt each other which makes block
|
|
194
201
|
editing awkward.
|
|
195
202
|
|
|
196
|
-
|
|
203
|
+
29. `edir` is very strict about the format of the lines you edit and
|
|
197
204
|
immediately exits with an error message (before changing anything)
|
|
198
205
|
if you format one of the lines incorrectly. All lines in the edited
|
|
199
206
|
list:
|
|
@@ -209,7 +216,7 @@ following ways:
|
|
|
209
216
|
line so an easy way to swap two file names is just to swap their
|
|
210
217
|
numbers.
|
|
211
218
|
|
|
212
|
-
|
|
219
|
+
30. `edir` always actions files consistently. The sequence of
|
|
213
220
|
operations applied is:
|
|
214
221
|
|
|
215
222
|
1. Deleted files are removed and all renamed files and directories
|
|
@@ -260,7 +267,7 @@ temporarily.
|
|
|
260
267
|
|
|
261
268
|
You can specify an alternative trash program, e.g.
|
|
262
269
|
[`trash-d`](https://github.com/rushsteve1/trash-d), or
|
|
263
|
-
[`gio trash`](https://man.archlinux.org/man/gio.1
|
|
270
|
+
[`gio trash`](https://man.archlinux.org/man/gio.1), or
|
|
264
271
|
[`gtrash put`](https://github.com/umlx5h/gtrash),
|
|
265
272
|
by setting the `--trash-program` option. Most likely you
|
|
266
273
|
want to set this as a [default option](#command-default-options).
|
|
@@ -338,12 +345,16 @@ command line arguments. Comments in the file (i.e. starting with a `#`)
|
|
|
338
345
|
are ignored. Type `edir -h` to see all [supported
|
|
339
346
|
options](#command-line-options).
|
|
340
347
|
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
348
|
+
Some options, e.g. `--recurse`, which can be set as a default option, provide
|
|
349
|
+
another "on-the-fly" negation option to temporarily override and disable the
|
|
350
|
+
default using the command line. E.g. use `-R` to override default `--recurse`.
|
|
351
|
+
See the usage summary for details.
|
|
352
|
+
|
|
353
|
+
You can conveniently edit your default options file using the `--conf` option:
|
|
354
|
+
|
|
355
|
+
```sh
|
|
356
|
+
$ edir --conf
|
|
357
|
+
```
|
|
347
358
|
|
|
348
359
|
## Examples
|
|
349
360
|
|
|
@@ -379,8 +390,8 @@ Type `edir -h` to view the usage summary:
|
|
|
379
390
|
```
|
|
380
391
|
usage: edir [-h] [-i] [-I] [-a] [-A] [-r] [-R] [-q] [-Q] [-G] [-g] [-t]
|
|
381
392
|
[-T] [--trash-program TRASH_PROGRAM] [-c] [-C] [-d DEPTH] [-F |
|
|
382
|
-
-D] [-L] [-N] [-M] [-S] [-E] [-X] [-Y] [-Z]
|
|
383
|
-
[-V]
|
|
393
|
+
-D] [-L] [-N] [-M] [-S] [-O] [--OP OP] [-E] [-X] [-Y] [-Z]
|
|
394
|
+
[--suffix SUFFIX] [--no-relative] [-V] [--conf]
|
|
384
395
|
[args ...]
|
|
385
396
|
|
|
386
397
|
Command line utility to rename, remove, or copy files and directories directly
|
|
@@ -420,32 +431,42 @@ options:
|
|
|
420
431
|
-N, --sort-name sort paths in file by name, alphabetically
|
|
421
432
|
-M, --sort-time sort paths in file by time, oldest first
|
|
422
433
|
-S, --sort-size sort paths in file by size, smallest first
|
|
423
|
-
-
|
|
434
|
+
-O, --sort-natural sort paths using natural sort (using natsort package)
|
|
435
|
+
--OP, --sort-natural-opt OP
|
|
436
|
+
pass given option[s] to natsort, optionally
|
|
437
|
+
delimitered by "," or "|", see options at
|
|
438
|
+
https://natsort.readthedocs.io/en/stable/api.html#the-
|
|
439
|
+
ns-enum
|
|
440
|
+
-E, --sort-reverse sort paths (by name/time/size/natural) in reverse
|
|
424
441
|
-X, --group-dirs-first
|
|
425
442
|
group directories first (including when sorted)
|
|
426
443
|
-Y, --group-dirs-last
|
|
427
444
|
group directories last (including when sorted)
|
|
428
445
|
-Z, --no-group-dirs negate the options to group directories
|
|
429
446
|
--suffix SUFFIX specify suffix for temp editor file, default=".sh"
|
|
447
|
+
--no-relative do not forcibly show paths relative to current working
|
|
448
|
+
directory
|
|
430
449
|
-V, --version show edir version
|
|
450
|
+
--conf just invoke your editor on your startup options
|
|
451
|
+
configuration file
|
|
431
452
|
|
|
432
|
-
Note you can set default starting options in
|
|
433
|
-
|
|
434
|
-
|
|
453
|
+
Note you can set default starting options in ~/.config/edir-flags.conf. The
|
|
454
|
+
negation options (i.e. the --no-* options) allow you to temporarily override
|
|
455
|
+
your defaults.
|
|
435
456
|
```
|
|
436
457
|
|
|
437
458
|
## Running with sudo
|
|
438
459
|
|
|
439
|
-
You can use `edir` with `sudo` to rename, delete, or copy system files.
|
|
440
|
-
improved security, `edir` runs the editing session as your
|
|
441
|
-
root - similar to how `sudoedit` works. This
|
|
442
|
-
graphical editors (like VS Code), which should not be
|
|
443
|
-
so that your preferred editor is selected via your
|
|
444
|
-
environment variable. For example, to rename or
|
|
445
|
-
Code:
|
|
460
|
+
You can use `edir` with [`sudo`][sudo] to rename, delete, or copy system files.
|
|
461
|
+
For improved convenience and security, `edir` runs the editing session as your
|
|
462
|
+
regular user, not as root - similar to how [`sudoedit`][sudoedit] works. This
|
|
463
|
+
approach allows you to use graphical editors (like VS Code), which should not be
|
|
464
|
+
run as root. Use `sudo -E` so that your preferred editor is selected via your
|
|
465
|
+
`$EDIR_EDITOR` or `$EDITOR` environment variable. For example, to rename or
|
|
466
|
+
delete files in `/etc` using VS Code:
|
|
446
467
|
|
|
447
468
|
```sh
|
|
448
|
-
$ export EDIR_EDITOR="code -
|
|
469
|
+
$ export EDIR_EDITOR="code -nw"
|
|
449
470
|
$ sudo -E edir /etc
|
|
450
471
|
```
|
|
451
472
|
|
|
@@ -478,7 +499,19 @@ class edir(Command):
|
|
|
478
499
|
## Use with Yazi File Manager
|
|
479
500
|
|
|
480
501
|
If you use [`yazi`][yazi] for your file manager then you don't need any special
|
|
481
|
-
configuration. Just type `:edir` from within [`yazi`][yazi]
|
|
502
|
+
configuration. Just type `:edir` from within [`yazi`][yazi] to edit all file
|
|
503
|
+
names in the current directory.
|
|
504
|
+
|
|
505
|
+
You can also replace the standard rename function (`r` key) in [`yazi`][yazi]
|
|
506
|
+
to use `edir` on selected files by adding the following to your
|
|
507
|
+
`~/.config/yazi/keymap.toml` file:
|
|
508
|
+
|
|
509
|
+
```toml
|
|
510
|
+
[[mgr.prepend_keymap]]
|
|
511
|
+
on = "r"
|
|
512
|
+
run = "shell --block -- edir -q %s"
|
|
513
|
+
desc = "Run edir on selected files/dirs"
|
|
514
|
+
```
|
|
482
515
|
|
|
483
516
|
## License
|
|
484
517
|
|
|
@@ -499,6 +532,8 @@ License at <https://opensource.org/license/gpl-3-0> for more details.
|
|
|
499
532
|
[uvtool]: https://docs.astral.sh/uv/guides/tools/#installing-tools
|
|
500
533
|
[ranger]: https://ranger.github.io/
|
|
501
534
|
[yazi]: https://yazi-rs.github.io/
|
|
502
|
-
[trash]: https://
|
|
535
|
+
[trash]: https://www.freedesktop.org/wiki/Specifications/trash-spec/
|
|
536
|
+
[sudo]: https://man7.org/linux/man-pages/man8/sudo.8.html
|
|
537
|
+
[sudoedit]: https://man7.org/linux/man-pages/man8/sudoedit.8.html
|
|
503
538
|
|
|
504
539
|
<!-- vim: se ai syn=markdown: -->
|
{edir-2.33 → edir-2.35}/edir.py
RENAMED
|
@@ -10,7 +10,6 @@ repository, git will be used for renames and removals.
|
|
|
10
10
|
# Author: Mark Blakeney, May 2019.
|
|
11
11
|
from __future__ import annotations
|
|
12
12
|
|
|
13
|
-
import argparse_from_file as argparse
|
|
14
13
|
import itertools
|
|
15
14
|
import os
|
|
16
15
|
import shlex
|
|
@@ -21,6 +20,8 @@ import tempfile
|
|
|
21
20
|
from collections.abc import Callable, Iterable, Sequence
|
|
22
21
|
from pathlib import Path
|
|
23
22
|
|
|
23
|
+
import argparse_from_file as argparse
|
|
24
|
+
|
|
24
25
|
# Some constants
|
|
25
26
|
PROG = Path(sys.argv[0]).stem
|
|
26
27
|
EDITOR = PROG.upper() + '_EDITOR'
|
|
@@ -52,15 +53,15 @@ COLOR_reset = '\033[39;49m'
|
|
|
52
53
|
args = argparse.Namespace()
|
|
53
54
|
gitfiles = set()
|
|
54
55
|
counts = [0, 0]
|
|
56
|
+
cwd = Path.cwd()
|
|
55
57
|
|
|
56
58
|
EDITORS = {'Windows': 'notepad', 'Darwin': 'open -e', 'default': 'vim'}
|
|
57
59
|
|
|
58
|
-
|
|
59
60
|
def get_default_editor() -> str:
|
|
60
61
|
"Return default editor for this system"
|
|
61
62
|
from platform import system
|
|
62
63
|
|
|
63
|
-
return EDITORS.get(system()
|
|
64
|
+
return EDITORS.get(system()) or EDITORS['default']
|
|
64
65
|
|
|
65
66
|
|
|
66
67
|
def make_editor_command(filename: str, sudo_user: str) -> tuple[str, list[str]]:
|
|
@@ -216,11 +217,17 @@ def find_in_dir(path: Path, depth: int, allfiles: bool) -> Iterable[Path]:
|
|
|
216
217
|
yield from find_in_dir(p, depth - 1, allfiles)
|
|
217
218
|
|
|
218
219
|
|
|
220
|
+
def removeprefix(s: str, prefix: str) -> str:
|
|
221
|
+
"Remove prefix from string if present"
|
|
222
|
+
return s[len(prefix) :] if s.startswith(prefix) else s
|
|
223
|
+
|
|
224
|
+
|
|
219
225
|
class Fpath:
|
|
220
226
|
"Class to manage each instance of a file/dir"
|
|
221
227
|
|
|
222
228
|
paths = []
|
|
223
229
|
tempdirs = set()
|
|
230
|
+
natsort_key: Callable
|
|
224
231
|
|
|
225
232
|
def __init__(self, path: Path):
|
|
226
233
|
"Class constructor"
|
|
@@ -235,12 +242,11 @@ class Fpath:
|
|
|
235
242
|
sys.exit(f'ERROR: Can not read {path}: {e}')
|
|
236
243
|
|
|
237
244
|
self.appdash = SEP if self.is_dir else ''
|
|
238
|
-
self.
|
|
239
|
-
self.
|
|
245
|
+
self.repr = str(self.path)
|
|
246
|
+
self.diagrepr = self.repr
|
|
247
|
+
self.is_git = self.repr in gitfiles
|
|
240
248
|
|
|
241
|
-
self.linerepr = (
|
|
242
|
-
self.diagrepr if self.path.is_absolute() else f'.{SEP}{self.diagrepr}'
|
|
243
|
-
)
|
|
249
|
+
self.linerepr = self.repr if self.path.is_absolute() else f'.{SEP}{self.repr}'
|
|
244
250
|
if self.is_dir and not self.diagrepr.endswith(SEP):
|
|
245
251
|
self.linerepr += SEP
|
|
246
252
|
self.diagrepr += SEP
|
|
@@ -271,7 +277,7 @@ class Fpath:
|
|
|
271
277
|
except Exception as e:
|
|
272
278
|
return str(e)
|
|
273
279
|
try:
|
|
274
|
-
func(str(self.newpath), str(pathdest))
|
|
280
|
+
func(str(self.newpath), str(pathdest))
|
|
275
281
|
except Exception as e:
|
|
276
282
|
return str(e)
|
|
277
283
|
|
|
@@ -303,7 +309,7 @@ class Fpath:
|
|
|
303
309
|
|
|
304
310
|
def sort_name(self) -> str:
|
|
305
311
|
"Return name for sort"
|
|
306
|
-
return
|
|
312
|
+
return self.repr
|
|
307
313
|
|
|
308
314
|
def sort_time(self) -> float:
|
|
309
315
|
"Return time for sort"
|
|
@@ -323,6 +329,15 @@ class Fpath:
|
|
|
323
329
|
|
|
324
330
|
return ret
|
|
325
331
|
|
|
332
|
+
def sort_natural(self):
|
|
333
|
+
"Return key for natural sort"
|
|
334
|
+
try:
|
|
335
|
+
ret = self.natsort_key()
|
|
336
|
+
except Exception:
|
|
337
|
+
ret = self.repr
|
|
338
|
+
|
|
339
|
+
return ret
|
|
340
|
+
|
|
326
341
|
def is_recursive(self) -> bool:
|
|
327
342
|
"Return True if directory and we can view it and contains children"
|
|
328
343
|
if not self.is_dir:
|
|
@@ -349,6 +364,28 @@ class Fpath:
|
|
|
349
364
|
prompt=True,
|
|
350
365
|
)
|
|
351
366
|
|
|
367
|
+
@classmethod
|
|
368
|
+
def make_natsort_key(cls, optstr: str | None) -> None:
|
|
369
|
+
"Create natsort key function from given option string"
|
|
370
|
+
from natsort import natsort_keygen, ns
|
|
371
|
+
|
|
372
|
+
if optstr:
|
|
373
|
+
sep = '|' if '|' in optstr else ','
|
|
374
|
+
optval = 0
|
|
375
|
+
for opt in optstr.split(sep):
|
|
376
|
+
if opt := removeprefix(opt.strip().upper(), 'NS.'):
|
|
377
|
+
try:
|
|
378
|
+
nsval = getattr(ns, opt)
|
|
379
|
+
except AttributeError as e:
|
|
380
|
+
sys.exit(f'ERROR: invalid natsort option: {str(e)}')
|
|
381
|
+
|
|
382
|
+
if nsval and isinstance(nsval, int):
|
|
383
|
+
optval |= nsval
|
|
384
|
+
|
|
385
|
+
cls.natsort_key = natsort_keygen(key=lambda x: x.repr, alg=optval)
|
|
386
|
+
else:
|
|
387
|
+
cls.natsort_key = natsort_keygen(key=lambda x: x.repr)
|
|
388
|
+
|
|
352
389
|
@classmethod
|
|
353
390
|
def remove_temps(cls) -> None:
|
|
354
391
|
"Remove all the temp dirs we created in rename_temp() above"
|
|
@@ -378,9 +415,17 @@ class Fpath:
|
|
|
378
415
|
def add(cls, name: str, depth: int) -> None:
|
|
379
416
|
"Add file[s]/dir[s] to the list of paths"
|
|
380
417
|
path = Path(name)
|
|
418
|
+
|
|
381
419
|
if not path.exists():
|
|
382
420
|
sys.exit(f'ERROR: {name} does not exist')
|
|
383
421
|
|
|
422
|
+
if not args.no_relative:
|
|
423
|
+
# Make path relative to current working dir if possible
|
|
424
|
+
try:
|
|
425
|
+
path = path.relative_to(cwd)
|
|
426
|
+
except ValueError:
|
|
427
|
+
pass
|
|
428
|
+
|
|
384
429
|
if path.is_dir():
|
|
385
430
|
for child in find_in_dir(path, depth, args.all):
|
|
386
431
|
cls.append(child)
|
|
@@ -634,7 +679,7 @@ def main() -> int:
|
|
|
634
679
|
'--sort-name',
|
|
635
680
|
dest='sort',
|
|
636
681
|
action='store_const',
|
|
637
|
-
const=
|
|
682
|
+
const='name',
|
|
638
683
|
help='sort paths in file by name, alphabetically',
|
|
639
684
|
)
|
|
640
685
|
opt.add_argument(
|
|
@@ -642,7 +687,7 @@ def main() -> int:
|
|
|
642
687
|
'--sort-time',
|
|
643
688
|
dest='sort',
|
|
644
689
|
action='store_const',
|
|
645
|
-
const=
|
|
690
|
+
const='time',
|
|
646
691
|
help='sort paths in file by time, oldest first',
|
|
647
692
|
)
|
|
648
693
|
opt.add_argument(
|
|
@@ -650,14 +695,28 @@ def main() -> int:
|
|
|
650
695
|
'--sort-size',
|
|
651
696
|
dest='sort',
|
|
652
697
|
action='store_const',
|
|
653
|
-
const=
|
|
698
|
+
const='size',
|
|
654
699
|
help='sort paths in file by size, smallest first',
|
|
655
700
|
)
|
|
701
|
+
opt.add_argument(
|
|
702
|
+
'-O',
|
|
703
|
+
'--sort-natural',
|
|
704
|
+
dest='sort',
|
|
705
|
+
action='store_const',
|
|
706
|
+
const='natural',
|
|
707
|
+
help='sort paths using natural sort (using natsort package)',
|
|
708
|
+
)
|
|
709
|
+
opt.add_argument(
|
|
710
|
+
'--OP',
|
|
711
|
+
'--sort-natural-opt',
|
|
712
|
+
help='pass given option[s] to natsort, optionally delimitered by "," or "|", '
|
|
713
|
+
'see options at https://natsort.readthedocs.io/en/stable/api.html#the-ns-enum',
|
|
714
|
+
)
|
|
656
715
|
opt.add_argument(
|
|
657
716
|
'-E',
|
|
658
717
|
'--sort-reverse',
|
|
659
718
|
action='store_true',
|
|
660
|
-
help='sort paths (by name/time/size) in reverse',
|
|
719
|
+
help='sort paths (by name/time/size/natural) in reverse',
|
|
661
720
|
)
|
|
662
721
|
opt.add_argument(
|
|
663
722
|
'-X',
|
|
@@ -688,9 +747,19 @@ def main() -> int:
|
|
|
688
747
|
default=SUFFIX,
|
|
689
748
|
help='specify suffix for temp editor file, default="%(default)s"',
|
|
690
749
|
)
|
|
750
|
+
opt.add_argument(
|
|
751
|
+
'--no-relative',
|
|
752
|
+
action='store_true',
|
|
753
|
+
help='do not forcibly show paths relative to current working directory',
|
|
754
|
+
)
|
|
691
755
|
opt.add_argument(
|
|
692
756
|
'-V', '--version', action='store_true', help=f'show {PROG} version'
|
|
693
757
|
)
|
|
758
|
+
opt.add_argument(
|
|
759
|
+
'--conf',
|
|
760
|
+
action='store_true',
|
|
761
|
+
help='just invoke your editor on your startup options configuration file',
|
|
762
|
+
)
|
|
694
763
|
opt.add_argument('args', nargs='*', help='file|dir, or "-" for stdin')
|
|
695
764
|
|
|
696
765
|
args = opt.parse_args()
|
|
@@ -706,9 +775,31 @@ def main() -> int:
|
|
|
706
775
|
print(ver)
|
|
707
776
|
return 0
|
|
708
777
|
|
|
778
|
+
if args.conf:
|
|
779
|
+
# Edit the configuration file and exit
|
|
780
|
+
if not (conf_file := opt.from_file_path):
|
|
781
|
+
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
|
+
|
|
798
|
+
return 0
|
|
799
|
+
|
|
709
800
|
if args.trash:
|
|
710
801
|
if not args.trash_program:
|
|
711
|
-
opt.error('must specify trash program with --trash-program option')
|
|
802
|
+
opt.error('must specify trash program with --trash-program option.')
|
|
712
803
|
|
|
713
804
|
args.trash_program = args.trash_program.split()
|
|
714
805
|
|
|
@@ -721,7 +812,7 @@ def main() -> int:
|
|
|
721
812
|
gitfiles.update(out.splitlines())
|
|
722
813
|
|
|
723
814
|
if args.git and not gitfiles:
|
|
724
|
-
opt.error('must be within a git repo to use -g/--git option')
|
|
815
|
+
opt.error('must be within a git repo to use -g/--git option.')
|
|
725
816
|
|
|
726
817
|
# Set input list to a combination of arguments and stdin
|
|
727
818
|
filelist = args.args
|
|
@@ -751,12 +842,15 @@ def main() -> int:
|
|
|
751
842
|
print(f'No {desc}.')
|
|
752
843
|
return 0
|
|
753
844
|
|
|
754
|
-
if args.sort ==
|
|
845
|
+
if args.sort == 'name':
|
|
755
846
|
Fpath.paths.sort(key=Fpath.sort_name, reverse=args.sort_reverse)
|
|
756
|
-
elif args.sort ==
|
|
847
|
+
elif args.sort == 'time':
|
|
757
848
|
Fpath.paths.sort(key=Fpath.sort_time, reverse=args.sort_reverse)
|
|
758
|
-
elif args.sort ==
|
|
849
|
+
elif args.sort == 'size':
|
|
759
850
|
Fpath.paths.sort(key=Fpath.sort_size, reverse=args.sort_reverse)
|
|
851
|
+
elif args.sort == 'natural':
|
|
852
|
+
Fpath.make_natsort_key(args.OP)
|
|
853
|
+
Fpath.paths.sort(key=Fpath.sort_natural, reverse=args.sort_reverse)
|
|
760
854
|
|
|
761
855
|
if args.group_dirs is not None and args.group_dirs >= 0:
|
|
762
856
|
ldirs: list[Fpath] = []
|
edir-2.35/justfile
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
PYFILES := file_name(justfile_dir()) + '.py'
|
|
2
|
+
|
|
3
|
+
check:
|
|
4
|
+
ruff check {{PYFILES}}
|
|
5
|
+
ty check --python=/usr/bin/python3 {{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
|
|
18
|
+
|
|
19
|
+
format:
|
|
20
|
+
ruff check --select I --fix {{PYFILES}} && ruff format {{PYFILES}}
|
|
21
|
+
|
|
22
|
+
clean:
|
|
23
|
+
@rm -vrf *.egg-info build/ dist/ __pycache__/
|
edir-2.33/Makefile
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
NAME = $(shell basename $(CURDIR))
|
|
2
|
-
PYFILES = $(NAME).py
|
|
3
|
-
|
|
4
|
-
check::
|
|
5
|
-
ruff check $(PYFILES)
|
|
6
|
-
mypy $(PYFILES)
|
|
7
|
-
pyright $(PYFILES)
|
|
8
|
-
vermin -vv --no-tips -i $(PYFILES)
|
|
9
|
-
md-link-checker
|
|
10
|
-
|
|
11
|
-
build::
|
|
12
|
-
rm -rf dist
|
|
13
|
-
uv build
|
|
14
|
-
|
|
15
|
-
upload:: build
|
|
16
|
-
uv-publish
|
|
17
|
-
|
|
18
|
-
doc::
|
|
19
|
-
update-readme-usage
|
|
20
|
-
|
|
21
|
-
format::
|
|
22
|
-
ruff check --select I --fix $(PYFILES) && ruff format $(PYFILES)
|
|
23
|
-
|
|
24
|
-
clean::
|
|
25
|
-
@rm -vrf *.egg-info .venv/ build/ dist/ __pycache__/
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|