Major redesign of emacs/eshell
+ :sh can now be fed commands to run immediately, e.g. :sh cd %:P to start from the current project root. + Eshell will spawn a new eshell on every split. This can be controlled via `+eshell-enable-new-shell-on-split' + Eshell can be configured to kill the window when you kill the eshell process. This is disabled by default. See `+eshell-kill-window-on-exit'. Some commands ignore this, like the quit-and-close command (I alias this to "q"). + eshell-directory-name has been moved to doom-etc-dir/eshell. It will seem like eshell has forgotten all your history, but you can move ~/.eshell (or ~/.doom.d/eshell) to ~/.emacs.d/.local/etc/eshell and you'll be fine. + eshell-aliases-file has been moved to ~/.doom.d/eshell_aliases by default. + Automatic writing to eshell-aliases-file has been disabled. No shell so aggressively persists aliases. You may maintain it yourself, or use the new +eshell-aliases variable to customize eshell from Doom. + C-s now invokes a history search with ivy/helm. + C-c s and C-c v split horizontally and vertically. Inspired by tmux. + C-c x kill the current eshell and its window. Inspired by tmux.j + New set-eshell-alias! autodef for defining your own aliases. + +eshell/open-workspace has been replaced with +eshell/open-fullscreen. + Added the "cd-to-project" command. I suggest you alias it.
This commit is contained in:
parent
15921306ce
commit
7f79eb4579
6 changed files with 284 additions and 170 deletions
|
@ -6,11 +6,35 @@
|
|||
;; + `+eshell/open-workspace': open in separate tab (requires :feature
|
||||
;; workspaces)
|
||||
|
||||
(defvar eshell-directory-name
|
||||
(let ((dir (expand-file-name "eshell" doom-private-dir)))
|
||||
(if (file-directory-p dir)
|
||||
dir
|
||||
"~/.eshell")))
|
||||
(defvar eshell-directory-name (concat doom-etc-dir "eshell"))
|
||||
|
||||
(defvar eshell-aliases-file
|
||||
(expand-file-name "eshell_aliases" doom-private-dir)
|
||||
"The path to your eshell aliases file, where you may declare alises. This is
|
||||
here as an alternative to `set-eshell-alias!'.")
|
||||
|
||||
;;
|
||||
(defvar +eshell-enable-new-shell-on-split t
|
||||
"If non-nil, spawn a new eshell session after splitting from an eshell
|
||||
buffer.")
|
||||
|
||||
(defvar +eshell-kill-window-on-exit nil
|
||||
"If non-nil, eshell will close windows along with its eshell buffers.")
|
||||
|
||||
(defvar +eshell-aliases
|
||||
'(("q" "exit") ; built-in
|
||||
("z" "cd =$1") ; built-in
|
||||
("bd" "eshell-up $1") ; `eshell-up'
|
||||
("rg" "rg --color=always")
|
||||
("ag" "ag --color=always"))
|
||||
"An alist of default eshell aliases, meant to emulate useful shell utilities,
|
||||
like fasd and bd. Note that you may overwrite these in your
|
||||
`eshell-aliases-file'. This is here to provide an alternative, elisp-centric way
|
||||
to define your aliases.
|
||||
|
||||
You should use `det-eshell-alias!' to change this.")
|
||||
|
||||
(defvar +eshell--default-aliases nil)
|
||||
|
||||
|
||||
;;
|
||||
|
@ -31,7 +55,7 @@
|
|||
eshell-hist-ignoredups t
|
||||
;; em-prompt
|
||||
eshell-prompt-regexp "^.* λ "
|
||||
eshell-prompt-function #'+eshell-prompt
|
||||
eshell-prompt-function #'+eshell-default-prompt
|
||||
;; em-glob
|
||||
eshell-glob-case-insensitive t
|
||||
eshell-error-if-no-glob t)
|
||||
|
@ -39,6 +63,10 @@
|
|||
;; Consider eshell buffers real
|
||||
(add-hook 'eshell-mode-hook #'doom|mark-buffer-as-real)
|
||||
|
||||
;; Keep track of open eshell buffers
|
||||
(add-hook 'eshell-mode-hook #'+eshell|init)
|
||||
(add-hook 'eshell-exit-hook #'+eshell|cleanup)
|
||||
|
||||
;; UI enhancements
|
||||
(defun +eshell|replace-fringes-with-margins ()
|
||||
"Remove eshell's fringes and give it a margin of 1."
|
||||
|
@ -47,28 +75,25 @@
|
|||
(add-hook 'eshell-mode-hook #'+eshell|replace-fringes-with-margins)
|
||||
(add-hook 'eshell-mode-hook #'hide-mode-line-mode)
|
||||
|
||||
;; Keep track of open eshell buffers
|
||||
(add-hook 'eshell-mode-hook #'+eshell|init)
|
||||
(add-hook 'eshell-exit-hook #'+eshell|cleanup)
|
||||
|
||||
(after! em-alias
|
||||
;; Emulates popular shell utilities
|
||||
(map-put eshell-command-aliases-list "z" '("cd =$1"))
|
||||
(map-put eshell-command-aliases-list "bd" '("eshell-up $1")))
|
||||
;; Don't auto-write our aliases! Let us manage our own `eshell-aliases-file'
|
||||
;; or configure `+eshell-aliases' via elisp.
|
||||
(advice-add #'eshell-write-aliases-list :override #'ignore)
|
||||
|
||||
;; Visual commands require a proper terminal. Eshell can't handle that, so
|
||||
;; it delegates these commands to a term buffer.
|
||||
(after! em-term
|
||||
;; Visual commands require a proper terminal. Eshell can't handle that, so
|
||||
;; it delegates these commands to a term buffer.
|
||||
(dolist (cmd '("tmux" "htop" "bash" "zsh" "fish" "vim" "nvim" "ncmpcpp"))
|
||||
(cl-pushnew cmd eshell-visual-commands)))
|
||||
(add-to-list 'eshell-visual-commands cmd)))
|
||||
|
||||
(defun +eshell|init-evil ()
|
||||
"Replace `evil-collection-eshell-next-prompt-on-insert' with
|
||||
`+eshell|goto-prompt-on-insert'."
|
||||
(dolist (hook '(evil-replace-state-entry-hook evil-insert-state-entry-hook))
|
||||
(remove-hook hook 'evil-collection-eshell-next-prompt-on-insert t)
|
||||
(add-hook hook '+eshell|goto-prompt-on-insert nil t)))
|
||||
(add-hook 'eshell-mode-hook #'+eshell|init-evil)
|
||||
(defun +eshell|init-aliases ()
|
||||
(setq +eshell--default-aliases eshell-command-aliases-list
|
||||
eshell-command-aliases-list
|
||||
(append eshell-command-aliases-list
|
||||
+eshell-aliases)))
|
||||
(add-hook 'eshell-alias-load-hook #'+eshell|init-aliases)
|
||||
|
||||
(when (featurep! :feature evil +everywhere)
|
||||
(add-hook 'eshell-mode-hook #'+eshell|init-evil))
|
||||
|
||||
(defun +eshell|init-keymap ()
|
||||
"Setup eshell keybindings. This must be done in a hook because eshell-mode
|
||||
|
@ -90,6 +115,10 @@ redefines its keys every time `eshell-mode' is enabled."
|
|||
"\C-p" #'eshell-previous-input
|
||||
"\C-n" #'eshell-next-input))
|
||||
(define-key! eshell-mode-map
|
||||
(kbd "C-s") #'+eshell/search-history
|
||||
(kbd "C-c s") #'+eshell/split-below
|
||||
(kbd "C-c v") #'+eshell/split-right
|
||||
(kbd "C-c x") #'+eshell/kill-and-close
|
||||
[remap split-window-below] #'+eshell/split-below
|
||||
[remap split-window-right] #'+eshell/split-right
|
||||
[remap doom/backward-to-bol-or-indent] #'eshell-bol
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue