summaryrefslogtreecommitdiffstats
path: root/2022/talks/eshell.md
blob: b1ffac3251005ccec7f1ab5956a606f41bf14213 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
[[!sidebar content=""]]
[[!meta title="Top 10 reasons why you should be using Eshell"]]
[[!meta copyright="Copyright © 2022 Howard Abrams"]]
[[!inline pages="internal(2022/info/eshell-nav)" raw="yes"]]

<!-- Initially generated with emacsconf-generate-talk-page and then left alone for manual editing -->
<!-- You can manually edit this file to update the abstract, add links, etc. --->


# Top 10 reasons why you should be using Eshell
Howard Abrams (he/him)

[[!inline pages="internal(2022/info/eshell-before)" raw="yes"]]
[[!template id="help"
volunteer=""
summary="Q&A could be indexed with chapter markers"
tags="help_with_chapter_markers"
message="""The Q&A session for this talk does not have chapter markers yet.
Would you like to help? See [[help_with_chapter_markers]] for more details. You can use the vidid="eshell-qanda" if adding the markers to this wiki page, or e-mail your chapter notes to <emacsconf-submit@gnu.org>."""]]


While Eshell is this quick and dirty way to run external commands, its
*dirtiness* plays into the Lisp’s *malleable* big ball of mud metaphor,
and I have a number of quick hacks that will make you want to play in
this puddle.

This will be a lightning talk that I will pre-record to show off some
features in eshell I found while diving into the source code &#x2026; stuff
you can’t do in another terminals. Did you know that `$$` is a special
variable that contains the output from the last command?

Update from Howard: I wrote an _expanded transcript_ with more code and functional links. See <http://howardism.org/Technical/Emacs/eshell-why.html>
Want _all_ the code? See my literate dotfiles for #emacs at <https://github.com/howardabrams/hamacs/blob/main/ha-eshell.org>
# Discussion

## Notes

-   Full code:
    <https://github.com/howardabrams/hamacs/blob/main/ha-eshell.org>
-   Longer transcript:
    <http://howardism.org/Technical/Emacs/eshell-why.html>
-   Yes eshell is usefull!  Please help polishing and showing this stuff
    you found out.
-   Alvaro Ramirez has been doing the DWIM stuff
-   Regarding the not so well oiled parts of eshell. There are many
    efforts doing a better shell. I have the feeling we already have
    that in emacs already and it is just unfinished. But maybe that is
    just a statment about emacs in general.
-   Reach out to me if anyone wants to pair up and make a eshell-ext
    with many of the feature improvements I mentioned in my talk, that
    probably shouldn't clutter up the default eshell implementation.
- eshell is great for running top and htop (except I can't figure out how to input the function keys)
  - haha yeah i don't either  
- vterm isn't distracting - it has no new features to speak of  

## Questions and answers

-   Q: Do you fallback to vterm only when needing terminal emulation
    (ncurses/etc)? Or are there use cases or contexts where you use
    vterm over eshell beyond just terminal emulation needs?
    -   A: I do vterm mostly for SSH, but Docker builds and Ansible
        commands can cause a real mess of the screen, so I often run
        those commands in vterm ... but I'm not really working with
        that output.
-   Q: One issue I've had with eshell's TRAMP integration is that cd
    is host agnostic (as you point out). This means typing `cd` on a
    remote machine will cd back to $HOME on your local machine. Is
    there a way to cd to $HOME on the remote machine?
    -   A: It just isn't the way it behaves. While Eshell, with a
        Tramp-based cd command, will ssh "under the hood", it is
        temporary, as all the buffer work is local. I usually don't
        know what will happen, so I often need to switch to vterm for
        all ssh work. Which gets me upset when I encounter something
        that I would then like to use Eshell for (like piping the output
        back to my local Emacs buffer).
-   Q: Thank you for the missing Why eshell. Have you thought about
    adding it to the eshell manual?
    -   A: maybe I should team up with someone and improve on it
-   Q:Do you know if the eshell {} can be used from elisp? It could make
    for a nice elisp shell interface.
    -   A: Yes. Start with `eshell-command' and some variations on
        that.
-   Q: How does that interplay with your "literate-devops" approach,
    where things are done in an org buffer/document first instead of
    directly in the shell/terminal?
    -   A: the 2 are different. I use as REPL to test stuff
-   Q: Do you have a strategy for getting around eshell's lack of
    support for input redirection? (I also miss process substitution.)
    -   A: I have started sending output to Emacs buffers, where I can
        have more fun editing them than trying to get a pipe command
        sequence working. I wrote a function to pull a buffer back into
        Eshell to pipe back to something else. Pipes are problematic in
        Eshell.
-   Q: Can you call elisp functions as well (ie, not just commands)?
    -   A: Yes. Functions that start with eshell/ are called as if they
        were commands. However, all functions are available in eshell
        ... that is what makes it more interesting than the other
        comint-based term shells.
-   ~~Q: Aren't buffers the superior pipes? --> that was meant as a
    comment when he was asked about pipes, not a question per se -->
    alright~~
    -   A:Howard: yes
-   Q:Do you have a preferred method for getting argument completion for
    shell commands in Eshell?
    -   A: Check out
        <https://github.com/howardabrams/hamacs/blob/main/ha-eshell.org#getopts>
-   Q: Similarly, is it possible to get Eldoc-based completion for Elisp
    calls in Eshell?
    -   A: dont know. would be great, though
-   Q:Do you have thoughts about
    <https://www.masteringemacs.org/article/complete-guide-mastering-eshell#plan-9-smart-shell>
    ?  Summary: it effecitly adds a "| less" to every command so you
    get to see paged output if needed, except it is built into eshell.
    -   A: It is a cool idea, but while I tried it when Mickey first
        published that idea, it didn't stay in my workflow.
-   Q: Is $$ a built-in feature of eshell or did you add it?
    -   A: The Eshell built-in version of $$ doesn't always work, so
        I wrote an updated version that seems to work better (see
        <https://github.com/howardabrams/hamacs/blob/main/ha-eshell.org#last-results>)
        ... I'm pretty sure that if you do a command with a lot of
        output, it may not work at all, not just get the last of that
        output. Mine is just a better hack. :-D
-   Q: Do you ever fallback to terminals/shells outside Emacs, and if so
    in what circumstances?
    -   A: I boot up with a Terminal to mount remote file systems, as my
        Emacs configuration isn't always stored locally on my machine.
        I'll admit that I sometimes leave the Emacs Garden, but doing
        anything interesting become frustrating when you have to leave
        the keyboard for the mouse.
-   Q: What are the less well-oiled parts of Eshell or edge case issues
    that you encounter if any?
    -   A: We should make a list and start working on them.
-   Q:Do you have ways to improve eshell vterm interop like sharing
    command history and directory tracking?
    -   A: I don't. If I am going to SSH somewhere, I just start vterm,
        and haven't thought about any interop.

[[!inline pages="internal(2022/info/eshell-after)" raw="yes"]]

[[!inline pages="internal(2022/info/eshell-nav)" raw="yes"]]