edir 2.34__tar.gz → 2.36__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: edir
3
- Version: 2.34
3
+ Version: 2.36
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
@@ -186,7 +186,13 @@ following ways:
186
186
  26. `vidir` returns an error when attempting to rename across different
187
187
  file systems, which `edir` allows.
188
188
 
189
- 27. `edir` always ensures editor line numbers have the same width (e.g.
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.
190
196
  `1` to `6` for 6 files, or `01` to `12` for 12 files, etc) so that
191
197
  file names always line up justified. This facilitates block editing
192
198
  of file names, e.g. using vim's [visual block
@@ -194,7 +200,7 @@ following ways:
194
200
  do this so file names can be jagged wrt each other which makes block
195
201
  editing awkward.
196
202
 
197
- 28. `edir` is very strict about the format of the lines you edit and
203
+ 29. `edir` is very strict about the format of the lines you edit and
198
204
  immediately exits with an error message (before changing anything)
199
205
  if you format one of the lines incorrectly. All lines in the edited
200
206
  list:
@@ -210,7 +216,7 @@ following ways:
210
216
  line so an easy way to swap two file names is just to swap their
211
217
  numbers.
212
218
 
213
- 29. `edir` always actions files consistently. The sequence of
219
+ 30. `edir` always actions files consistently. The sequence of
214
220
  operations applied is:
215
221
 
216
222
  1. Deleted files are removed and all renamed files and directories
@@ -224,11 +230,11 @@ following ways:
224
230
 
225
231
  4. Remaining deleted directories are removed.
226
232
 
227
- In simple terms, remember that files are processed before
228
- directories so you can rename files into a different directory and
229
- then delete the original directory, all in one edit. However in
230
- practice it is far **less confusing and less risky** if you perform
231
- complicated renames and moves in distinct steps.
233
+ In simple terms, remember that files are processed before directories so
234
+ you can rename files into a different directory and then delete the
235
+ original directory, all in one edit. However in practice it is far **less
236
+ confusing and less risky** if you perform complicated renames and moves
237
+ across changed directories in distinct steps.
232
238
 
233
239
  ## Renames and Deletes in a GIT Repository
234
240
 
@@ -261,7 +267,7 @@ temporarily.
261
267
 
262
268
  You can specify an alternative trash program, e.g.
263
269
  [`trash-d`](https://github.com/rushsteve1/trash-d), or
264
- [`gio trash`](https://man.archlinux.org/man/gio.1#COMMANDS), or
270
+ [`gio trash`](https://man.archlinux.org/man/gio.1), or
265
271
  [`gtrash put`](https://github.com/umlx5h/gtrash),
266
272
  by setting the `--trash-program` option. Most likely you
267
273
  want to set this as a [default option](#command-default-options).
@@ -339,12 +345,16 @@ command line arguments. Comments in the file (i.e. starting with a `#`)
339
345
  are ignored. Type `edir -h` to see all [supported
340
346
  options](#command-line-options).
341
347
 
342
- The options `--interactive`, `--all`, `--recurse`, `--quiet`,
343
- `--no-git`, `--trash`, `--suffix`, `--no-color`, `--no-invert-color`,
344
- `--group-dirs-first/last`, `--trash-program` are sensible candidates to
345
- consider setting as default. If you set these then "on-the-fly" negation
346
- options `-I`, `-A`, `-R`, `-Q`, `-g`, `-T`, `-Z` are also provided to
347
- temporarily override and disable default options on the command line.
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
+ ```
348
358
 
349
359
  ## Examples
350
360
 
@@ -381,7 +391,7 @@ Type `edir -h` to view the usage summary:
381
391
  usage: edir [-h] [-i] [-I] [-a] [-A] [-r] [-R] [-q] [-Q] [-G] [-g] [-t]
382
392
  [-T] [--trash-program TRASH_PROGRAM] [-c] [-C] [-d DEPTH] [-F |
383
393
  -D] [-L] [-N] [-M] [-S] [-O] [--OP OP] [-E] [-X] [-Y] [-Z]
384
- [--suffix SUFFIX] [-V]
394
+ [--suffix SUFFIX] [--no-relative] [-V] [--conf]
385
395
  [args ...]
386
396
 
387
397
  Command line utility to rename, remove, or copy files and directories directly
@@ -434,7 +444,11 @@ options:
434
444
  group directories last (including when sorted)
435
445
  -Z, --no-group-dirs negate the options to group directories
436
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
437
449
  -V, --version show edir version
450
+ --conf just invoke your editor on your startup options
451
+ configuration file
438
452
 
439
453
  Note you can set default starting options in ~/.config/edir-flags.conf. The
440
454
  negation options (i.e. the --no-* options) allow you to temporarily override
@@ -446,10 +460,10 @@ your defaults.
446
460
  You can use `edir` with [`sudo`][sudo] to rename, delete, or copy system files.
447
461
  For improved convenience and security, `edir` runs the editing session as your
448
462
  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:
463
+ approach allows you to use graphical editors (like VS Code or Zed etc), which
464
+ normally should not be run as root. Use `sudo -E` so that your preferred editor
465
+ is selected via your `$EDIR_EDITOR` or `$EDITOR` environment variable. For
466
+ example, to rename or delete files in `/etc` using VS Code:
453
467
 
454
468
  ```sh
455
469
  $ export EDIR_EDITOR="code -nw"
@@ -461,8 +475,9 @@ $ sudo -E edir /etc
461
475
  In many ways `edir` (and even `vidir`) is better than the [`ranger`][ranger]
462
476
  terminal file manager
463
477
  [`bulkrename`](https://github.com/ranger/ranger/wiki/Official-user-guide#bulk-renaming)
464
- command which does not handle name swaps and clashes etc. To add `edir` as a
465
- command within [`ranger`][ranger], add or create the following in
478
+ command which does not handle name swaps and clashes etc. Also, use `edir` to
479
+ delete or copy files, not just rename them. To add `edir` as a command within
480
+ [`ranger`][ranger], add or create the following in
466
481
  `~/.config/ranger/commands.py`. Then run it from within [`ranger`][ranger] by
467
482
  typing `:edir`.
468
483
 
@@ -485,7 +500,23 @@ class edir(Command):
485
500
  ## Use with Yazi File Manager
486
501
 
487
502
  If you use [`yazi`][yazi] for your file manager then you don't need any special
488
- configuration. Just type `:edir` from within [`yazi`][yazi].
503
+ configuration. Just type `:edir` from within [`yazi`][yazi] to rename or delete
504
+ or copy file names in the current directory.
505
+
506
+ You can also replace the standard rename function (`r` key) in [`yazi`][yazi]
507
+ to use `edir` on selected files by adding the following to your
508
+ `~/.config/yazi/keymap.toml` file:
509
+
510
+ ```toml
511
+ [[mgr.prepend_keymap]]
512
+ on = "r"
513
+ run = "shell --block -- edir -d0 -q %s"
514
+ desc = "Run edir on selected files/dirs"
515
+ ```
516
+
517
+ So press `r` on the current selection to rename (or delete or copy) that single
518
+ file name using `edir`. Alternately, select multiple files (or all files with
519
+ the `yazi` standard key binding `Ctrl+a`), before pressing `r`.
489
520
 
490
521
  ## License
491
522
 
@@ -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` always ensures editor line numbers have the same width (e.g.
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
- 28. `edir` is very strict about the format of the lines you edit and
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
- 29. `edir` always actions files consistently. The sequence of
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
@@ -210,11 +216,11 @@ following ways:
210
216
 
211
217
  4. Remaining deleted directories are removed.
212
218
 
213
- In simple terms, remember that files are processed before
214
- directories so you can rename files into a different directory and
215
- then delete the original directory, all in one edit. However in
216
- practice it is far **less confusing and less risky** if you perform
217
- complicated renames and moves in distinct steps.
219
+ In simple terms, remember that files are processed before directories so
220
+ you can rename files into a different directory and then delete the
221
+ original directory, all in one edit. However in practice it is far **less
222
+ confusing and less risky** if you perform complicated renames and moves
223
+ across changed directories in distinct steps.
218
224
 
219
225
  ## Renames and Deletes in a GIT Repository
220
226
 
@@ -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#COMMANDS), or
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
- The options `--interactive`, `--all`, `--recurse`, `--quiet`,
329
- `--no-git`, `--trash`, `--suffix`, `--no-color`, `--no-invert-color`,
330
- `--group-dirs-first/last`, `--trash-program` are sensible candidates to
331
- consider setting as default. If you set these then "on-the-fly" negation
332
- options `-I`, `-A`, `-R`, `-Q`, `-g`, `-T`, `-Z` are also provided to
333
- temporarily override and disable default options on the command line.
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
 
@@ -367,7 +377,7 @@ Type `edir -h` to view the usage summary:
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
379
  -D] [-L] [-N] [-M] [-S] [-O] [--OP OP] [-E] [-X] [-Y] [-Z]
370
- [--suffix SUFFIX] [-V]
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
@@ -420,7 +430,11 @@ options:
420
430
  group directories last (including when sorted)
421
431
  -Z, --no-group-dirs negate the options to group directories
422
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
423
435
  -V, --version show edir version
436
+ --conf just invoke your editor on your startup options
437
+ configuration file
424
438
 
425
439
  Note you can set default starting options in ~/.config/edir-flags.conf. The
426
440
  negation options (i.e. the --no-* options) allow you to temporarily override
@@ -432,10 +446,10 @@ your defaults.
432
446
  You can use `edir` with [`sudo`][sudo] to rename, delete, or copy system files.
433
447
  For improved convenience and security, `edir` runs the editing session as your
434
448
  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:
449
+ approach allows you to use graphical editors (like VS Code or Zed etc), which
450
+ normally should not be run as root. Use `sudo -E` so that your preferred editor
451
+ is selected via your `$EDIR_EDITOR` or `$EDITOR` environment variable. For
452
+ example, to rename or delete files in `/etc` using VS Code:
439
453
 
440
454
  ```sh
441
455
  $ export EDIR_EDITOR="code -nw"
@@ -447,8 +461,9 @@ $ sudo -E edir /etc
447
461
  In many ways `edir` (and even `vidir`) is better than the [`ranger`][ranger]
448
462
  terminal file manager
449
463
  [`bulkrename`](https://github.com/ranger/ranger/wiki/Official-user-guide#bulk-renaming)
450
- command which does not handle name swaps and clashes etc. To add `edir` as a
451
- command within [`ranger`][ranger], add or create the following in
464
+ command which does not handle name swaps and clashes etc. Also, use `edir` to
465
+ delete or copy files, not just rename them. To add `edir` as a command within
466
+ [`ranger`][ranger], add or create the following in
452
467
  `~/.config/ranger/commands.py`. Then run it from within [`ranger`][ranger] by
453
468
  typing `:edir`.
454
469
 
@@ -471,7 +486,23 @@ class edir(Command):
471
486
  ## Use with Yazi File Manager
472
487
 
473
488
  If you use [`yazi`][yazi] for your file manager then you don't need any special
474
- configuration. Just type `:edir` from within [`yazi`][yazi].
489
+ configuration. Just type `:edir` from within [`yazi`][yazi] to rename or delete
490
+ or copy file names in the current directory.
491
+
492
+ You can also replace the standard rename function (`r` key) in [`yazi`][yazi]
493
+ to use `edir` on selected files by adding the following to your
494
+ `~/.config/yazi/keymap.toml` file:
495
+
496
+ ```toml
497
+ [[mgr.prepend_keymap]]
498
+ on = "r"
499
+ run = "shell --block -- edir -d0 -q %s"
500
+ desc = "Run edir on selected files/dirs"
501
+ ```
502
+
503
+ So press `r` on the current selection to rename (or delete or copy) that single
504
+ file name using `edir`. Alternately, select multiple files (or all files with
505
+ the `yazi` standard key binding `Ctrl+a`), before pressing `r`.
475
506
 
476
507
  ## License
477
508
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: edir
3
- Version: 2.34
3
+ Version: 2.36
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
@@ -186,7 +186,13 @@ following ways:
186
186
  26. `vidir` returns an error when attempting to rename across different
187
187
  file systems, which `edir` allows.
188
188
 
189
- 27. `edir` always ensures editor line numbers have the same width (e.g.
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.
190
196
  `1` to `6` for 6 files, or `01` to `12` for 12 files, etc) so that
191
197
  file names always line up justified. This facilitates block editing
192
198
  of file names, e.g. using vim's [visual block
@@ -194,7 +200,7 @@ following ways:
194
200
  do this so file names can be jagged wrt each other which makes block
195
201
  editing awkward.
196
202
 
197
- 28. `edir` is very strict about the format of the lines you edit and
203
+ 29. `edir` is very strict about the format of the lines you edit and
198
204
  immediately exits with an error message (before changing anything)
199
205
  if you format one of the lines incorrectly. All lines in the edited
200
206
  list:
@@ -210,7 +216,7 @@ following ways:
210
216
  line so an easy way to swap two file names is just to swap their
211
217
  numbers.
212
218
 
213
- 29. `edir` always actions files consistently. The sequence of
219
+ 30. `edir` always actions files consistently. The sequence of
214
220
  operations applied is:
215
221
 
216
222
  1. Deleted files are removed and all renamed files and directories
@@ -224,11 +230,11 @@ following ways:
224
230
 
225
231
  4. Remaining deleted directories are removed.
226
232
 
227
- In simple terms, remember that files are processed before
228
- directories so you can rename files into a different directory and
229
- then delete the original directory, all in one edit. However in
230
- practice it is far **less confusing and less risky** if you perform
231
- complicated renames and moves in distinct steps.
233
+ In simple terms, remember that files are processed before directories so
234
+ you can rename files into a different directory and then delete the
235
+ original directory, all in one edit. However in practice it is far **less
236
+ confusing and less risky** if you perform complicated renames and moves
237
+ across changed directories in distinct steps.
232
238
 
233
239
  ## Renames and Deletes in a GIT Repository
234
240
 
@@ -261,7 +267,7 @@ temporarily.
261
267
 
262
268
  You can specify an alternative trash program, e.g.
263
269
  [`trash-d`](https://github.com/rushsteve1/trash-d), or
264
- [`gio trash`](https://man.archlinux.org/man/gio.1#COMMANDS), or
270
+ [`gio trash`](https://man.archlinux.org/man/gio.1), or
265
271
  [`gtrash put`](https://github.com/umlx5h/gtrash),
266
272
  by setting the `--trash-program` option. Most likely you
267
273
  want to set this as a [default option](#command-default-options).
@@ -339,12 +345,16 @@ command line arguments. Comments in the file (i.e. starting with a `#`)
339
345
  are ignored. Type `edir -h` to see all [supported
340
346
  options](#command-line-options).
341
347
 
342
- The options `--interactive`, `--all`, `--recurse`, `--quiet`,
343
- `--no-git`, `--trash`, `--suffix`, `--no-color`, `--no-invert-color`,
344
- `--group-dirs-first/last`, `--trash-program` are sensible candidates to
345
- consider setting as default. If you set these then "on-the-fly" negation
346
- options `-I`, `-A`, `-R`, `-Q`, `-g`, `-T`, `-Z` are also provided to
347
- temporarily override and disable default options on the command line.
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
+ ```
348
358
 
349
359
  ## Examples
350
360
 
@@ -381,7 +391,7 @@ Type `edir -h` to view the usage summary:
381
391
  usage: edir [-h] [-i] [-I] [-a] [-A] [-r] [-R] [-q] [-Q] [-G] [-g] [-t]
382
392
  [-T] [--trash-program TRASH_PROGRAM] [-c] [-C] [-d DEPTH] [-F |
383
393
  -D] [-L] [-N] [-M] [-S] [-O] [--OP OP] [-E] [-X] [-Y] [-Z]
384
- [--suffix SUFFIX] [-V]
394
+ [--suffix SUFFIX] [--no-relative] [-V] [--conf]
385
395
  [args ...]
386
396
 
387
397
  Command line utility to rename, remove, or copy files and directories directly
@@ -434,7 +444,11 @@ options:
434
444
  group directories last (including when sorted)
435
445
  -Z, --no-group-dirs negate the options to group directories
436
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
437
449
  -V, --version show edir version
450
+ --conf just invoke your editor on your startup options
451
+ configuration file
438
452
 
439
453
  Note you can set default starting options in ~/.config/edir-flags.conf. The
440
454
  negation options (i.e. the --no-* options) allow you to temporarily override
@@ -446,10 +460,10 @@ your defaults.
446
460
  You can use `edir` with [`sudo`][sudo] to rename, delete, or copy system files.
447
461
  For improved convenience and security, `edir` runs the editing session as your
448
462
  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:
463
+ approach allows you to use graphical editors (like VS Code or Zed etc), which
464
+ normally should not be run as root. Use `sudo -E` so that your preferred editor
465
+ is selected via your `$EDIR_EDITOR` or `$EDITOR` environment variable. For
466
+ example, to rename or delete files in `/etc` using VS Code:
453
467
 
454
468
  ```sh
455
469
  $ export EDIR_EDITOR="code -nw"
@@ -461,8 +475,9 @@ $ sudo -E edir /etc
461
475
  In many ways `edir` (and even `vidir`) is better than the [`ranger`][ranger]
462
476
  terminal file manager
463
477
  [`bulkrename`](https://github.com/ranger/ranger/wiki/Official-user-guide#bulk-renaming)
464
- command which does not handle name swaps and clashes etc. To add `edir` as a
465
- command within [`ranger`][ranger], add or create the following in
478
+ command which does not handle name swaps and clashes etc. Also, use `edir` to
479
+ delete or copy files, not just rename them. To add `edir` as a command within
480
+ [`ranger`][ranger], add or create the following in
466
481
  `~/.config/ranger/commands.py`. Then run it from within [`ranger`][ranger] by
467
482
  typing `:edir`.
468
483
 
@@ -485,7 +500,23 @@ class edir(Command):
485
500
  ## Use with Yazi File Manager
486
501
 
487
502
  If you use [`yazi`][yazi] for your file manager then you don't need any special
488
- configuration. Just type `:edir` from within [`yazi`][yazi].
503
+ configuration. Just type `:edir` from within [`yazi`][yazi] to rename or delete
504
+ or copy file names in the current directory.
505
+
506
+ You can also replace the standard rename function (`r` key) in [`yazi`][yazi]
507
+ to use `edir` on selected files by adding the following to your
508
+ `~/.config/yazi/keymap.toml` file:
509
+
510
+ ```toml
511
+ [[mgr.prepend_keymap]]
512
+ on = "r"
513
+ run = "shell --block -- edir -d0 -q %s"
514
+ desc = "Run edir on selected files/dirs"
515
+ ```
516
+
517
+ So press `r` on the current selection to rename (or delete or copy) that single
518
+ file name using `edir`. Alternately, select multiple files (or all files with
519
+ the `yazi` standard key binding `Ctrl+a`), before pressing `r`.
489
520
 
490
521
  ## License
491
522
 
@@ -0,0 +1 @@
1
+ edir
@@ -21,7 +21,6 @@ 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
25
24
 
26
25
  # Some constants
27
26
  PROG = Path(sys.argv[0]).stem
@@ -54,6 +53,7 @@ COLOR_reset = '\033[39;49m'
54
53
  args = argparse.Namespace()
55
54
  gitfiles = set()
56
55
  counts = [0, 0]
56
+ cwd = Path.cwd()
57
57
 
58
58
  EDITORS = {'Windows': 'notepad', 'Darwin': 'open -e', 'default': 'vim'}
59
59
 
@@ -62,7 +62,7 @@ def get_default_editor() -> str:
62
62
  "Return default editor for this system"
63
63
  from platform import system
64
64
 
65
- return EDITORS.get(system(), EDITORS['default'])
65
+ return EDITORS.get(system()) or EDITORS['default']
66
66
 
67
67
 
68
68
  def make_editor_command(filename: str, sudo_user: str) -> tuple[str, list[str]]:
@@ -82,7 +82,7 @@ def make_editor_command(filename: str, sudo_user: str) -> tuple[str, list[str]]:
82
82
  return editor, editcmd
83
83
 
84
84
 
85
- def editfile(editor: str, editcmd: list[str]) -> None:
85
+ def edit_file(editor: str, editcmd: list[str]) -> None:
86
86
  "Run the editor command"
87
87
 
88
88
  # Run the editor ..
@@ -97,6 +97,23 @@ def editfile(editor: str, editcmd: list[str]) -> None:
97
97
  sys.exit(f'ERROR: "{editor}" returned error {res.returncode}')
98
98
 
99
99
 
100
+ def edit_file_conf(conf_file: Path) -> None:
101
+ "Edit the startup options configuration file"
102
+ conf_file.parent.mkdir(parents=True, exist_ok=True)
103
+
104
+ if not conf_file.is_file() or conf_file.stat().st_size == 0:
105
+ conf_file.write_text(
106
+ '# Add your default edir options, one option per line. Comments are ignored.\n'
107
+ )
108
+
109
+ editor = os.getenv('EDITOR') or get_default_editor()
110
+ edit_file(editor, [editor, str(conf_file)])
111
+
112
+ # Remove the edited config file if it is empty
113
+ if conf_file.is_file() and conf_file.stat().st_size == 0:
114
+ conf_file.unlink()
115
+
116
+
100
117
  def log(
101
118
  action: str, msg: str, error: str | None = None, *, prompt: bool = False
102
119
  ) -> None:
@@ -265,6 +282,10 @@ class Fpath:
265
282
 
266
283
  return path
267
284
 
285
+ def changed(self, newpath: Path | None = None) -> bool:
286
+ "Return True if path has been changed"
287
+ return str(newpath or self.newpath) != self.repr
288
+
268
289
  def copy(self, pathdest: Path) -> str | None:
269
290
  "Copy given pathsrc to pathdest"
270
291
  if self.is_dir:
@@ -278,7 +299,7 @@ class Fpath:
278
299
  except Exception as e:
279
300
  return str(e)
280
301
  try:
281
- func(str(self.newpath), str(pathdest)) # type:ignore
302
+ func(str(self.newpath), str(pathdest))
282
303
  except Exception as e:
283
304
  return str(e)
284
305
 
@@ -352,7 +373,7 @@ class Fpath:
352
373
  "Log all pending changes for this path"
353
374
  if not self.newpath:
354
375
  log('remove', f'"{self.diagrepr}"{self.note}', prompt=True)
355
- elif self.newpath != self.path:
376
+ elif self.changed():
356
377
  log(
357
378
  'rename',
358
379
  f'"{self.diagrepr}" to "{self.newpath}{self.appdash}"',
@@ -368,22 +389,24 @@ class Fpath:
368
389
  @classmethod
369
390
  def make_natsort_key(cls, optstr: str | None) -> None:
370
391
  "Create natsort key function from given option string"
392
+ from natsort import natsort_keygen, ns
393
+
371
394
  if optstr:
372
395
  sep = '|' if '|' in optstr else ','
373
396
  optval = 0
374
397
  for opt in optstr.split(sep):
375
398
  if opt := removeprefix(opt.strip().upper(), 'NS.'):
376
399
  try:
377
- nsval = getattr(natsort.ns, opt)
400
+ nsval = getattr(ns, opt)
378
401
  except AttributeError as e:
379
402
  sys.exit(f'ERROR: invalid natsort option: {str(e)}')
380
403
 
381
404
  if nsval and isinstance(nsval, int):
382
405
  optval |= nsval
383
406
 
384
- cls.natsort_key = natsort.natsort_keygen(key=lambda x: x.repr, alg=optval)
407
+ cls.natsort_key = natsort_keygen(key=lambda x: x.repr, alg=optval)
385
408
  else:
386
- cls.natsort_key = natsort.natsort_keygen(key=lambda x: x.repr)
409
+ cls.natsort_key = natsort_keygen(key=lambda x: x.repr)
387
410
 
388
411
  @classmethod
389
412
  def remove_temps(cls) -> None:
@@ -414,9 +437,17 @@ class Fpath:
414
437
  def add(cls, name: str, depth: int) -> None:
415
438
  "Add file[s]/dir[s] to the list of paths"
416
439
  path = Path(name)
440
+
417
441
  if not path.exists():
418
442
  sys.exit(f'ERROR: {name} does not exist')
419
443
 
444
+ if not args.no_relative:
445
+ # Make path relative to current working dir if possible
446
+ try:
447
+ path = path.relative_to(cwd)
448
+ except ValueError:
449
+ pass
450
+
420
451
  if path.is_dir():
421
452
  for child in find_in_dir(path, depth, args.all):
422
453
  cls.append(child)
@@ -472,7 +503,7 @@ class Fpath:
472
503
  newpath = Path(pathstr)
473
504
 
474
505
  if path.newpath:
475
- if newpath != path.path and newpath not in path.copies:
506
+ if path.changed(newpath) and newpath not in path.copies:
476
507
  path.copies.append(newpath)
477
508
  else:
478
509
  path.newpath = newpath
@@ -508,13 +539,13 @@ class Fpath:
508
539
  shutil.chown(fpath, sudo_user)
509
540
 
510
541
  # Invoke editor on file containing the list of paths
511
- editfile(editor, editcmd)
542
+ edit_file(editor, editcmd)
512
543
 
513
544
  # Read the changed paths from the file
514
545
  cls.readfile(fpath)
515
546
 
516
547
  # Reduce paths to those that were removed or changed by the user
517
- paths = [p for p in cls.paths if p.path != p.newpath or p.copies]
548
+ paths = [p for p in cls.paths if p.changed() or p.copies]
518
549
 
519
550
  if not paths:
520
551
  return []
@@ -738,9 +769,19 @@ def main() -> int:
738
769
  default=SUFFIX,
739
770
  help='specify suffix for temp editor file, default="%(default)s"',
740
771
  )
772
+ opt.add_argument(
773
+ '--no-relative',
774
+ action='store_true',
775
+ help='do not forcibly show paths relative to current working directory',
776
+ )
741
777
  opt.add_argument(
742
778
  '-V', '--version', action='store_true', help=f'show {PROG} version'
743
779
  )
780
+ opt.add_argument(
781
+ '--conf',
782
+ action='store_true',
783
+ help='just invoke your editor on your startup options configuration file',
784
+ )
744
785
  opt.add_argument('args', nargs='*', help='file|dir, or "-" for stdin')
745
786
 
746
787
  args = opt.parse_args()
@@ -756,9 +797,18 @@ def main() -> int:
756
797
  print(ver)
757
798
  return 0
758
799
 
800
+ if args.conf:
801
+ # Edit the configuration file and exit
802
+ if not (conf_file := opt.from_file_path):
803
+ opt.error('No configuration file path determined.')
804
+ return 1
805
+
806
+ edit_file_conf(conf_file)
807
+ return 0
808
+
759
809
  if args.trash:
760
810
  if not args.trash_program:
761
- opt.error('must specify trash program with --trash-program option')
811
+ opt.error('must specify trash program with --trash-program option.')
762
812
 
763
813
  args.trash_program = args.trash_program.split()
764
814
 
@@ -771,7 +821,7 @@ def main() -> int:
771
821
  gitfiles.update(out.splitlines())
772
822
 
773
823
  if args.git and not gitfiles:
774
- opt.error('must be within a git repo to use -g/--git option')
824
+ opt.error('must be within a git repo to use -g/--git option.')
775
825
 
776
826
  # Set input list to a combination of arguments and stdin
777
827
  filelist = args.args
@@ -828,7 +878,7 @@ def main() -> int:
828
878
  # files.
829
879
  for p in paths:
830
880
  if p.newpath:
831
- if p.newpath != p.path:
881
+ if p.changed():
832
882
  if err := p.rename_temp():
833
883
  log('rename', f'"{p.diagrepr}" to "{p.newpath}{p.appdash}"', err)
834
884
  elif not p.is_dir:
@@ -1,4 +1,4 @@
1
- PYFILES := file_name(justfile_dir()) + '.py'
1
+ PYFILES := file_name(justfile_directory()) + '.py'
2
2
 
3
3
  check:
4
4
  ruff check {{PYFILES}}
@@ -1 +0,0 @@
1
- tmp
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes