summaryrefslogblamecommitdiffstats
path: root/2022/talks/eshell.md
blob: 7ff7bbef252dcf59a480b9027cd04b0067f05673 (plain) (tree)
1
                       



















                                                                                                     
                                                                        

                                                        

                                                                                                                                                    
















                                                                         
                                                                    


                                                                                                     







                                                                    
                                                                   
                    






                                                                    








                                                                        
                                                                  
             
                                                                    


                                                                    
                                                                 








                                                                       
                                                                 
                                 

                                                                    










                                                                                               
                                                                     

                                                                      


                                                                    

                                                                                      
                                                                  




                                                                        

                                                                      






                                                                       

                                                                       





                                                              
[[!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"]]

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"]]