reddit / emacs

Announcing Shell Underscore - Use the output of the last shell command in other commands

themathiasdahl 路 2022-08-10 12:38
All, I just hacked this together: https://github.com/mathiasdahl/shell-underscore Let me know what you think of it. Thanks!
xenodium 路 2022-08-10 20:13
Nice one. Great to see some shell/command experimentation.
Suitable_Motor_3671 路 2022-08-10 21:07
Indeed. I think there are many more opportunities for leveraging the fact that the shell runs inside Emacs. You can of course see Eshell like the greatest experiment of them all... 馃檪
howardthegeek 路 2022-08-10 21:19
A really interesting idea. I'm going to see if I can do something similar for eshell.
Cat_Marshal 路 2022-08-10 22:18
Looks fun
agumonkey 路 2022-08-11 01:07
pretty cool, one nitpick, local reuse reminds me of anaphoric macros which use 'it' as placeholder, do you think it could work ? (it's not critical, but it would be cuter and lispy in a way)
rswgnu 路 2022-08-11 03:02
If you use the Hyperbole package, then you get these shell features out of the box: Select any directory or file output from an ls command and display it in another window or frame. Random access to any source line referenced in the output of grep or many backtraces and errors without the need to use specialized Emacs commands like M-x grep.
themathiasdahl 路 2022-08-11 04:51
My guess is that it'll be much easier there.
themathiasdahl 路 2022-08-11 04:54
What's local reuse in this context? Can you point me to the part of the code you're thinking about?
donio 路 2022-08-11 05:54
Very nice! Didn't know about `comint-write-output`, this is a cool shortcut to take advantage of that.
themathiasdahl 路 2022-08-11 08:39
Same here 馃檪 It helped. There are several nice commands/functions for moving up and down the different "output groups", as they are called, and I could have implemented something like that myself too, but this was even simpler. It's a pity that it's buggy though, and don't correctly handle prompts with multiple lines. I'll try to workaround that though with some custom code.
jumper047 路 2022-08-11 11:10
Maybe it is worth to make placeholder string configurable?
xenodium 路 2022-08-11 13:21
The groups remind me of a tiny mod I did to add imenu support https://xenodium.com/imenu-on-emacs-eshell
themathiasdahl 路 2022-08-11 15:28
Yes, I've been thinking about it. Should be easy. Will it be used though? ... 馃檪
themathiasdahl 路 2022-08-11 15:33
I liked the hack. Long time Emacs user, almost never used imenu 馃檪 I guess I'm too used to just isearch my way around. But imenu is of course more specific in that you only search for a handful of all lines compared to what you find with isearch... Perhaps I should invest in trying to use it again. Do you have a favorite use case?
jumper047 路 2022-08-11 15:47
As you mentioned in readme, "if you using _ in your script this plugin probably is not for you" (am I remember it correctly?), so with this setting added your plugin will suit for these guys too:)
agumonkey 路 2022-08-11 16:33
By 'local reuse' i simply meant reusing the symbol for a local result, just like what you did.
xenodium 路 2022-08-11 17:05
Navigating classes, functions, etc. Also, there鈥檚 and extension for use-package (handy to jump around config).
themathiasdahl 路 2022-08-11 18:22
Yes 馃檪 The question is if it's hypothetical or not. But again, not very hard to implement.
themathiasdahl 路 2022-08-11 18:24
Ah! Got the idea partly from av similar feature in ielm in Emacs where you can refer to the previous three results with *, ** and ***.
themathiasdahl 路 2022-08-11 18:26
My latest Emacs setup uses use-package heavily, will give that a try. Thanks!
xenodium 路 2022-08-11 19:31
https://irreal.org/blog/?p=5916
themathiasdahl 路 2022-08-12 20:54
Thanks!