I had planned on giving a presentation to the Austin Emacs Meetup on my progress transitioning to Eshell. I tried to make one in both org-reveal and org-re-reveal, but every time I exported I just got a regular HTML file. Even though I did not have a formal presentation, I gave a few thoughts on using Eshell as my main shell before I left. This was originally part of the monthly write-up, but as that was already a long post, I separated them. I have written my notes here and expanded upon them.
For Eshell, so far all I have done is convert a few shell scripts that I use to back up files once a month. There are a couple of more complicated ones that are still in bash. I have not spent much time using it as my daily shell.
Based on the pages I have seen on the web, I think most people do not try to run scripts in Eshell and just use it interactively. I have a feeling I might be on the Emacs frontier on this point. One useful piece of information that is in the Mastering Emacs page about Eshell and not in the official documentation is that comments start with the pound sign, not the semicolon. I gave my scripts the “.el” extension, and I used the semicolon for comments, and I kept getting weird results. I could probably use the “.sh” extension, but I would like a way to keep them straight in and out of Emacs. Per section 2.10 of the manual, I used the “source” command to run them in Eshell:
source /home/ericm/path/to/scripts/some.eshell.file.el
I always have more terminal windows/tabs open than I have Emacs instances open, so I thought a complete replacement may not be possible. I thought you could only have one Eshell instance open in Emacs. You can have multiple instances open if you rename them. If you just try to start another Eshell instance, Emacs will not open a new Eshell instance. It will just go to the current one with the default name. You have to rename the Eshell buffer, either in the buffer list or with the rename-buffer command. You can do this by hand, but if you do that more than a few times, then you must be new here.
A few days ago I found via googling a Stack Overflow page with a few functions that make it easier to rename and have multiple Eshell instances open. A couple of the provided functions prompt for a string that they use for the buffer name, while another just increments them by number. I used the function provided by pajato0, which puts a dollar sign in front of the name. This keeps all the Emacs buffers at the top of my buffer list, since I like to arrange them alphabetically. I might change it to an asterisk since that keeps the color coding in the buffer list.
I wonder if there is a way to only load functions when you start Eshell buffer that are only to be used in Eshell, instead of loading them when you start Emacs and being available in all buffers. Per the Mastering Emacs article, I think these can be set with variables eshell-login-script and eshell-rc-script (which is another nugget not in the docs). I have not tried this yet.
I think in order to get the most use out of Eshell you need to be knowledgeable about Emacs Lisp, similar to the joke about regular expressions. Yet another thing to add to my TODO list.
If you want to use pure Eshell and really stay in Emacs all day, you need to keep in mind the options for the built-in Eshell commands. Some of the commands have fewer options in Eshell than the stock Linux commands. Calling a built-in command with an option it does not have will pass the command onto the host OS. On Linux mkdir has “–verbose”, while Eshell does not. In Eshell you get this message when you invoke command with “–help”:
This command is implemented in Lisp. If an unrecognized option is
passed to this command, the external version '/usr/bin/mkdir'
will be called instead.
This post was created in Emacs with Org Mode and Love. You’re welcome.
Image from the Larissa Gospels, a manuscript created in Thessaly Greece in the 13th or 14th century, housed at the University of Chicago Goodspeed Manuscript Collection, assumed allowed under public domain.