2018-05-27 12:05:15 +02:00
|
|
|
;;; emacs/eshell/config.el -*- lexical-binding: t; -*-
|
2017-02-19 18:53:38 -05:00
|
|
|
|
|
|
|
;; see:
|
2017-09-27 12:42:24 +02:00
|
|
|
;; + `+eshell/open': open in current buffer
|
|
|
|
;; + `+eshell/open-popup': open in a popup
|
2018-01-15 00:43:17 -05:00
|
|
|
;; + `+eshell/open-workspace': open in separate tab (requires :feature
|
|
|
|
;; workspaces)
|
2017-02-19 18:53:38 -05:00
|
|
|
|
2018-06-14 23:36:42 +02:00
|
|
|
(defvar eshell-directory-name
|
|
|
|
(let ((dir (expand-file-name "eshell" doom-private-dir)))
|
|
|
|
(if (file-directory-p dir)
|
|
|
|
dir
|
|
|
|
"~/.eshell")))
|
|
|
|
|
|
|
|
|
|
|
|
;;
|
|
|
|
;; Plugins
|
|
|
|
;;
|
|
|
|
|
|
|
|
(after! eshell ; built-in
|
2018-06-16 16:59:33 +02:00
|
|
|
(setq eshell-banner-message
|
|
|
|
'(format "%s %s\n"
|
|
|
|
(propertize (format " %s " (string-trim (buffer-name)))
|
|
|
|
'face 'mode-line-highlight)
|
|
|
|
(propertize (current-time-string)
|
|
|
|
'face 'font-lock-keyword-face))
|
|
|
|
eshell-scroll-to-bottom-on-input 'all
|
2017-02-19 18:53:38 -05:00
|
|
|
eshell-scroll-to-bottom-on-output 'all
|
|
|
|
eshell-buffer-shorthand t
|
2017-05-12 12:10:04 +02:00
|
|
|
eshell-kill-processes-on-exit t
|
2018-03-23 18:17:59 -04:00
|
|
|
eshell-hist-ignoredups t
|
2017-02-19 18:53:38 -05:00
|
|
|
;; em-prompt
|
2017-07-21 16:48:34 +02:00
|
|
|
eshell-prompt-regexp "^.* λ "
|
2017-09-27 12:42:24 +02:00
|
|
|
eshell-prompt-function #'+eshell-prompt
|
2017-02-19 18:53:38 -05:00
|
|
|
;; em-glob
|
|
|
|
eshell-glob-case-insensitive t
|
2018-03-23 18:17:59 -04:00
|
|
|
eshell-error-if-no-glob t)
|
2017-02-19 18:53:38 -05:00
|
|
|
|
2018-05-18 01:26:00 +02:00
|
|
|
;; Consider eshell buffers real
|
2018-06-04 21:06:57 +02:00
|
|
|
(add-hook 'eshell-mode-hook #'doom|mark-buffer-as-real)
|
2018-05-18 01:26:00 +02:00
|
|
|
|
2018-06-16 16:39:48 +02:00
|
|
|
;; UI enhancements
|
|
|
|
(defun +eshell|replace-fringes-with-margins ()
|
|
|
|
"Remove eshell's fringes and give it a margin of 1."
|
|
|
|
(set-window-fringes nil 0 0)
|
|
|
|
(set-window-margins nil 1 1))
|
|
|
|
(add-hook 'eshell-mode-hook #'+eshell|replace-fringes-with-margins)
|
|
|
|
(add-hook 'eshell-mode-hook #'hide-mode-line-mode)
|
|
|
|
|
2017-09-27 12:42:24 +02:00
|
|
|
;; Keep track of open eshell buffers
|
|
|
|
(add-hook 'eshell-mode-hook #'+eshell|init)
|
|
|
|
(add-hook 'eshell-exit-hook #'+eshell|cleanup)
|
|
|
|
|
2018-06-16 16:38:39 +02:00
|
|
|
(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")))
|
|
|
|
|
2017-05-12 12:07:28 +02:00
|
|
|
(after! em-term
|
2018-05-15 01:33:21 +02:00
|
|
|
;; Visual commands require a proper terminal. Eshell can't handle that, so
|
|
|
|
;; it delegates these commands to a term buffer.
|
2018-06-16 16:42:26 +02:00
|
|
|
(dolist (cmd '("tmux" "htop" "bash" "zsh" "fish" "vim" "nvim" "ncmpcpp"))
|
|
|
|
(cl-pushnew cmd eshell-visual-commands)))
|
2017-05-10 05:29:56 +02:00
|
|
|
|
2018-05-26 18:58:00 +02:00
|
|
|
(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)
|
|
|
|
|
2017-09-27 12:42:24 +02:00
|
|
|
(defun +eshell|init-keymap ()
|
|
|
|
"Setup eshell keybindings. This must be done in a hook because eshell-mode
|
2017-02-19 18:53:38 -05:00
|
|
|
redefines its keys every time `eshell-mode' is enabled."
|
2018-06-03 15:46:00 +02:00
|
|
|
(when (featurep 'evil)
|
|
|
|
(evil-define-key* 'normal eshell-mode-map
|
|
|
|
[return] #'+eshell/goto-end-of-prompt
|
|
|
|
"c" #'+eshell/evil-change
|
|
|
|
"C" #'+eshell/evil-change-line
|
|
|
|
"d" #'+eshell/evil-delete
|
|
|
|
"D" #'+eshell/evil-delete-line)
|
|
|
|
(evil-define-key* 'insert eshell-mode-map
|
2018-06-16 16:37:43 +02:00
|
|
|
[tab] #'+eshell/pcomplete
|
2018-06-16 21:08:08 +02:00
|
|
|
"\C-j" #'evil-window-down
|
|
|
|
"\C-k" #'evil-window-up
|
|
|
|
"\C-h" #'evil-window-left
|
|
|
|
"\C-l" #'evil-window-right
|
2018-06-03 15:46:00 +02:00
|
|
|
"\C-d" #'+eshell/quit-or-delete-char
|
|
|
|
"\C-p" #'eshell-previous-input
|
|
|
|
"\C-n" #'eshell-next-input))
|
|
|
|
(define-key! eshell-mode-map
|
|
|
|
[remap split-window-below] #'+eshell/split-below
|
|
|
|
[remap split-window-right] #'+eshell/split-right
|
|
|
|
[remap doom/backward-to-bol-or-indent] #'eshell-bol
|
|
|
|
[remap doom/backward-kill-to-bol-and-indent] #'eshell-kill-input
|
|
|
|
[remap evil-window-split] #'+eshell/split-below
|
|
|
|
[remap evil-window-vsplit] #'+eshell/split-right))
|
2018-03-23 18:17:59 -04:00
|
|
|
(add-hook 'eshell-first-time-mode-hook #'+eshell|init-keymap))
|
2017-02-19 18:53:38 -05:00
|
|
|
|
2018-06-16 16:38:39 +02:00
|
|
|
|
|
|
|
(def-package! eshell-up
|
|
|
|
:commands (eshell-up eshell-up-peek))
|
2018-06-16 16:51:43 +02:00
|
|
|
|
|
|
|
|
|
|
|
(def-package! shrink-path
|
|
|
|
:commands shrink-path-file)
|