Rewrite eshell config

This commit is contained in:
Henrik Lissner 2017-01-07 23:26:48 -05:00
parent 2672d4b4cd
commit 9c2e59e231
4 changed files with 105 additions and 44 deletions

View file

@ -1,5 +1,10 @@
;;; module-eshell.el --- -*- no-byte-compile: t; -*-
;; see:
;; + `doom:eshell' (open in current buffer or popup)
;; + `doom/eshell-tab' (open in separate tab)
;; + `doom/eshell-frame' (open in separate frame)
(use-package eshell
:init
(setq eshell-directory-name (concat doom-temp-dir "/eshell")
@ -16,8 +21,11 @@
:config
(evil-set-initial-state 'eshell-mode 'insert)
(def-popup! "^\\*eshell:popup\\*$" :regexp t :align below :size 25 :select t)
(defun doom|eshell-keymap-setup ()
"Setup eshell keybindings. This must be done in a hook because eshell
redefines its keys every time `eshell-mode' is enabled."
(map! :map eshell-mode-map
:n "i" 'doom/eshell-evil-prepend-maybe
:n "I" 'doom/eshell-evil-prepend
@ -25,20 +33,16 @@
:n "A" 'doom/eshell-evil-append
:n "r" 'doom/eshell-evil-replace-maybe
:n "R" 'doom/eshell-evil-replace-state-maybe
:n "c" 'doom/eshell-evil-change
:n "C" 'doom/eshell-evil-change-line
:i "<tab>" 'eshell-pcomplete
:i "C-u" 'eshell-kill-input
:i "SPC" 'self-insert-command
:m "<return>" 'doom/eshell-evil-append
:n [remap doom/evil-window-split] 'doom/eshell-split
:n [remap doom/evil-window-vsplit] 'doom/eshell-vsplit))
(defun doom|eshell-init ()
(when (eq major-mode 'eshell-mode)
(add-to-list 'doom-eshell-buffers (current-buffer))))
(defun doom|eshell-cleanup ()
(when (eq major-mode 'eshell-mode)
(setq doom-eshell-buffers (delete (current-buffer) doom-eshell-buffers))
(delete-window)))
:n [remap evil-window-split] 'doom/eshell-split
:n [remap evil-window-vsplit] 'doom/eshell-vsplit
:n [remap evil-record-macro] 'eshell-life-is-too-much
[remap doom/close-window-or-tab] 'eshell-life-is-too-much))
;; Close window on exit
(add-hook 'eshell-exit-hook 'doom|eshell-cleanup)
@ -46,7 +50,28 @@
(add-hook 'eshell-mode-hook 'doom|eshell-keymap-setup)
(add-hook 'eshell-mode-hook 'doom-hide-mode-line-mode)
(add-hook 'eshell-mode-hook 'hl-line-mode))
(add-hook! eshell-mode
(add-hook 'evil-insert-state-exit-hook 'hl-line-mode nil t)
(add-hook 'evil-insert-state-entry-hook (lambda () (hl-line-mode -1)) nil t))
;; Aliases
(setq eshell-command-aliases-list
'(("q" "exit")
("l" "ls -1")
("ll" "ls -l")
("la" "ls -la")
("g" "hub")
("gs" "hub status --oneline .")
("gss" "hub status --oneline")))
;; Custom commands
(defun eshell/e (file)
(eshell-eval (cond ((doom/popup-p)
(doom/popup-save (find-file file))
0)
(t (find-file file)
0)))))
(provide 'module-eshell)
;;; module-eshell.el ends here