Last active
June 7, 2024 22:03
-
-
Save alexispurslane/93c35dcfc910088016e0603aec9b24e0 to your computer and use it in GitHub Desktop.
Switching from modern, blingful shells like Fish or Nushell to Eshell, and want an eshell config that will feel excellent, modern, and versitile? This is for you.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun user/eshell-layer () | |
"Make eshell feel like a hyper-modern, advanced, featureful | |
shell, like Fish or Nushell. Also make eshell output read-only | |
to avoid confusion. | |
Loads: | |
- `eshell-prompt-extras': three beautiful, useful modern prompt | |
themes, and better tools for building your own. | |
- `esh-autosuggest': automatically suggest (in grayed out text) | |
commands from your history based on your current command, which | |
you can accept with a right arrow, like Fish. | |
- `fish-completion': use Fish as your pcomplete backend, to give | |
LSP-like completions for your terminal (since corfu is enabled | |
in terminals by default in Quake Emacs already). | |
- `esh-help': documentation popups for eshell and shell commands | |
for a more IDE-like experience. | |
- `eshell-syntax-highlighting': Fish/Nushell-like syntax | |
highlighting for eshell, including recognizing whether a | |
command is found or not. | |
- `eat': a pure-elisp, no-external-dependencies fast, | |
full-featured vterm-class terminal emulator for Emacs that | |
embeds into Eshell to make Eshell able to deal with commands | |
that aren't dumb-terminal-compatible. (This removes the main | |
eshell pain-point)." | |
;;;; Configure base eshell | |
(use-package eshell | |
:commands (eshell eshell-mode) | |
:init | |
(add-to-list 'exec-path "/var/home/linuxbrew/.linuxbrew/bin") | |
(add-to-list 'exec-path "/var/home/linuxbrew/.linuxbrew/sbin") | |
;; Avoid VIM and LESS, use Emacs instead | |
(eshell/alias "vim" "find-file $1") | |
(eshell/alias "less" "view-file $1") | |
;; Make eshell/cat capable of cat'ing images and buffers as well as files. | |
(advice-add 'eshell/cat | |
:around (lambda (oldfun &rest args) | |
(mapconcat (lambda (arg) | |
(cond | |
((bufferp arg) (concat | |
(with-current-buffer arg (buffer-string)) | |
"\n")) | |
((string-match-p (image-file-name-regexp) arg) | |
(concat | |
(propertize "image" 'display (create-image arg)) | |
"\n")) | |
(t (apply oldfun args)))) | |
args))) | |
(setq eshell-banner-message | |
(concat | |
(propertize " | |
λλλ | |
λλλλλλλλ | |
λλλλλλλλλλλ | |
λλλ λλλλ | |
λλ λλλλ | |
λ λλλλ | |
λ λλλ | |
λλλ | |
λλλ | |
λλ | |
λλλ | |
λλλλ | |
λλλλλλ | |
λλλλλλλ | |
λλλλλλλλλ | |
λλλλλλλλλλ | |
λλλλλλ λλ | |
λλλλλλ λλλ | |
λλλλλλ λλ | |
λλλλλλ λλλ | |
λλλλλλ λλλ | |
λλλλλλ λλλ | |
λλλλλλ λλλ | |
λλλλλλ λλλ λ | |
λλλλλλ λλλλ λλ | |
λλλλλλ λλλλλ λλλ | |
λλλλλλ λλλλλλλλλλλ | |
λλλλλλλ λλλλλλλλλ | |
λλλ" | |
'face `(:foreground "#FEDD00")) | |
"\n\nWelcome to the Emacs shell\n\n")) | |
:config | |
;;;;; shell mode configuration | |
(defun eshell-interactive-output-readonly () | |
"Make output of interactive commands in eshell read-only. | |
This should be the last entry in eshell-output-filter-functions!" | |
(let ((end eshell-last-output-end)) | |
(save-excursion | |
(goto-char end) | |
(end-of-line 0) | |
(setq end (point))) | |
(when (< eshell-last-output-block-begin end) | |
(put-text-property eshell-last-output-block-begin end 'read-only "Read-only interactive eshell output")))) | |
(add-hook 'eshell-mode-hook (lambda () | |
(add-hook 'eshell-output-filter-functions 'eshell-interactive-output-readonly 'append))) | |
;;;;; extra commands | |
(defun eshell/clear () | |
"Clear the eshell buffer." | |
(interactive) | |
(let ((inhibit-read-only t)) | |
(erase-buffer)))) | |
;;;; extra packages | |
(use-package eshell-prompt-extras | |
:after (eshell) | |
:config | |
(setq eshell-highlight-prompt t | |
eshell-prompt-regexp "^[^λ]+ λ " | |
eshell-prompt-function 'epe-theme-dakrone)) | |
(use-package esh-autosuggest | |
:hook (eshell-mode . esh-autosuggest-mode)) | |
(use-package fish-completion | |
:after (eshell) | |
:config | |
(when (executable-find "fish") | |
(global-fish-completion-mode))) | |
(use-package esh-help | |
:after (eshell fish-completion) | |
:config | |
(setup-esh-help-eldoc)) | |
(use-package eshell-syntax-highlighting | |
:after (eshell) | |
:custom | |
(eshell-syntax-highlighting-highlight-in-remote-dirs t) | |
:config | |
(eshell-syntax-highlighting-global-mode)) | |
(use-package eat | |
:hook ((eshell-load . eat-eshell-mode)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment