summaryrefslogblamecommitdiffstats
path: root/2024/talks/shell.md
blob: 8642efe10484ad8f37a7d6651f6617d7673dc140 (plain) (tree)
























                                                                                                    
                                               
 

                                                                                                                     
 
































































                                                                                                                                                                                                                                                                                                                     




                                                             
[[!meta title="Emacs as a Shell"]]
[[!meta copyright="Copyright © 2024 Christopher Howard"]]
[[!inline pages="internal(2024/info/shell-nav)" raw="yes"]]

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


# Emacs as a Shell
Christopher Howard (he/him) - IRC: lispmacs, <mailto:christopher@librehacker.com>

[[!inline pages="internal(2024/info/shell-before)" raw="yes"]]

A shell, such as Bash, is fundamentally an
interface to your operating system. It allows you
to run programs, direct I/O, manage processes, and
interact with the file system, as well as script
such activities. Allowing for a few caveats, we
can see that Emacs is capable of doing all these
things, and therefore Emacs can be used a
practical replacement for the traditional shell.
This talk aims to explain this philosophy, to
explore Emacs' basic shell functionality, and to
address various caveats.

See also these other talks by the same speaker:

- [EmacsConf - 2024 - talks - Watering my (digital) plant with Emacs timers](https://emacsconf.org/2024/talks/water/)
- [EmacsConf - 2023 - talks - Org-Mode Workflow: Informal Reference Tracking](https://emacsconf.org/2023/talks/ref/)

# Discussion

-   a nice interface for using process filters directly sounds really
    useful, reminds me of emacs-piper

- Uniline?
  - lispmacs[work]: gs-101: yes
- feels like a museum to see someone using helm x)
  - lispmacs[work]: heh heh
  - lispmacs[work]: it was the first one I learned, now I'm hooked
  - gs-101: First one I used was Ivy + Counsel, but then I moved to the Vertico + Consult stack as it was newer.
- lispmacs[work]: I haven't had any pressuring motivations to try anything else yet, but am open minded
- Is there a convenient way to share shell history between Eshell and the system shell (fish in my case)?
  - lispmacs[work]: I know there is, but I don't use it. let me check the eshell modules list
  - I use atuin and eshell-atuin to share shell history across programs, shells and machines.
  - Ah yes, I gave atuin a try some time ago but I hate that it takes over full terminal for history. Not sure if that changed now though.
  - lispmacs[work]: I'm not seeing something like that in the built-in Eshell Modules List unless eshell-hist does something like that
  - i use my consult-shell-command package which is a small wrapper around async-shell-command that also suggests shell history :D https://codeberg.org/mekeor/consult-shell-command
  - atuin is a CLI utility; eshell-atuin is a third party Emacs package. (https://github.com/SqrtMinusOne/eshell-atuin/)
  - there is also https://github.com/svaante/recall by dape.el-developer with a similar goal
- I need to look more into Eshell. Just started using native Emacs on Windows and switched from cmd.exe in shell mode to PowerShell, but it would be nice to have a better shell that I can use both on my home machines and the two work machines that run GNU/Linux that would also work on my work Windows laptop.
  - Yes, I saw that's one of the main use cases for ehsell. But on windows, for some reason, git provides a bash shell. https://gitforwindows.org/
  - Yes, I was thinking to maybe hook that into shell mode. The advantage of Eshell would be that I would not have to configure shell mode at all and just use the built in functionality of Emacs no matter what system I am on.
- Using buffers for input and output is such a killer feature
  - Do you mean in eshell or more generally in Emacs
  - both! But particularly in eshell
  - How do you use a buffer as input in eshell?
- That looks really cool!
- wow!
- I don't see an eshell/@ command, I think I missed something
  - lispmacs[work]: https://codeberg.org/infrared/emacsconf-2024/src/branch/main/shell-talk.el
- Oh, it's piping (buffer-string).  I think this should be (buffer-substring-no-properties (point-min) (point-max)) Otherwise you'll pipe propertized text causing issues with shell commands.  (Unless the eshell pipe somehow strips text properties, which I doubt.)
  - lispmacs[work]: oh okay, I wonder if the eshell pipe gets rid of that on its own
- There's also https://github.com/szermatt/emacsclient-commands which has an epipe utility
- Input redirection from buffers in eshell would be great -- actually, input redirection at all would be great.
  - isn't the "solution" to use cat input | ...?
    - What is input here?
- what's the use case of #\<buffer NAME\> or #\<NAME\> notation in eshell, as described at (info "(eshell) Arguments")?
  - It's useful for redirection.  run-foo > #\<buffer NAME\>
  - ah right, described at (info "(eshell) Pipelines")
- I just can’t get eshell to stick … I keep running back to vterm with my tail between my legs
  - eat fan here -- it doesn't require an additional external c library :D
  - mekeor: I need to try it out, I read on its README that vterm is faster but I'm not sure if I actually need that speed.
  - Eat seems to handle buffer resizes better
- lispmacs[work]: I think an important point is to just use Eshell where you find it useful - same with all the other Emacs tools. Of course, you should explore some of Eshell's Emacs/Elisp integration features
- The integrations with the rest of Emacs is probably what makes Eshell worth it once you get used to it. I am going to read up and try it out.
- Thanks
  - einar_m: Thank you! :-)
  - lounge-664: thanks chris good talk
  - chum-cha: This was fantastic, thanks lispmacs[work]!
  - mretka: M-x clap πŸ‘πŸ‘πŸ‘
  - dubs: Great talk
  - [14:32:57] * gs-101 claps
  - lispmacs[work]: thank you
  - johnhamelink: Thank you :)
  - jsiegel62: Thanks!
  - lispmacs[work]: πŸ™‡
  - karthik: Thank you
  - mraabo: Very nice, thank you!
  - lounge-267: ty, lispmacs.
  - [14:33:42] * inkpotmonkey πŸ™‡
  - oylenshpeegul: πŸ‘
  - ankit: Thank you, I've picked up a lot of things that I'll try to use in my workflow.
  - einar_m: Thank you for the inspiration, lismacs!

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

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