A utility to mark and operate on files in the shell.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123 lines
3.8 KiB

  1. marks - mark and operate on files
  2. =================================
  3. **This is a rough proof of concept. It probably won't eat your files, but I
  4. make no promises whatsoever.**
  5. synopsis
  6. --------
  7. <!-- exec -->
  8. $ marks --help
  9. /usr/local/bin/marks - mark and operate on files
  10. Usage: marks [command] [args]
  11. marks - List current marks (shortcut for mark ls)
  12. marks add [path] - Add a file path to the mark list
  13. marks + [path] - Shorthand for add
  14. marks remove [path] - Remove a file path from the mark list
  15. marks - [path] - Shorthand for remove
  16. marks clear - Clear mark list
  17. marks cp - Copy marked files to current directory
  18. marks each [cmd] - Execute command for each marked file
  19. marks ls - List current marks
  20. marks mv - Move files to current directory and unmark
  21. marks -h - Print this help message
  22. <!-- end -->
  23. example
  24. -------
  25. ```
  26. # Some files to work with:
  27. brennen@inertia:~/Downloads $ ls
  28. binti.epub rogue_protocol.epub unix_reader.pdf
  29. # Mark a couple of them:
  30. brennen@inertia:~/Downloads $ mark + *.epub
  31. brennen@inertia:~/Downloads $ marks
  32. /home/brennen/Downloads/rogue_protocol.epub
  33. /home/brennen/Downloads/binti.epub
  34. # Jump to a target directory:
  35. brennen@inertia:~/Downloads $ cd ~/books/sf
  36. # Move the files here:
  37. brennen@inertia:~/books/sf $ marks mv
  38. Moved: /home/brennen/Downloads/rogue_protocol.epub
  39. Moved: /home/brennen/Downloads/binti.epub
  40. # Note that the mark list is now empty:
  41. brennen@inertia:~/books/sf $ marks
  42. brennen@inertia:~/books/sf $
  43. ```
  44. installing
  45. ----------
  46. I haven't uploaded a recent version of this to CPAN yet. For now,
  47. I expect this would work on a Debian, at any rate:
  48. ```sh
  49. # Module::Build may be installed, but if not, either:
  50. sudo apt install libmodule-build-perl
  51. # Or:
  52. sudo cpan -i Module::Build
  53. # Then:
  54. git clone https://code.p1k3.com/gitea/brennen/app-markfiles.git
  55. cd app-markfiles
  56. perl Build.PL
  57. ./Build installdeps
  58. ./Build test
  59. sudo ./Build install
  60. ```
  61. rationale, notes
  62. ----------------
  63. This is a proof of concept and the interface might change. Right now it's in
  64. poorly-organized Perl and shell, and has some dependencies. It's pretty tiny
  65. and maybe I'll polish it up or port it to some language that squicks the cool
  66. kids out less, but also I might not if it suits my needs well enough. Right
  67. now it's in a state where it feels usable on my machine, so I think you could
  68. probably try it, but there are definitely bugs.
  69. In the very simple case this is a worse interface than just typing `mv
  70. somefiles ~/some/path`. All the same, I find it pretty handy to stash the path
  71. of one or more files somewhere while I figure out what I'm going to do with
  72. them, and it permits building up a list while hopping around the filesystem
  73. working on other things.
  74. There are definitely bugs in this implementation.
  75. This is meant to enable unixy one-tool-one-job patterns (thanks to Joey Hess
  76. for the suggestion):
  77. ```sh
  78. marks + *.foo
  79. mv $(marks) dest
  80. ```
  81. ...but it also includes convenience cruft like `marks cp`, `marks mv`, and
  82. `marks each`. My thinking is that it's nice to be able to do operations that
  83. clear files from the list as they're manipulated, and have a few extra built-in
  84. guard rails.
  85. I'm not totally sure how interactive this should be / how much handholding I
  86. want.
  87. TODO
  88. ----
  89. - [ ] sqlite - too heavyweight?
  90. - [ ] sqlite - version the schema, if there's a good reason to keep it
  91. - [ ] handle `~` expansion (and general shell globbing?) in files/stdin?
  92. - [ ] more graceful installation instrux
  93. - [ ] `remove` feels like it's going to get confused with an operation that
  94. deletes the file rather than removing the mark from the list. Should
  95. this be called `unmark` or something instead?
  96. - [ ] it'd be cool to plumb this into fzf a little bit