Eshell Configuration

Another video from Emacs Elements. This time it’s about Eshell configuration. I love Eshell and use it all the time. It’s mostly like a standard Unix shell but there are some surprises. The major surprise, of course, is that you can’t create pipelines the way you can in, say, Bash or Zshell. But there are some other gotchas. One of them is setting aliases.

It’s really easy to set an alias with Eshell—arguably easier than in any of the Unix shells—but it is different so it’s nice that the video discusses how to set and use them. Best of all, they’re stored in a plain text file that you can edit by hand if you’re inclined.

One of the other things the video mentions is some Elisp to provide a clear command for Eshell. You can type clear and it will blank the screen but the cursor is left in the wrong place and you can scroll backward to all the text you thought you were clearing. I combined that code with alias to make a real clear command. I modified the code a bit to

(defun eshell-clear-buffer ()
  "Clear the current Eshell buffer."
  (interactive)
  (let ((inhibit-read-only t))
    (erase-buffer)
    (eshell-send-input)))

and then set an alias to clear with

alias clear '(eshell-clear-buffer)

That solves a longstanding problem with my Eshell use so I was happy to discover it.

The video covers a few other subjects as well. You’ll learn how to set up Eshell to imitate Plan 9’s shell behavior, how to open files in Eshell, and where Eshell hides all your settings.

Finally, he strongly recommends Mickey’s article Mastering Eshell to learn everything you need to know about Eshell to use it effectively.

UPDATE [2023-08-14 Mon 16:15]: shell-send-inputeshell-send-input

This entry was posted in General and tagged . Bookmark the permalink.