2016-05-26 18:51:39 -04:00
|
|
|
;;; module-eshell.el --- -*- no-byte-compile: t; -*-
|
2015-06-15 09:06:10 +02:00
|
|
|
|
2017-01-07 23:26:48 -05:00
|
|
|
;; see:
|
|
|
|
;; + `doom:eshell' (open in current buffer or popup)
|
|
|
|
;; + `doom/eshell-tab' (open in separate tab)
|
|
|
|
;; + `doom/eshell-frame' (open in separate frame)
|
|
|
|
|
2015-06-15 09:06:10 +02:00
|
|
|
(use-package eshell
|
|
|
|
:init
|
2016-05-20 22:37:30 -04:00
|
|
|
(setq eshell-directory-name (concat doom-temp-dir "/eshell")
|
2015-06-15 09:06:10 +02:00
|
|
|
eshell-scroll-to-bottom-on-input 'all
|
2016-06-05 23:09:25 -04:00
|
|
|
eshell-scroll-to-bottom-on-output 'all
|
2015-06-15 09:06:10 +02:00
|
|
|
eshell-buffer-shorthand t
|
2016-06-05 23:09:25 -04:00
|
|
|
;; em-prompt
|
|
|
|
eshell-prompt-function 'doom/eshell-prompt
|
2015-06-15 09:06:10 +02:00
|
|
|
;; em-glob
|
|
|
|
eshell-glob-case-insensitive t
|
|
|
|
eshell-error-if-no-glob t
|
|
|
|
;; em-alias
|
2016-05-20 22:37:30 -04:00
|
|
|
eshell-aliases-file (concat doom-temp-dir "/.eshell-aliases"))
|
2015-06-15 09:06:10 +02:00
|
|
|
|
2016-05-24 21:57:25 -04:00
|
|
|
:config
|
2016-06-05 23:09:25 -04:00
|
|
|
(evil-set-initial-state 'eshell-mode 'insert)
|
2017-01-07 23:26:48 -05:00
|
|
|
(def-popup! "^\\*eshell:popup\\*$" :regexp t :align below :size 25 :select t)
|
2016-06-05 23:09:25 -04:00
|
|
|
|
|
|
|
(defun doom|eshell-keymap-setup ()
|
2017-01-07 23:26:48 -05:00
|
|
|
"Setup eshell keybindings. This must be done in a hook because eshell
|
|
|
|
redefines its keys every time `eshell-mode' is enabled."
|
2016-06-05 23:09:25 -04:00
|
|
|
(map! :map eshell-mode-map
|
|
|
|
:n "i" 'doom/eshell-evil-prepend-maybe
|
|
|
|
:n "I" 'doom/eshell-evil-prepend
|
|
|
|
:n "a" 'doom/eshell-evil-append-maybe
|
|
|
|
:n "A" 'doom/eshell-evil-append
|
|
|
|
:n "r" 'doom/eshell-evil-replace-maybe
|
|
|
|
:n "R" 'doom/eshell-evil-replace-state-maybe
|
2017-01-07 23:26:48 -05:00
|
|
|
:n "c" 'doom/eshell-evil-change
|
|
|
|
:n "C" 'doom/eshell-evil-change-line
|
|
|
|
:i "<tab>" 'eshell-pcomplete
|
2016-06-05 23:09:25 -04:00
|
|
|
:i "C-u" 'eshell-kill-input
|
|
|
|
:i "SPC" 'self-insert-command
|
|
|
|
:m "<return>" 'doom/eshell-evil-append
|
2017-01-07 23:26:48 -05:00
|
|
|
: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))
|
2016-06-05 23:09:25 -04:00
|
|
|
|
|
|
|
;; Close window on exit
|
|
|
|
(add-hook 'eshell-exit-hook 'doom|eshell-cleanup)
|
|
|
|
(add-hook 'eshell-mode-hook 'doom|eshell-init)
|
|
|
|
|
|
|
|
(add-hook 'eshell-mode-hook 'doom|eshell-keymap-setup)
|
|
|
|
(add-hook 'eshell-mode-hook 'doom-hide-mode-line-mode)
|
2017-01-07 23:26:48 -05:00
|
|
|
|
|
|
|
(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)))))
|
2015-06-15 09:06:10 +02:00
|
|
|
|
|
|
|
(provide 'module-eshell)
|
|
|
|
;;; module-eshell.el ends here
|