edir 2.32__tar.gz → 2.34__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.32/edir.egg-info → edir-2.34}/PKG-INFO +38 -26
- {edir-2.32 → edir-2.34}/README.md +35 -24
- {edir-2.32 → edir-2.34/edir.egg-info}/PKG-INFO +38 -26
- {edir-2.32 → edir-2.34}/edir.egg-info/SOURCES.txt +1 -1
- edir-2.34/edir.egg-info/requires.txt +2 -0
- edir-2.34/edir.egg-info/top_level.txt +1 -0
- {edir-2.32 → edir-2.34}/edir.py +92 -40
- edir-2.34/justfile +23 -0
- {edir-2.32 → edir-2.34}/pyproject.toml +2 -1
- edir-2.32/Makefile +0 -25
- edir-2.32/edir.egg-info/requires.txt +0 -1
- edir-2.32/edir.egg-info/top_level.txt +0 -1
- {edir-2.32 → edir-2.34}/.gitignore +0 -0
- {edir-2.32 → edir-2.34}/edir.egg-info/dependency_links.txt +0 -0
- {edir-2.32 → edir-2.34}/edir.egg-info/entry_points.txt +0 -0
- {edir-2.32 → edir-2.34}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: edir
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.34
|
|
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
|
|
@@ -9,7 +9,8 @@ Keywords: vidir,git,trash,trash-put,thrash-d
|
|
|
9
9
|
Classifier: Programming Language :: Python :: 3
|
|
10
10
|
Requires-Python: >=3.8
|
|
11
11
|
Description-Content-Type: text/markdown
|
|
12
|
-
Requires-Dist:
|
|
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
|
|
@@ -379,12 +380,15 @@ Type `edir -h` to view the usage summary:
|
|
|
379
380
|
```
|
|
380
381
|
usage: edir [-h] [-i] [-I] [-a] [-A] [-r] [-R] [-q] [-Q] [-G] [-g] [-t]
|
|
381
382
|
[-T] [--trash-program TRASH_PROGRAM] [-c] [-C] [-d DEPTH] [-F |
|
|
382
|
-
-D] [-L] [-N] [-M] [-S] [-E] [-X] [-Y] [-Z]
|
|
383
|
-
[-V]
|
|
383
|
+
-D] [-L] [-N] [-M] [-S] [-O] [--OP OP] [-E] [-X] [-Y] [-Z]
|
|
384
|
+
[--suffix SUFFIX] [-V]
|
|
384
385
|
[args ...]
|
|
385
386
|
|
|
386
|
-
|
|
387
|
-
|
|
387
|
+
Command line utility to rename, remove, or copy files and directories directly
|
|
388
|
+
from your editor. When run, you'll see a numbered list of files in your
|
|
389
|
+
editor. Delete a line to remove a file, modify a line to rename a file, or
|
|
390
|
+
duplicate a line to copy a file. Swap line numbers to swap file names. If
|
|
391
|
+
inside a git repository, git will be used for renames and removals.
|
|
388
392
|
|
|
389
393
|
positional arguments:
|
|
390
394
|
args file|dir, or "-" for stdin
|
|
@@ -417,7 +421,13 @@ options:
|
|
|
417
421
|
-N, --sort-name sort paths in file by name, alphabetically
|
|
418
422
|
-M, --sort-time sort paths in file by time, oldest first
|
|
419
423
|
-S, --sort-size sort paths in file by size, smallest first
|
|
420
|
-
-
|
|
424
|
+
-O, --sort-natural sort paths using natural sort (using natsort package)
|
|
425
|
+
--OP, --sort-natural-opt OP
|
|
426
|
+
pass given option[s] to natsort, optionally
|
|
427
|
+
delimitered by "," or "|", see options at
|
|
428
|
+
https://natsort.readthedocs.io/en/stable/api.html#the-
|
|
429
|
+
ns-enum
|
|
430
|
+
-E, --sort-reverse sort paths (by name/time/size/natural) in reverse
|
|
421
431
|
-X, --group-dirs-first
|
|
422
432
|
group directories first (including when sorted)
|
|
423
433
|
-Y, --group-dirs-last
|
|
@@ -426,24 +436,24 @@ options:
|
|
|
426
436
|
--suffix SUFFIX specify suffix for temp editor file, default=".sh"
|
|
427
437
|
-V, --version show edir version
|
|
428
438
|
|
|
429
|
-
Note you can set default starting options in
|
|
430
|
-
|
|
431
|
-
|
|
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.
|
|
432
442
|
```
|
|
433
443
|
|
|
434
444
|
## Running with sudo
|
|
435
445
|
|
|
436
|
-
You can use `edir` with `sudo` to rename, delete, or copy system files.
|
|
437
|
-
improved security, `edir` runs the editing session as your
|
|
438
|
-
root - similar to how `sudoedit` works. This
|
|
439
|
-
editors (like VS Code), which should not be
|
|
440
|
-
|
|
441
|
-
environment variable
|
|
442
|
-
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:
|
|
443
453
|
|
|
444
454
|
```sh
|
|
445
|
-
export EDIR_EDITOR="code -
|
|
446
|
-
sudo -E edir /etc
|
|
455
|
+
$ export EDIR_EDITOR="code -nw"
|
|
456
|
+
$ sudo -E edir /etc
|
|
447
457
|
```
|
|
448
458
|
|
|
449
459
|
## Embed in Ranger File Manager
|
|
@@ -496,6 +506,8 @@ License at <https://opensource.org/license/gpl-3-0> for more details.
|
|
|
496
506
|
[uvtool]: https://docs.astral.sh/uv/guides/tools/#installing-tools
|
|
497
507
|
[ranger]: https://ranger.github.io/
|
|
498
508
|
[yazi]: https://yazi-rs.github.io/
|
|
499
|
-
[trash]: https://
|
|
509
|
+
[trash]: https://www.freedesktop.org/wiki/Specifications/trash-spec/
|
|
510
|
+
[sudo]: https://man7.org/linux/man-pages/man8/sudo.8.html
|
|
511
|
+
[sudoedit]: https://man7.org/linux/man-pages/man8/sudoedit.8.html
|
|
500
512
|
|
|
501
513
|
<!-- 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
|
|
@@ -366,12 +366,15 @@ Type `edir -h` to view the usage summary:
|
|
|
366
366
|
```
|
|
367
367
|
usage: edir [-h] [-i] [-I] [-a] [-A] [-r] [-R] [-q] [-Q] [-G] [-g] [-t]
|
|
368
368
|
[-T] [--trash-program TRASH_PROGRAM] [-c] [-C] [-d DEPTH] [-F |
|
|
369
|
-
-D] [-L] [-N] [-M] [-S] [-E] [-X] [-Y] [-Z]
|
|
370
|
-
[-V]
|
|
369
|
+
-D] [-L] [-N] [-M] [-S] [-O] [--OP OP] [-E] [-X] [-Y] [-Z]
|
|
370
|
+
[--suffix SUFFIX] [-V]
|
|
371
371
|
[args ...]
|
|
372
372
|
|
|
373
|
-
|
|
374
|
-
|
|
373
|
+
Command line utility to rename, remove, or copy files and directories directly
|
|
374
|
+
from your editor. When run, you'll see a numbered list of files in your
|
|
375
|
+
editor. Delete a line to remove a file, modify a line to rename a file, or
|
|
376
|
+
duplicate a line to copy a file. Swap line numbers to swap file names. If
|
|
377
|
+
inside a git repository, git will be used for renames and removals.
|
|
375
378
|
|
|
376
379
|
positional arguments:
|
|
377
380
|
args file|dir, or "-" for stdin
|
|
@@ -404,7 +407,13 @@ options:
|
|
|
404
407
|
-N, --sort-name sort paths in file by name, alphabetically
|
|
405
408
|
-M, --sort-time sort paths in file by time, oldest first
|
|
406
409
|
-S, --sort-size sort paths in file by size, smallest first
|
|
407
|
-
-
|
|
410
|
+
-O, --sort-natural sort paths using natural sort (using natsort package)
|
|
411
|
+
--OP, --sort-natural-opt OP
|
|
412
|
+
pass given option[s] to natsort, optionally
|
|
413
|
+
delimitered by "," or "|", see options at
|
|
414
|
+
https://natsort.readthedocs.io/en/stable/api.html#the-
|
|
415
|
+
ns-enum
|
|
416
|
+
-E, --sort-reverse sort paths (by name/time/size/natural) in reverse
|
|
408
417
|
-X, --group-dirs-first
|
|
409
418
|
group directories first (including when sorted)
|
|
410
419
|
-Y, --group-dirs-last
|
|
@@ -413,24 +422,24 @@ options:
|
|
|
413
422
|
--suffix SUFFIX specify suffix for temp editor file, default=".sh"
|
|
414
423
|
-V, --version show edir version
|
|
415
424
|
|
|
416
|
-
Note you can set default starting options in
|
|
417
|
-
|
|
418
|
-
|
|
425
|
+
Note you can set default starting options in ~/.config/edir-flags.conf. The
|
|
426
|
+
negation options (i.e. the --no-* options) allow you to temporarily override
|
|
427
|
+
your defaults.
|
|
419
428
|
```
|
|
420
429
|
|
|
421
430
|
## Running with sudo
|
|
422
431
|
|
|
423
|
-
You can use `edir` with `sudo` to rename, delete, or copy system files.
|
|
424
|
-
improved security, `edir` runs the editing session as your
|
|
425
|
-
root - similar to how `sudoedit` works. This
|
|
426
|
-
editors (like VS Code), which should not be
|
|
427
|
-
|
|
428
|
-
environment variable
|
|
429
|
-
Code:
|
|
432
|
+
You can use `edir` with [`sudo`][sudo] to rename, delete, or copy system files.
|
|
433
|
+
For improved convenience and security, `edir` runs the editing session as your
|
|
434
|
+
regular user, not as root - similar to how [`sudoedit`][sudoedit] works. This
|
|
435
|
+
approach allows you to use graphical editors (like VS Code), which should not be
|
|
436
|
+
run as root. Use `sudo -E` so that your preferred editor is selected via your
|
|
437
|
+
`$EDIR_EDITOR` or `$EDITOR` environment variable. For example, to rename or
|
|
438
|
+
delete files in `/etc` using VS Code:
|
|
430
439
|
|
|
431
440
|
```sh
|
|
432
|
-
export EDIR_EDITOR="code -
|
|
433
|
-
sudo -E edir /etc
|
|
441
|
+
$ export EDIR_EDITOR="code -nw"
|
|
442
|
+
$ sudo -E edir /etc
|
|
434
443
|
```
|
|
435
444
|
|
|
436
445
|
## Embed in Ranger File Manager
|
|
@@ -483,6 +492,8 @@ License at <https://opensource.org/license/gpl-3-0> for more details.
|
|
|
483
492
|
[uvtool]: https://docs.astral.sh/uv/guides/tools/#installing-tools
|
|
484
493
|
[ranger]: https://ranger.github.io/
|
|
485
494
|
[yazi]: https://yazi-rs.github.io/
|
|
486
|
-
[trash]: https://
|
|
495
|
+
[trash]: https://www.freedesktop.org/wiki/Specifications/trash-spec/
|
|
496
|
+
[sudo]: https://man7.org/linux/man-pages/man8/sudo.8.html
|
|
497
|
+
[sudoedit]: https://man7.org/linux/man-pages/man8/sudoedit.8.html
|
|
487
498
|
|
|
488
499
|
<!-- 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.34
|
|
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
|
|
@@ -9,7 +9,8 @@ Keywords: vidir,git,trash,trash-put,thrash-d
|
|
|
9
9
|
Classifier: Programming Language :: Python :: 3
|
|
10
10
|
Requires-Python: >=3.8
|
|
11
11
|
Description-Content-Type: text/markdown
|
|
12
|
-
Requires-Dist:
|
|
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
|
|
@@ -379,12 +380,15 @@ Type `edir -h` to view the usage summary:
|
|
|
379
380
|
```
|
|
380
381
|
usage: edir [-h] [-i] [-I] [-a] [-A] [-r] [-R] [-q] [-Q] [-G] [-g] [-t]
|
|
381
382
|
[-T] [--trash-program TRASH_PROGRAM] [-c] [-C] [-d DEPTH] [-F |
|
|
382
|
-
-D] [-L] [-N] [-M] [-S] [-E] [-X] [-Y] [-Z]
|
|
383
|
-
[-V]
|
|
383
|
+
-D] [-L] [-N] [-M] [-S] [-O] [--OP OP] [-E] [-X] [-Y] [-Z]
|
|
384
|
+
[--suffix SUFFIX] [-V]
|
|
384
385
|
[args ...]
|
|
385
386
|
|
|
386
|
-
|
|
387
|
-
|
|
387
|
+
Command line utility to rename, remove, or copy files and directories directly
|
|
388
|
+
from your editor. When run, you'll see a numbered list of files in your
|
|
389
|
+
editor. Delete a line to remove a file, modify a line to rename a file, or
|
|
390
|
+
duplicate a line to copy a file. Swap line numbers to swap file names. If
|
|
391
|
+
inside a git repository, git will be used for renames and removals.
|
|
388
392
|
|
|
389
393
|
positional arguments:
|
|
390
394
|
args file|dir, or "-" for stdin
|
|
@@ -417,7 +421,13 @@ options:
|
|
|
417
421
|
-N, --sort-name sort paths in file by name, alphabetically
|
|
418
422
|
-M, --sort-time sort paths in file by time, oldest first
|
|
419
423
|
-S, --sort-size sort paths in file by size, smallest first
|
|
420
|
-
-
|
|
424
|
+
-O, --sort-natural sort paths using natural sort (using natsort package)
|
|
425
|
+
--OP, --sort-natural-opt OP
|
|
426
|
+
pass given option[s] to natsort, optionally
|
|
427
|
+
delimitered by "," or "|", see options at
|
|
428
|
+
https://natsort.readthedocs.io/en/stable/api.html#the-
|
|
429
|
+
ns-enum
|
|
430
|
+
-E, --sort-reverse sort paths (by name/time/size/natural) in reverse
|
|
421
431
|
-X, --group-dirs-first
|
|
422
432
|
group directories first (including when sorted)
|
|
423
433
|
-Y, --group-dirs-last
|
|
@@ -426,24 +436,24 @@ options:
|
|
|
426
436
|
--suffix SUFFIX specify suffix for temp editor file, default=".sh"
|
|
427
437
|
-V, --version show edir version
|
|
428
438
|
|
|
429
|
-
Note you can set default starting options in
|
|
430
|
-
|
|
431
|
-
|
|
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.
|
|
432
442
|
```
|
|
433
443
|
|
|
434
444
|
## Running with sudo
|
|
435
445
|
|
|
436
|
-
You can use `edir` with `sudo` to rename, delete, or copy system files.
|
|
437
|
-
improved security, `edir` runs the editing session as your
|
|
438
|
-
root - similar to how `sudoedit` works. This
|
|
439
|
-
editors (like VS Code), which should not be
|
|
440
|
-
|
|
441
|
-
environment variable
|
|
442
|
-
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:
|
|
443
453
|
|
|
444
454
|
```sh
|
|
445
|
-
export EDIR_EDITOR="code -
|
|
446
|
-
sudo -E edir /etc
|
|
455
|
+
$ export EDIR_EDITOR="code -nw"
|
|
456
|
+
$ sudo -E edir /etc
|
|
447
457
|
```
|
|
448
458
|
|
|
449
459
|
## Embed in Ranger File Manager
|
|
@@ -496,6 +506,8 @@ License at <https://opensource.org/license/gpl-3-0> for more details.
|
|
|
496
506
|
[uvtool]: https://docs.astral.sh/uv/guides/tools/#installing-tools
|
|
497
507
|
[ranger]: https://ranger.github.io/
|
|
498
508
|
[yazi]: https://yazi-rs.github.io/
|
|
499
|
-
[trash]: https://
|
|
509
|
+
[trash]: https://www.freedesktop.org/wiki/Specifications/trash-spec/
|
|
510
|
+
[sudo]: https://man7.org/linux/man-pages/man8/sudo.8.html
|
|
511
|
+
[sudoedit]: https://man7.org/linux/man-pages/man8/sudoedit.8.html
|
|
500
512
|
|
|
501
513
|
<!-- vim: se ai syn=markdown: -->
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
tmp
|
{edir-2.32 → edir-2.34}/edir.py
RENAMED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
2
|
"""
|
|
3
|
-
|
|
4
|
-
editor.
|
|
5
|
-
|
|
3
|
+
Command line utility to rename, remove, or copy files and directories directly
|
|
4
|
+
from your editor. When run, you'll see a numbered list of files in your editor.
|
|
5
|
+
Delete a line to remove a file, modify a line to rename a file, or duplicate a
|
|
6
|
+
line to copy a file. Swap line numbers to swap file names. If inside a git
|
|
7
|
+
repository, git will be used for renames and removals.
|
|
6
8
|
"""
|
|
7
9
|
|
|
8
10
|
# Author: Mark Blakeney, May 2019.
|
|
9
11
|
from __future__ import annotations
|
|
10
12
|
|
|
11
|
-
import argparse
|
|
12
13
|
import itertools
|
|
13
14
|
import os
|
|
14
|
-
import re
|
|
15
15
|
import shlex
|
|
16
16
|
import shutil
|
|
17
17
|
import subprocess
|
|
@@ -20,11 +20,11 @@ import tempfile
|
|
|
20
20
|
from collections.abc import Callable, Iterable, Sequence
|
|
21
21
|
from pathlib import Path
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
import argparse_from_file as argparse
|
|
24
|
+
import natsort
|
|
24
25
|
|
|
25
26
|
# Some constants
|
|
26
27
|
PROG = Path(sys.argv[0]).stem
|
|
27
|
-
CNFFILE = user_config_path() / f'{PROG}-flags.conf'
|
|
28
28
|
EDITOR = PROG.upper() + '_EDITOR'
|
|
29
29
|
SUFFIX = '.sh'
|
|
30
30
|
SEP = os.sep
|
|
@@ -65,8 +65,10 @@ def get_default_editor() -> str:
|
|
|
65
65
|
return EDITORS.get(system(), EDITORS['default'])
|
|
66
66
|
|
|
67
67
|
|
|
68
|
-
def
|
|
69
|
-
"
|
|
68
|
+
def make_editor_command(filename: str, sudo_user: str) -> tuple[str, list[str]]:
|
|
69
|
+
"Create the edit command"
|
|
70
|
+
editcmd = ['runuser', '-u', sudo_user, '--'] if sudo_user else []
|
|
71
|
+
|
|
70
72
|
# Use explicit user defined editor or choose system default
|
|
71
73
|
editor = (
|
|
72
74
|
os.getenv(EDITOR)
|
|
@@ -74,10 +76,14 @@ def editfile(filename: Path, sudo_user: str) -> None:
|
|
|
74
76
|
or os.getenv('EDITOR')
|
|
75
77
|
or get_default_editor()
|
|
76
78
|
)
|
|
77
|
-
editcmd = shlex.split(editor) + [str(filename)]
|
|
78
79
|
|
|
79
|
-
|
|
80
|
-
|
|
80
|
+
editcmd.extend(shlex.split(editor))
|
|
81
|
+
editcmd.append(filename)
|
|
82
|
+
return editor, editcmd
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def editfile(editor: str, editcmd: list[str]) -> None:
|
|
86
|
+
"Run the editor command"
|
|
81
87
|
|
|
82
88
|
# Run the editor ..
|
|
83
89
|
if sys.stdin.isatty():
|
|
@@ -88,7 +94,7 @@ def editfile(filename: Path, sudo_user: str) -> None:
|
|
|
88
94
|
|
|
89
95
|
# Check if editor returned error
|
|
90
96
|
if res.returncode != 0:
|
|
91
|
-
sys.exit(f'ERROR: {editor} returned error {res.returncode}')
|
|
97
|
+
sys.exit(f'ERROR: "{editor}" returned error {res.returncode}')
|
|
92
98
|
|
|
93
99
|
|
|
94
100
|
def log(
|
|
@@ -212,11 +218,17 @@ def find_in_dir(path: Path, depth: int, allfiles: bool) -> Iterable[Path]:
|
|
|
212
218
|
yield from find_in_dir(p, depth - 1, allfiles)
|
|
213
219
|
|
|
214
220
|
|
|
221
|
+
def removeprefix(s: str, prefix: str) -> str:
|
|
222
|
+
"Remove prefix from string if present"
|
|
223
|
+
return s[len(prefix) :] if s.startswith(prefix) else s
|
|
224
|
+
|
|
225
|
+
|
|
215
226
|
class Fpath:
|
|
216
227
|
"Class to manage each instance of a file/dir"
|
|
217
228
|
|
|
218
229
|
paths = []
|
|
219
230
|
tempdirs = set()
|
|
231
|
+
natsort_key: Callable
|
|
220
232
|
|
|
221
233
|
def __init__(self, path: Path):
|
|
222
234
|
"Class constructor"
|
|
@@ -231,12 +243,11 @@ class Fpath:
|
|
|
231
243
|
sys.exit(f'ERROR: Can not read {path}: {e}')
|
|
232
244
|
|
|
233
245
|
self.appdash = SEP if self.is_dir else ''
|
|
234
|
-
self.
|
|
235
|
-
self.
|
|
246
|
+
self.repr = str(self.path)
|
|
247
|
+
self.diagrepr = self.repr
|
|
248
|
+
self.is_git = self.repr in gitfiles
|
|
236
249
|
|
|
237
|
-
self.linerepr = (
|
|
238
|
-
self.diagrepr if self.path.is_absolute() else f'.{SEP}{self.diagrepr}'
|
|
239
|
-
)
|
|
250
|
+
self.linerepr = self.repr if self.path.is_absolute() else f'.{SEP}{self.repr}'
|
|
240
251
|
if self.is_dir and not self.diagrepr.endswith(SEP):
|
|
241
252
|
self.linerepr += SEP
|
|
242
253
|
self.diagrepr += SEP
|
|
@@ -299,7 +310,7 @@ class Fpath:
|
|
|
299
310
|
|
|
300
311
|
def sort_name(self) -> str:
|
|
301
312
|
"Return name for sort"
|
|
302
|
-
return
|
|
313
|
+
return self.repr
|
|
303
314
|
|
|
304
315
|
def sort_time(self) -> float:
|
|
305
316
|
"Return time for sort"
|
|
@@ -319,6 +330,15 @@ class Fpath:
|
|
|
319
330
|
|
|
320
331
|
return ret
|
|
321
332
|
|
|
333
|
+
def sort_natural(self):
|
|
334
|
+
"Return key for natural sort"
|
|
335
|
+
try:
|
|
336
|
+
ret = self.natsort_key()
|
|
337
|
+
except Exception:
|
|
338
|
+
ret = self.repr
|
|
339
|
+
|
|
340
|
+
return ret
|
|
341
|
+
|
|
322
342
|
def is_recursive(self) -> bool:
|
|
323
343
|
"Return True if directory and we can view it and contains children"
|
|
324
344
|
if not self.is_dir:
|
|
@@ -345,6 +365,26 @@ class Fpath:
|
|
|
345
365
|
prompt=True,
|
|
346
366
|
)
|
|
347
367
|
|
|
368
|
+
@classmethod
|
|
369
|
+
def make_natsort_key(cls, optstr: str | None) -> None:
|
|
370
|
+
"Create natsort key function from given option string"
|
|
371
|
+
if optstr:
|
|
372
|
+
sep = '|' if '|' in optstr else ','
|
|
373
|
+
optval = 0
|
|
374
|
+
for opt in optstr.split(sep):
|
|
375
|
+
if opt := removeprefix(opt.strip().upper(), 'NS.'):
|
|
376
|
+
try:
|
|
377
|
+
nsval = getattr(natsort.ns, opt)
|
|
378
|
+
except AttributeError as e:
|
|
379
|
+
sys.exit(f'ERROR: invalid natsort option: {str(e)}')
|
|
380
|
+
|
|
381
|
+
if nsval and isinstance(nsval, int):
|
|
382
|
+
optval |= nsval
|
|
383
|
+
|
|
384
|
+
cls.natsort_key = natsort.natsort_keygen(key=lambda x: x.repr, alg=optval)
|
|
385
|
+
else:
|
|
386
|
+
cls.natsort_key = natsort.natsort_keygen(key=lambda x: x.repr)
|
|
387
|
+
|
|
348
388
|
@classmethod
|
|
349
389
|
def remove_temps(cls) -> None:
|
|
350
390
|
"Remove all the temp dirs we created in rename_temp() above"
|
|
@@ -454,6 +494,10 @@ class Fpath:
|
|
|
454
494
|
|
|
455
495
|
# Create a temp file for the user to edit then read the lines back
|
|
456
496
|
fpath = Path(fdir, f'{PROG}{args.suffix}')
|
|
497
|
+
|
|
498
|
+
# Get the editor and editor command
|
|
499
|
+
editor, editcmd = make_editor_command(str(fpath), sudo_user)
|
|
500
|
+
|
|
457
501
|
restart = True
|
|
458
502
|
while True:
|
|
459
503
|
if restart:
|
|
@@ -463,10 +507,10 @@ class Fpath:
|
|
|
463
507
|
if sudo_user:
|
|
464
508
|
shutil.chown(fpath, sudo_user)
|
|
465
509
|
|
|
466
|
-
# Invoke editor on list of paths
|
|
467
|
-
editfile(
|
|
510
|
+
# Invoke editor on file containing the list of paths
|
|
511
|
+
editfile(editor, editcmd)
|
|
468
512
|
|
|
469
|
-
# Read the changed paths
|
|
513
|
+
# Read the changed paths from the file
|
|
470
514
|
cls.readfile(fpath)
|
|
471
515
|
|
|
472
516
|
# Reduce paths to those that were removed or changed by the user
|
|
@@ -513,7 +557,7 @@ def main() -> int:
|
|
|
513
557
|
opt = argparse.ArgumentParser(
|
|
514
558
|
description=__doc__,
|
|
515
559
|
epilog='Note you can set default starting options in '
|
|
516
|
-
|
|
560
|
+
'#FROM_FILE_PATH#. The negation options (i.e. the --no-* options) '
|
|
517
561
|
'allow you to temporarily override your defaults.',
|
|
518
562
|
)
|
|
519
563
|
opt.add_argument(
|
|
@@ -626,7 +670,7 @@ def main() -> int:
|
|
|
626
670
|
'--sort-name',
|
|
627
671
|
dest='sort',
|
|
628
672
|
action='store_const',
|
|
629
|
-
const=
|
|
673
|
+
const='name',
|
|
630
674
|
help='sort paths in file by name, alphabetically',
|
|
631
675
|
)
|
|
632
676
|
opt.add_argument(
|
|
@@ -634,7 +678,7 @@ def main() -> int:
|
|
|
634
678
|
'--sort-time',
|
|
635
679
|
dest='sort',
|
|
636
680
|
action='store_const',
|
|
637
|
-
const=
|
|
681
|
+
const='time',
|
|
638
682
|
help='sort paths in file by time, oldest first',
|
|
639
683
|
)
|
|
640
684
|
opt.add_argument(
|
|
@@ -642,14 +686,28 @@ def main() -> int:
|
|
|
642
686
|
'--sort-size',
|
|
643
687
|
dest='sort',
|
|
644
688
|
action='store_const',
|
|
645
|
-
const=
|
|
689
|
+
const='size',
|
|
646
690
|
help='sort paths in file by size, smallest first',
|
|
647
691
|
)
|
|
692
|
+
opt.add_argument(
|
|
693
|
+
'-O',
|
|
694
|
+
'--sort-natural',
|
|
695
|
+
dest='sort',
|
|
696
|
+
action='store_const',
|
|
697
|
+
const='natural',
|
|
698
|
+
help='sort paths using natural sort (using natsort package)',
|
|
699
|
+
)
|
|
700
|
+
opt.add_argument(
|
|
701
|
+
'--OP',
|
|
702
|
+
'--sort-natural-opt',
|
|
703
|
+
help='pass given option[s] to natsort, optionally delimitered by "," or "|", '
|
|
704
|
+
'see options at https://natsort.readthedocs.io/en/stable/api.html#the-ns-enum',
|
|
705
|
+
)
|
|
648
706
|
opt.add_argument(
|
|
649
707
|
'-E',
|
|
650
708
|
'--sort-reverse',
|
|
651
709
|
action='store_true',
|
|
652
|
-
help='sort paths (by name/time/size) in reverse',
|
|
710
|
+
help='sort paths (by name/time/size/natural) in reverse',
|
|
653
711
|
)
|
|
654
712
|
opt.add_argument(
|
|
655
713
|
'-X',
|
|
@@ -685,16 +743,7 @@ def main() -> int:
|
|
|
685
743
|
)
|
|
686
744
|
opt.add_argument('args', nargs='*', help='file|dir, or "-" for stdin')
|
|
687
745
|
|
|
688
|
-
|
|
689
|
-
# command line.
|
|
690
|
-
if CNFFILE.exists():
|
|
691
|
-
with CNFFILE.open() as fp:
|
|
692
|
-
lines = [re.sub(r'#.*$', '', line).strip() for line in fp]
|
|
693
|
-
cnflines = ' '.join(lines).strip()
|
|
694
|
-
else:
|
|
695
|
-
cnflines = ''
|
|
696
|
-
|
|
697
|
-
args = opt.parse_args(shlex.split(cnflines) + sys.argv[1:])
|
|
746
|
+
args = opt.parse_args()
|
|
698
747
|
|
|
699
748
|
if args.version:
|
|
700
749
|
from importlib.metadata import version
|
|
@@ -752,12 +801,15 @@ def main() -> int:
|
|
|
752
801
|
print(f'No {desc}.')
|
|
753
802
|
return 0
|
|
754
803
|
|
|
755
|
-
if args.sort ==
|
|
804
|
+
if args.sort == 'name':
|
|
756
805
|
Fpath.paths.sort(key=Fpath.sort_name, reverse=args.sort_reverse)
|
|
757
|
-
elif args.sort ==
|
|
806
|
+
elif args.sort == 'time':
|
|
758
807
|
Fpath.paths.sort(key=Fpath.sort_time, reverse=args.sort_reverse)
|
|
759
|
-
elif args.sort ==
|
|
808
|
+
elif args.sort == 'size':
|
|
760
809
|
Fpath.paths.sort(key=Fpath.sort_size, reverse=args.sort_reverse)
|
|
810
|
+
elif args.sort == 'natural':
|
|
811
|
+
Fpath.make_natsort_key(args.OP)
|
|
812
|
+
Fpath.paths.sort(key=Fpath.sort_natural, reverse=args.sort_reverse)
|
|
761
813
|
|
|
762
814
|
if args.group_dirs is not None and args.group_dirs >= 0:
|
|
763
815
|
ldirs: list[Fpath] = []
|
edir-2.34/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.32/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__/
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
platformdirs
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
edir
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|