1 ;;; bandali-eshell.el --- bandali's Eshell setup -*- lexical-binding: t; -*-
3 ;; Copyright (C) 2018-2020 Amin Bandali
5 ;; Author: Amin Bandali <bandali@gnu.org>
8 ;; This program is free software; you can redistribute it and/or modify
9 ;; it under the terms of the GNU General Public License as published by
10 ;; the Free Software Foundation, either version 3 of the License, or
11 ;; (at your option) any later version.
13 ;; This program is distributed in the hope that it will be useful,
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;; GNU General Public License for more details.
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with this program. If not, see <https://www.gnu.org/licenses/>.
23 ;; My awesome Eshell setup.
27 (with-eval-after-load 'eshell
29 eshell-hist-ignoredups t
30 eshell-input-filter
#'eshell-input-filter-initial-space
31 eshell-prompt-regexp
"\\(.*\n\\)*[$#] "
32 eshell-prompt-function
35 (propertize (format "%s@%s:" (user-login-name) (system-name))
37 (propertize (abbreviate-file-name default-directory
)
38 'face
'font-lock-comment-face
)
39 (propertize "\n" 'face
'default
)
41 (propertize "#" 'face
'red
)
42 (propertize "$" 'face
'default
))
43 (propertize " " 'face
'default
))))
45 (defvar eshell-prompt-regexp
)
46 (declare-function eshell-life-is-too-much
"esh-mode")
47 (declare-function eshell-send-input
"esh-mode"
48 (&optional use-region queue-p no-newline
)))
49 (defun b/eshell-quit-or-delete-char
(arg)
51 (if (and (eolp) (looking-back eshell-prompt-regexp nil
))
52 (eshell-life-is-too-much)
54 (defun b/eshell-clear
()
56 (let ((inhibit-read-only t
))
59 (defun b/eshell-setup
()
60 (make-local-variable 'company-idle-delay
)
61 (defvar company-idle-delay
)
63 (defvar eshell-mode-map
)
64 (defvar eshell-hist-mode-map
))
65 (setq company-idle-delay nil
)
67 (define-key eshell-mode-map
(kbd "C-d")
68 #'b
/eshell-quit-or-delete-char
)
69 (define-key eshell-mode-map
(kbd "C-S-l")
71 (define-key eshell-mode-map
(kbd "M-r")
72 #'counsel-esh-history
)
73 ;; (define-key eshell-mode-map [tab]
74 ;; #'company-complete)
75 (define-key eshell-hist-mode-map
(kbd "M-r")
76 #'counsel-esh-history
)))
77 ;; global key bindings
78 (global-set-key (kbd "C-c a s e") #'eshell
)
80 (add-hook 'eshell-mode-hook
#'b
/eshell-setup
)
82 (provide 'bandali-eshell
)
83 ;;; bandali-eshell.el ends here