1 ;;; bandali-eshell.el --- bandali's Eshell setup -*- lexical-binding: t; -*-
3 ;; Copyright (C) 2018-2022 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
28 (make-directory (b/etc
"eshell/") t
)
30 eshell-aliases-file
(b/etc
"eshell/aliases")
31 eshell-directory-name
(b/var
"eshell/")
32 eshell-hist-ignoredups t
33 eshell-input-filter
#'eshell-input-filter-initial-space
34 eshell-prompt-regexp
"\\(.*\n\\)*[$#] "
35 eshell-prompt-function
38 (propertize (format "%s@%s:" (user-login-name) (system-name))
40 (propertize (abbreviate-file-name default-directory
)
41 'face
'font-lock-comment-face
)
42 (propertize "\n" 'face
'default
)
44 (propertize "#" 'face
'red
)
45 (propertize "$" 'face
'default
))
46 (propertize " " 'face
'default
))))
48 (defvar eshell-prompt-regexp
)
49 (declare-function eshell-life-is-too-much
"esh-mode")
50 (declare-function eshell-send-input
"esh-mode"
51 (&optional use-region queue-p no-newline
)))
52 (defun b/eshell-quit-or-delete-char
(arg)
54 (if (and (eolp) (looking-back eshell-prompt-regexp nil
))
55 (eshell-life-is-too-much)
57 (defun b/eshell-clear
()
59 (let ((inhibit-read-only t
))
62 (defun b/eshell-history
()
64 (completing-read "Eshell history: "
65 (ring-elements eshell-history-ring
)))
66 (defun b/eshell-setup
()
67 (make-local-variable 'company-idle-delay
)
68 (defvar company-idle-delay
)
70 (defvar eshell-mode-map
)
71 (defvar eshell-hist-mode-map
))
72 (setq company-idle-delay nil
)
74 (define-key eshell-mode-map
(kbd "C-d")
75 #'b
/eshell-quit-or-delete-char
)
76 (define-key eshell-mode-map
(kbd "C-S-l")
78 (define-key eshell-hist-mode-map
(kbd "M-r")
80 ;; global key bindings
81 (global-set-key (kbd "C-c a s e") #'eshell
)
83 (add-hook 'eshell-mode-hook
#'b
/eshell-setup
)
85 (provide 'bandali-eshell
)
86 ;;; bandali-eshell.el ends here