Álvaro Ramírez
dwim-shell-command usages: pdftotext and scp
dwim-shell-command is a little Emacs package I wrote to enable crafting more reusable shell commands. I intended to use it as an async-shell-command alternative (and I do these days). The more surprising win was bringing lots of command-line utilities (sometimes with complicated invocations) and making them quickly accessible. I no longer need to remember their respective parameters, order, flags, etc.
I've migrated most one-liners and scripts I had to dwim-shell-command equivalents. They are available at dwim-shell-commands.el. Having said that, it's great to discover new usages from dwim-shell-command
users.
Take u/TiMueller's Reddit comment, showcasing pdftotext. Neat utility I was unaware of. It does as it says on the tin and converts a pdf to text. Can be easily saved to your accessible repertoire with:
(defun dwim-shell-commands-pdf-to-txt () "Convert pdf to txt." (interactive) (dwim-shell-command-on-marked-files "pdf to txt" "pdftotext -layout '<<f>>' '<<fne>>.txt'" :utils "pdftotext"))
tareefdev wanted a quick command to secure copy remote files to a local directory. Though this use-case is already covered by Tramp, I suspect a DWIM command would make it a little more convenient (async by default). However, Tramp paths aren't usable from the shell unless we massage them a little. We can use dwim-shell-command-on-marked-files
's :post-process-template
to drop the "/ssh:" prefix.
(defun dwim-shell-commands-copy-remote-to-downloads () (interactive) (dwim-shell-command-on-marked-files "Copy remote to local Downloads" "scp '<<f>>' ~/Downloads/" :utils "scp" :post-process-template (lambda (script file) ;; Tramp file path start with "/ssh:". Drop it. (string-replace file (string-remove-prefix "/ssh:" file) script))))
dwim-shell-command is available on MELPA (531 downloads as of 2022-10-01).