CHANGE 9 drones
[~bandali/configs] / lisp / bandali-eshell.el
... / ...
CommitLineData
1;;; bandali-eshell.el --- bandali's Eshell setup -*- lexical-binding: t; -*-
2
3;; Copyright (C) 2018-2020 Amin Bandali
4
5;; Author: Amin Bandali <bandali@gnu.org>
6;; Keywords: processes
7
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.
12
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.
17
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/>.
20
21;;; Commentary:
22
23;; My awesome Eshell setup.
24
25;;; Code:
26
27(use-package eshell
28 :commands eshell
29 :bind ("C-c a s e" . eshell)
30 :config
31 (eval-when-compile
32 (defvar eshell-prompt-regexp)
33 (declare-function eshell-life-is-too-much "esh-mode")
34 (declare-function eshell-send-input "esh-mode"
35 (&optional use-region queue-p no-newline)))
36 (defun b/eshell-quit-or-delete-char (arg)
37 (interactive "p")
38 (if (and (eolp) (looking-back eshell-prompt-regexp nil))
39 (eshell-life-is-too-much)
40 (delete-char arg)))
41
42 (defun b/eshell-clear ()
43 (interactive)
44 (let ((inhibit-read-only t))
45 (erase-buffer))
46 (eshell-send-input))
47
48 (defun b/eshell-setup ()
49 (make-local-variable 'company-idle-delay)
50 (defvar company-idle-delay)
51 (eval-when-compile
52 (defvar eshell-mode-map)
53 (defvar eshell-hist-mode-map))
54 (setq company-idle-delay nil)
55 (bind-keys :map eshell-mode-map
56 ("C-d" . b/eshell-quit-or-delete-char)
57 ("C-S-l" . b/eshell-clear)
58 ("M-r" . counsel-esh-history)
59 ;; ([tab] . company-complete)
60 :map eshell-hist-mode-map
61 ("M-r" . counsel-esh-history)))
62
63 (setq
64 eshell-prompt-regexp "\\(.*\n\\)*[$#] "
65 eshell-prompt-function
66 (lambda ()
67 (concat
68 (propertize (format "%s@%s:" (user-login-name) (system-name))
69 'face 'default)
70 (propertize (abbreviate-file-name default-directory)
71 'face 'font-lock-comment-face)
72 (propertize "\n" 'face 'default)
73 (if (= (user-uid) 0)
74 (propertize "#" 'face 'red)
75 (propertize "$" 'face 'default))
76 (propertize " " 'face 'default))))
77
78 :hook (eshell-mode . b/eshell-setup)
79 :custom
80 (eshell-hist-ignoredups t)
81 (eshell-input-filter 'eshell-input-filter-initial-space))
82
83(provide 'bandali-eshell)
84;;; bandali-eshell.el ends here