reddit / emacs

dwim-shell-command gives ya a reusable command history

xenodium · 2022-07-26 19:04
divinedominion · 2022-07-27 06:33
These DWIM shell commands are such a good idea! It's cool you share these use cases
xenodium · 2022-07-27 07:16
Glad you find them useful. Keen to see what others do with `dwim-shell-command` and `dwim-shell-command-on-marked-files` ([here's what I got so far](https://github.com/xenodium/dwim-shell-command/blob/main/dwim-shell-commands.el)). ps. The video shows explicit marking of files (with \*) after selecting region. I sprinkled a little more DWIM dust and you can now skip marking. Just select region and run command.
deaddyfreddy · 2022-07-27 08:40
Cool, but I prefer not to use shells for running complex commands directly at all, keeping scripts or [Babashka tasks](https://book.babashka.org/#tasks) in files not only gives you better editing experience, but (potentially) adds version control as well, so you don't lose any history at all.
xenodium · 2022-07-27 09:15
See `dwim-shell-command-on-marked-files ` https://xenodium.com/png-to-icns-emacs-dwim-style https://xenodium.com/emacs-dwim-shell-command-multi-language https://github.com/xenodium/dwim-shell-command/blob/main/dwim-shell-commands.el
_viz_ · 2022-07-27 09:49
Is this any different from regular minibuffer history? If not, what am I missing?
deaddyfreddy · 2022-07-27 10:14
Sorry, I don't get your point here. How `dwim-shell-command-on-marked-files` correlates with my comment above? But since you mentioned it, there's one issue: when you keep a pretty long script as a string in code - you don't have access to script's major mode advantages, like debug, autocompletion, linting, indentation and so on. Sure, you can use `edit-indirect` for that, but that's two more steps. Btw, there's another thing you may want to incorporate into your plugin - something like `transient` or `hydra`, so a user can have all commands together with descriptions on their fingertips (that's what shells usually lack).
xenodium · 2022-07-27 10:17
`dwim-shell-command` commands can be templated so they can be reused in different contexts without any edits. If the command was `cp image1.png image1_backup.png`, 1. It would have to be manually modified when reused from history. 2. Could not be batch-applied.
xenodium · 2022-07-27 10:32
> How dwim-shell-command-on-marked-files correlates with my comment above? The link to babashka tasks? https://imgur.com/a/3Fz4vEE Btw, We may be optimising for different use-cases, and that’s wonderful! We can all bend our beloved editor however we see fit.
_viz_ · 2022-07-27 10:43
So nothing special again. The way dired stores commands inputted from ! and & doesn't stop you from doing this either. (BTW, only thing dired lacks is <<fne>> so submitting a patch upstream would be much better, what you have right now can be replicated with dired-guess-shell-alist-user.)
xenodium · 2022-07-27 10:47
There’s more than that in the package. https://github.com/xenodium/dwim-shell-command has more details.
deaddyfreddy · 2022-07-28 08:09
> The link to babashka tasks? https://imgur.com/a/3Fz4vEE still can't get the point, are you sure you are aware of what Babashka is? > We may be optimising for different use-cases the only reasonable use case of computing is to do more job using fewer actions, so you have more time to do nothing
TiMueller · 2022-09-21 21:16
I really like it! I used the convert command from time to time and always had to look it up. Now I can do M-x from within emacs, fuzzy search for the right command, and even use dired to mark the files I need. Thank you, Alvaro! I'll also use the conversion to mp3 command.
xenodium · 2022-09-21 22:39
Hey, thank you. Nice to hear it! Feel free to share new commands you create. Happy to add them to the collection.
TiMueller · 2022-09-28 07:11
Might not be of use for everyone, but I am using it to convert pdfs to txt-files too. `(dwim-shell-command-on-marked-files "Convert to txt" "pdftotext -layout '<<f>>' '<<fne>>.txt'" :utils "pdftotext")`
xenodium · 2022-09-28 20:33
Hey, thanks! TIL about pdftotext, neat. Added https://github.com/xenodium/dwim-shell-command/commit/197d53d804a961ff0990e67d06d0fc67ba3aef32
TiMueller · 2022-09-29 05:43
Great! And what's a joy for me, by the way: When converting a whole album of music to mp3, being able to continue working with emacs while the converting happens asynchronously.
xenodium · 2022-09-29 08:27
Nice to hear it. Thank you.