edir 2.31__tar.gz → 2.32__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.31 → edir-2.32}/Makefile +1 -0
- {edir-2.31/edir.egg-info → edir-2.32}/PKG-INFO +26 -11
- {edir-2.31 → edir-2.32}/README.md +25 -10
- {edir-2.31 → edir-2.32/edir.egg-info}/PKG-INFO +26 -11
- {edir-2.31 → edir-2.32}/edir.py +24 -9
- {edir-2.31 → edir-2.32}/.gitignore +0 -0
- {edir-2.31 → edir-2.32}/edir.egg-info/SOURCES.txt +0 -0
- {edir-2.31 → edir-2.32}/edir.egg-info/dependency_links.txt +0 -0
- {edir-2.31 → edir-2.32}/edir.egg-info/entry_points.txt +0 -0
- {edir-2.31 → edir-2.32}/edir.egg-info/requires.txt +0 -0
- {edir-2.31 → edir-2.32}/edir.egg-info/top_level.txt +0 -0
- {edir-2.31 → edir-2.32}/pyproject.toml +0 -0
- {edir-2.31 → edir-2.32}/setup.cfg +0 -0
{edir-2.31 → edir-2.32}/Makefile
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: edir
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.32
|
|
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
|
|
@@ -35,9 +35,9 @@ https://github.com/bulletmark/edir.
|
|
|
35
35
|
## Advantages Compared to Vidir
|
|
36
36
|
|
|
37
37
|
[`edir`][edir] unashamedly mimics the functionality of the
|
|
38
|
-
[vidir](https://
|
|
39
|
-
[moreutils](https://joeyh.name/code/moreutils/) but aims to improve it
|
|
40
|
-
|
|
38
|
+
[vidir](https://man.archlinux.org/man/extra/moreutils/vidir.1.en) utility from
|
|
39
|
+
[moreutils](https://joeyh.name/code/moreutils/) but aims to improve it in the
|
|
40
|
+
following ways:
|
|
41
41
|
|
|
42
42
|
1. `edir` automatically uses `git mv` instead of `mv` and `git rm`
|
|
43
43
|
instead of `rm` for tracked files when invoked within a
|
|
@@ -128,7 +128,7 @@ in the following ways:
|
|
|
128
128
|
14. `edir` adds a `-d/--depth` option to edit to the specified directory
|
|
129
129
|
depth. The default is 1 so `edir a` (if a is a directory) will edit
|
|
130
130
|
names to `a/*`, `edir -d2 a` will edit names to `a/*/*`, etc. `edir
|
|
131
|
-
-d0 a` will just edit the `a` name directly. Can specify `-1` to
|
|
131
|
+
-d0 a` will just edit the `a` name directly. Can specify `-d -1` to
|
|
132
132
|
edit to all depths (or use a large positive number).
|
|
133
133
|
|
|
134
134
|
15. `edir` adds a [`-t/--trash` option](#using-trash) to remove to your
|
|
@@ -349,26 +349,26 @@ temporarily override and disable default options on the command line.
|
|
|
349
349
|
|
|
350
350
|
Rename and/or remove any files and directories in the current directory:
|
|
351
351
|
|
|
352
|
-
```
|
|
352
|
+
```sh
|
|
353
353
|
$ edir
|
|
354
354
|
```
|
|
355
355
|
|
|
356
356
|
Rename and/or remove any jpeg files in current dir:
|
|
357
357
|
|
|
358
|
-
```
|
|
358
|
+
```sh
|
|
359
359
|
$ edir *.jpg
|
|
360
360
|
```
|
|
361
361
|
|
|
362
362
|
Rename and/or remove any files under current directory and subdirectories:
|
|
363
363
|
|
|
364
|
-
```
|
|
364
|
+
```sh
|
|
365
365
|
$ find | edir -F
|
|
366
366
|
```
|
|
367
367
|
|
|
368
368
|
Use [`fd`](https://github.com/sharkdp/fd) to view and `git mv/rm`
|
|
369
369
|
repository files only, in the current directory only:
|
|
370
370
|
|
|
371
|
-
```
|
|
371
|
+
```sh
|
|
372
372
|
$ fd -d1 -tf | edir -g
|
|
373
373
|
```
|
|
374
374
|
|
|
@@ -431,6 +431,21 @@ flags.conf. The negation options (i.e. the --no-* options) allow you to
|
|
|
431
431
|
temporarily override your defaults.
|
|
432
432
|
```
|
|
433
433
|
|
|
434
|
+
## Running with sudo
|
|
435
|
+
|
|
436
|
+
You can use `edir` with `sudo` to rename, delete, or copy system files. For
|
|
437
|
+
improved security, `edir` runs the editing session as your regular user, not as
|
|
438
|
+
root - similar to how `sudoedit` works. This approach allows you to use graphical
|
|
439
|
+
editors (like VS Code), which should not be run as root. To ensure your editor
|
|
440
|
+
settings are preserved, use `sudo -E` so that your `$EDIR_EDITOR` or `$EDITOR`
|
|
441
|
+
environment variable is available. For example, to edit files in `/etc` with VS
|
|
442
|
+
Code:
|
|
443
|
+
|
|
444
|
+
```sh
|
|
445
|
+
export EDIR_EDITOR="code -w"
|
|
446
|
+
sudo -E edir /etc
|
|
447
|
+
```
|
|
448
|
+
|
|
434
449
|
## Embed in Ranger File Manager
|
|
435
450
|
|
|
436
451
|
In many ways `edir` (and even `vidir`) is better than the [`ranger`][ranger]
|
|
@@ -471,8 +486,8 @@ General Public License as published by the Free Software Foundation,
|
|
|
471
486
|
either version 3 of the License, or any later version. This program is
|
|
472
487
|
distributed in the hope that it will be useful, but WITHOUT ANY
|
|
473
488
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
474
|
-
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
|
475
|
-
<
|
|
489
|
+
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
|
490
|
+
License at <https://opensource.org/license/gpl-3-0> for more details.
|
|
476
491
|
|
|
477
492
|
[edir]: https://github.com/bulletmark/edir
|
|
478
493
|
[edirpy]: https://pypi.org/project/edir
|
|
@@ -22,9 +22,9 @@ https://github.com/bulletmark/edir.
|
|
|
22
22
|
## Advantages Compared to Vidir
|
|
23
23
|
|
|
24
24
|
[`edir`][edir] unashamedly mimics the functionality of the
|
|
25
|
-
[vidir](https://
|
|
26
|
-
[moreutils](https://joeyh.name/code/moreutils/) but aims to improve it
|
|
27
|
-
|
|
25
|
+
[vidir](https://man.archlinux.org/man/extra/moreutils/vidir.1.en) utility from
|
|
26
|
+
[moreutils](https://joeyh.name/code/moreutils/) but aims to improve it in the
|
|
27
|
+
following ways:
|
|
28
28
|
|
|
29
29
|
1. `edir` automatically uses `git mv` instead of `mv` and `git rm`
|
|
30
30
|
instead of `rm` for tracked files when invoked within a
|
|
@@ -115,7 +115,7 @@ in the following ways:
|
|
|
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
117
|
names to `a/*`, `edir -d2 a` will edit names to `a/*/*`, etc. `edir
|
|
118
|
-
-d0 a` will just edit the `a` name directly. Can specify `-1` to
|
|
118
|
+
-d0 a` will just edit the `a` name directly. Can specify `-d -1` to
|
|
119
119
|
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
|
|
@@ -336,26 +336,26 @@ temporarily override and disable default options on the command line.
|
|
|
336
336
|
|
|
337
337
|
Rename and/or remove any files and directories in the current directory:
|
|
338
338
|
|
|
339
|
-
```
|
|
339
|
+
```sh
|
|
340
340
|
$ edir
|
|
341
341
|
```
|
|
342
342
|
|
|
343
343
|
Rename and/or remove any jpeg files in current dir:
|
|
344
344
|
|
|
345
|
-
```
|
|
345
|
+
```sh
|
|
346
346
|
$ edir *.jpg
|
|
347
347
|
```
|
|
348
348
|
|
|
349
349
|
Rename and/or remove any files under current directory and subdirectories:
|
|
350
350
|
|
|
351
|
-
```
|
|
351
|
+
```sh
|
|
352
352
|
$ find | edir -F
|
|
353
353
|
```
|
|
354
354
|
|
|
355
355
|
Use [`fd`](https://github.com/sharkdp/fd) to view and `git mv/rm`
|
|
356
356
|
repository files only, in the current directory only:
|
|
357
357
|
|
|
358
|
-
```
|
|
358
|
+
```sh
|
|
359
359
|
$ fd -d1 -tf | edir -g
|
|
360
360
|
```
|
|
361
361
|
|
|
@@ -418,6 +418,21 @@ flags.conf. The negation options (i.e. the --no-* options) allow you to
|
|
|
418
418
|
temporarily override your defaults.
|
|
419
419
|
```
|
|
420
420
|
|
|
421
|
+
## Running with sudo
|
|
422
|
+
|
|
423
|
+
You can use `edir` with `sudo` to rename, delete, or copy system files. For
|
|
424
|
+
improved security, `edir` runs the editing session as your regular user, not as
|
|
425
|
+
root - similar to how `sudoedit` works. This approach allows you to use graphical
|
|
426
|
+
editors (like VS Code), which should not be run as root. To ensure your editor
|
|
427
|
+
settings are preserved, use `sudo -E` so that your `$EDIR_EDITOR` or `$EDITOR`
|
|
428
|
+
environment variable is available. For example, to edit files in `/etc` with VS
|
|
429
|
+
Code:
|
|
430
|
+
|
|
431
|
+
```sh
|
|
432
|
+
export EDIR_EDITOR="code -w"
|
|
433
|
+
sudo -E edir /etc
|
|
434
|
+
```
|
|
435
|
+
|
|
421
436
|
## Embed in Ranger File Manager
|
|
422
437
|
|
|
423
438
|
In many ways `edir` (and even `vidir`) is better than the [`ranger`][ranger]
|
|
@@ -458,8 +473,8 @@ General Public License as published by the Free Software Foundation,
|
|
|
458
473
|
either version 3 of the License, or any later version. This program is
|
|
459
474
|
distributed in the hope that it will be useful, but WITHOUT ANY
|
|
460
475
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
461
|
-
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
|
462
|
-
<
|
|
476
|
+
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
|
477
|
+
License at <https://opensource.org/license/gpl-3-0> for more details.
|
|
463
478
|
|
|
464
479
|
[edir]: https://github.com/bulletmark/edir
|
|
465
480
|
[edirpy]: https://pypi.org/project/edir
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: edir
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.32
|
|
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
|
|
@@ -35,9 +35,9 @@ https://github.com/bulletmark/edir.
|
|
|
35
35
|
## Advantages Compared to Vidir
|
|
36
36
|
|
|
37
37
|
[`edir`][edir] unashamedly mimics the functionality of the
|
|
38
|
-
[vidir](https://
|
|
39
|
-
[moreutils](https://joeyh.name/code/moreutils/) but aims to improve it
|
|
40
|
-
|
|
38
|
+
[vidir](https://man.archlinux.org/man/extra/moreutils/vidir.1.en) utility from
|
|
39
|
+
[moreutils](https://joeyh.name/code/moreutils/) but aims to improve it in the
|
|
40
|
+
following ways:
|
|
41
41
|
|
|
42
42
|
1. `edir` automatically uses `git mv` instead of `mv` and `git rm`
|
|
43
43
|
instead of `rm` for tracked files when invoked within a
|
|
@@ -128,7 +128,7 @@ in the following ways:
|
|
|
128
128
|
14. `edir` adds a `-d/--depth` option to edit to the specified directory
|
|
129
129
|
depth. The default is 1 so `edir a` (if a is a directory) will edit
|
|
130
130
|
names to `a/*`, `edir -d2 a` will edit names to `a/*/*`, etc. `edir
|
|
131
|
-
-d0 a` will just edit the `a` name directly. Can specify `-1` to
|
|
131
|
+
-d0 a` will just edit the `a` name directly. Can specify `-d -1` to
|
|
132
132
|
edit to all depths (or use a large positive number).
|
|
133
133
|
|
|
134
134
|
15. `edir` adds a [`-t/--trash` option](#using-trash) to remove to your
|
|
@@ -349,26 +349,26 @@ temporarily override and disable default options on the command line.
|
|
|
349
349
|
|
|
350
350
|
Rename and/or remove any files and directories in the current directory:
|
|
351
351
|
|
|
352
|
-
```
|
|
352
|
+
```sh
|
|
353
353
|
$ edir
|
|
354
354
|
```
|
|
355
355
|
|
|
356
356
|
Rename and/or remove any jpeg files in current dir:
|
|
357
357
|
|
|
358
|
-
```
|
|
358
|
+
```sh
|
|
359
359
|
$ edir *.jpg
|
|
360
360
|
```
|
|
361
361
|
|
|
362
362
|
Rename and/or remove any files under current directory and subdirectories:
|
|
363
363
|
|
|
364
|
-
```
|
|
364
|
+
```sh
|
|
365
365
|
$ find | edir -F
|
|
366
366
|
```
|
|
367
367
|
|
|
368
368
|
Use [`fd`](https://github.com/sharkdp/fd) to view and `git mv/rm`
|
|
369
369
|
repository files only, in the current directory only:
|
|
370
370
|
|
|
371
|
-
```
|
|
371
|
+
```sh
|
|
372
372
|
$ fd -d1 -tf | edir -g
|
|
373
373
|
```
|
|
374
374
|
|
|
@@ -431,6 +431,21 @@ flags.conf. The negation options (i.e. the --no-* options) allow you to
|
|
|
431
431
|
temporarily override your defaults.
|
|
432
432
|
```
|
|
433
433
|
|
|
434
|
+
## Running with sudo
|
|
435
|
+
|
|
436
|
+
You can use `edir` with `sudo` to rename, delete, or copy system files. For
|
|
437
|
+
improved security, `edir` runs the editing session as your regular user, not as
|
|
438
|
+
root - similar to how `sudoedit` works. This approach allows you to use graphical
|
|
439
|
+
editors (like VS Code), which should not be run as root. To ensure your editor
|
|
440
|
+
settings are preserved, use `sudo -E` so that your `$EDIR_EDITOR` or `$EDITOR`
|
|
441
|
+
environment variable is available. For example, to edit files in `/etc` with VS
|
|
442
|
+
Code:
|
|
443
|
+
|
|
444
|
+
```sh
|
|
445
|
+
export EDIR_EDITOR="code -w"
|
|
446
|
+
sudo -E edir /etc
|
|
447
|
+
```
|
|
448
|
+
|
|
434
449
|
## Embed in Ranger File Manager
|
|
435
450
|
|
|
436
451
|
In many ways `edir` (and even `vidir`) is better than the [`ranger`][ranger]
|
|
@@ -471,8 +486,8 @@ General Public License as published by the Free Software Foundation,
|
|
|
471
486
|
either version 3 of the License, or any later version. This program is
|
|
472
487
|
distributed in the hope that it will be useful, but WITHOUT ANY
|
|
473
488
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
474
|
-
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
|
475
|
-
<
|
|
489
|
+
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
|
490
|
+
License at <https://opensource.org/license/gpl-3-0> for more details.
|
|
476
491
|
|
|
477
492
|
[edir]: https://github.com/bulletmark/edir
|
|
478
493
|
[edirpy]: https://pypi.org/project/edir
|
{edir-2.31 → edir-2.32}/edir.py
RENAMED
|
@@ -17,9 +17,8 @@ import shutil
|
|
|
17
17
|
import subprocess
|
|
18
18
|
import sys
|
|
19
19
|
import tempfile
|
|
20
|
-
from collections import
|
|
20
|
+
from collections.abc import Callable, Iterable, Sequence
|
|
21
21
|
from pathlib import Path
|
|
22
|
-
from typing import Callable, Iterable, Sequence
|
|
23
22
|
|
|
24
23
|
from platformdirs import user_config_path
|
|
25
24
|
|
|
@@ -66,12 +65,20 @@ def get_default_editor() -> str:
|
|
|
66
65
|
return EDITORS.get(system(), EDITORS['default'])
|
|
67
66
|
|
|
68
67
|
|
|
69
|
-
def editfile(filename: Path) -> None:
|
|
68
|
+
def editfile(filename: Path, sudo_user: str) -> None:
|
|
70
69
|
"Run the editor command"
|
|
71
70
|
# Use explicit user defined editor or choose system default
|
|
72
|
-
editor =
|
|
71
|
+
editor = (
|
|
72
|
+
os.getenv(EDITOR)
|
|
73
|
+
or (sudo_user and os.getenv('SUDO_EDITOR'))
|
|
74
|
+
or os.getenv('EDITOR')
|
|
75
|
+
or get_default_editor()
|
|
76
|
+
)
|
|
73
77
|
editcmd = shlex.split(editor) + [str(filename)]
|
|
74
78
|
|
|
79
|
+
if sudo_user:
|
|
80
|
+
editcmd = ['runuser', '-u', sudo_user, '--'] + editcmd
|
|
81
|
+
|
|
75
82
|
# Run the editor ..
|
|
76
83
|
if sys.stdin.isatty():
|
|
77
84
|
res = subprocess.run(editcmd)
|
|
@@ -137,11 +144,11 @@ def remove(
|
|
|
137
144
|
cmd = 'git rm -f'.split()
|
|
138
145
|
if recurse:
|
|
139
146
|
cmd.append('-r')
|
|
140
|
-
|
|
147
|
+
_, err = run(cmd + [str(path)])
|
|
141
148
|
return f'git error: {err}' if err else None
|
|
142
149
|
|
|
143
150
|
if trash:
|
|
144
|
-
|
|
151
|
+
_, err = run(args.trash_program + [str(path)])
|
|
145
152
|
return f'{shlex.join(args.trash_program)} error: {err}' if err else None
|
|
146
153
|
|
|
147
154
|
if recurse and not path.is_symlink():
|
|
@@ -162,7 +169,7 @@ def remove(
|
|
|
162
169
|
def rename(pathsrc: Path, pathdest: Path, is_git: bool = False) -> str:
|
|
163
170
|
"Rename given pathsrc to pathdest"
|
|
164
171
|
if is_git:
|
|
165
|
-
|
|
172
|
+
_, err = run('git mv -f'.split() + [str(pathsrc), str(pathdest)])
|
|
166
173
|
if err:
|
|
167
174
|
err = f'git mv error: {err}'
|
|
168
175
|
else:
|
|
@@ -439,7 +446,12 @@ class Fpath:
|
|
|
439
446
|
else None
|
|
440
447
|
)
|
|
441
448
|
|
|
449
|
+
sudo_user = os.getenv('SUDO_USER', '')
|
|
450
|
+
|
|
442
451
|
with tempfile.TemporaryDirectory() as fdir:
|
|
452
|
+
if sudo_user:
|
|
453
|
+
shutil.chown(fdir, sudo_user)
|
|
454
|
+
|
|
443
455
|
# Create a temp file for the user to edit then read the lines back
|
|
444
456
|
fpath = Path(fdir, f'{PROG}{args.suffix}')
|
|
445
457
|
restart = True
|
|
@@ -448,8 +460,11 @@ class Fpath:
|
|
|
448
460
|
restart = False
|
|
449
461
|
cls.writefile(fpath)
|
|
450
462
|
|
|
463
|
+
if sudo_user:
|
|
464
|
+
shutil.chown(fpath, sudo_user)
|
|
465
|
+
|
|
451
466
|
# Invoke editor on list of paths
|
|
452
|
-
editfile(fpath)
|
|
467
|
+
editfile(fpath, sudo_user)
|
|
453
468
|
|
|
454
469
|
# Read the changed paths
|
|
455
470
|
cls.readfile(fpath)
|
|
@@ -718,7 +733,7 @@ def main() -> int:
|
|
|
718
733
|
filelist.insert(0, '-')
|
|
719
734
|
|
|
720
735
|
# Iterate over all (unique) inputs to get a list of files/dirs
|
|
721
|
-
for name in
|
|
736
|
+
for name in dict.fromkeys(filelist):
|
|
722
737
|
if name == '-':
|
|
723
738
|
for line in sys.stdin:
|
|
724
739
|
Fpath.add(line.rstrip('\n\r'), 0)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|