Merge pull request #2986 from rushsteve1/eshell-improvements

Improved Eshell module part 1
This commit is contained in:
Henrik Lissner 2020-05-14 04:31:52 -04:00 committed by GitHub
commit 2bdc14710f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 85 additions and 6 deletions

View file

@ -10,7 +10,7 @@
company-tooltip-align-annotations t company-tooltip-align-annotations t
company-require-match 'never company-require-match 'never
company-global-modes company-global-modes
'(not erc-mode message-mode help-mode gud-mode eshell-mode) '(not erc-mode message-mode help-mode gud-mode)
company-frontends '(company-pseudo-tooltip-frontend company-frontends '(company-pseudo-tooltip-frontend
company-echo-metadata-frontend) company-echo-metadata-frontend)

View file

@ -0,0 +1,61 @@
#+TITLE: term/eshell
#+DATE: May 18, 2020
#+SINCE: v2.0
#+STARTUP: inlineimages nofold
* Table of Contents :TOC_3:noexport:
- [[#description][Description]]
- [[#maintainers][Maintainers]]
- [[#module-flags][Module Flags]]
- [[#plugins][Plugins]]
- [[#hacks][Hacks]]
- [[#prerequisites][Prerequisites]]
- [[#features][Features]]
- [[#configuration][Configuration]]
- [[#troubleshooting][Troubleshooting]]
* Description
This module provides additional features for the built-in [[https://www.gnu.org/software/emacs/manual/html_mono/eshell.html][Emacs Shell]]
The Emacs Shell or =eshell= is a shell-like command interpreter implemented in
Emacs Lisp. It is an alternative to traditional shells such as =bash=, =zsh=,
=fish=, etc. that is built into Emacs and entirely cross-platform.
** Maintainers
This module has no dedicated maintainers.
** Module Flags
This module provides no flags, but does gain auto-completion if =:completion
company= is enabled.
** Plugins
+ [[https://github.com/peterwvj/eshell-up][eshell-up]]
+ [[https://github.com/xuchunyang/eshell-z][eshell-z]]
+ [[https://github.com/tom-tan/esh-help][esh-help]]
+ [[https://gitlab.com/bennya/shrink-path.el][shrink-path]]
+ [[https://github.com/xuchunyang/eshell-did-you-mean][eshell-did-you-mean]]
+ =:completion company=
+ [[https://gitlab.com/ambrevar/emacs-fish-completion][fish-completion]]
+ [[https://github.com/szermatt/emacs-bash-completion][bash-completion]]
** Hacks
+ Even with =fish-completion-fallback-on-bash-p= non-nil, fish must be installed
for bash completion to work. Workaround in =config.el=.
+ =eshell-did-you-mean= does not work on first invocation, so we manually invoke
it once.
* Prerequisites
[[https://fishshell.com/][=fish= shell]] for completions, falling back to [[https://www.gnu.org/software/bash/][=bash= shell]] if =fish= is not
found. If neither shell is found, completions may not be available.
* Features
+ Command completion with Company
+ =fish=-style prompt with Git integration
+ [[https://github.com/rupa/z][=z=]]-like directory jumping
+ Command-not-found recommendations
* TODO Configuration
# How to configure this module, including common problems and how to address them.
* TODO Troubleshooting
# Common issues and their solution, or places to look for help.

View file

@ -12,6 +12,10 @@
"Where to store eshell configuration files, as opposed to "Where to store eshell configuration files, as opposed to
`eshell-directory-name', which is where Doom will store temporary/data files.") `eshell-directory-name', which is where Doom will store temporary/data files.")
(defvar eshell-directory-name (concat doom-etc-dir "eshell")
"Where to store temporary/data files, as opposed to `eshell-config-dir',
which is where Doom will store eshell configuration files.")
(defvar +eshell-enable-new-shell-on-split t (defvar +eshell-enable-new-shell-on-split t
"If non-nil, spawn a new eshell session after splitting from an eshell "If non-nil, spawn a new eshell session after splitting from an eshell
buffer.") buffer.")
@ -22,11 +26,13 @@ buffer.")
(defvar +eshell-aliases (defvar +eshell-aliases
'(("q" "exit") ; built-in '(("q" "exit") ; built-in
("f" "find-file $1") ("f" "find-file $1")
("ff" "find-file $1")
("d" "dired $1") ("d" "dired $1")
("bd" "eshell-up $1") ("bd" "eshell-up $1")
("rg" "rg --color=always $*") ("rg" "rg --color=always $*")
("l" "ls -lh $*") ("l" "ls -lh $*")
("ll" "ls -lah $*") ("ll" "ls -lah $*")
("gg" "magit-status")
("clear" "clear-scrollback")) ; more sensible than default ("clear" "clear-scrollback")) ; more sensible than default
"An alist of default eshell aliases, meant to emulate useful shell utilities, "An alist of default eshell aliases, meant to emulate useful shell utilities,
like fasd and bd. Note that you may overwrite these in your like fasd and bd. Note that you may overwrite these in your
@ -35,15 +41,11 @@ to define your aliases.
You should use `set-eshell-alias!' to change this.") You should use `set-eshell-alias!' to change this.")
;;
(defvar eshell-directory-name (concat doom-etc-dir "eshell"))
;; These files are exceptions, because they may contain configuration ;; These files are exceptions, because they may contain configuration
(defvar eshell-aliases-file (concat +eshell-config-dir "aliases")) (defvar eshell-aliases-file (concat +eshell-config-dir "aliases"))
(defvar eshell-rc-script (concat +eshell-config-dir "profile")) (defvar eshell-rc-script (concat +eshell-config-dir "profile"))
(defvar eshell-login-script (concat +eshell-config-dir "login")) (defvar eshell-login-script (concat +eshell-config-dir "login"))
(defvar +eshell--default-aliases nil) (defvar +eshell--default-aliases nil)
@ -152,7 +154,11 @@ You should use `set-eshell-alias!' to change this.")
[remap doom/backward-kill-to-bol-and-indent] #'eshell-kill-input [remap doom/backward-kill-to-bol-and-indent] #'eshell-kill-input
[remap evil-delete-back-to-indentation] #'eshell-kill-input [remap evil-delete-back-to-indentation] #'eshell-kill-input
[remap evil-window-split] #'+eshell/split-below [remap evil-window-split] #'+eshell/split-below
[remap evil-window-vsplit] #'+eshell/split-right)))) [remap evil-window-vsplit] #'+eshell/split-right
(:localleader
"b" #'eshell-insert-buffer-name
"e" #'eshell-insert-envvar
"s" #'+eshell/search-history)))))
(use-package! eshell-up (use-package! eshell-up
@ -183,3 +189,14 @@ You should use `set-eshell-alias!' to change this.")
(defadvice! +eshell--fallback-to-bash-a (&rest _) (defadvice! +eshell--fallback-to-bash-a (&rest _)
:before-until #'fish-completion--list-completions-with-desc :before-until #'fish-completion--list-completions-with-desc
(unless (executable-find "fish") ""))) (unless (executable-find "fish") "")))
;; Activate eshell-did-you-mean using its setup function (lazily)
(use-package! eshell-did-you-mean
:after esh-mode ; Specifically esh-mode, not eshell
:config
(eshell-did-you-mean-setup)
;; HACK There is a known issue with `eshell-did-you-mean' where it does not
;; work on first invocation, so we invoke it once manually by setting
;; the last command and then calling the output filter.
(setq eshell-last-command-name "catt")
(eshell-did-you-mean-output-filter "catt: command not found"))

View file

@ -5,6 +5,7 @@
(package! eshell-z :pin "337cb241e17bd472bd3677ff166a0800f684213c") (package! eshell-z :pin "337cb241e17bd472bd3677ff166a0800f684213c")
(package! shrink-path :pin "c14882c8599aec79a6e8ef2d06454254bb3e1e41") (package! shrink-path :pin "c14882c8599aec79a6e8ef2d06454254bb3e1e41")
(package! esh-help :pin "417673ed18a983930a66a6692dbfb288a995cb80") (package! esh-help :pin "417673ed18a983930a66a6692dbfb288a995cb80")
(package! eshell-did-you-mean :pin "7cb6ef8e2274d0a50a9e114d412307a6543533d5")
(when (featurep! :completion company) (when (featurep! :completion company)
(package! fish-completion :pin "10384881817b5ae38cf6197a077a663420090d2c") (package! fish-completion :pin "10384881817b5ae38cf6197a077a663420090d2c")