Commit | Line | Data |
---|---|---|
4c05c418 AB |
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 | ||
c84be134 | 27 | (with-eval-after-load 'eshell |
0596e3cf | 28 | (make-directory (b/etc "eshell/") t) |
c84be134 | 29 | (csetq |
0596e3cf AB |
30 | eshell-aliases-file (b/etc "eshell/aliases") |
31 | eshell-directory-name (b/var "eshell/") | |
c84be134 AB |
32 | eshell-hist-ignoredups t |
33 | eshell-input-filter #'eshell-input-filter-initial-space | |
34 | eshell-prompt-regexp "\\(.*\n\\)*[$#] " | |
35 | eshell-prompt-function | |
36 | (lambda () | |
37 | (concat | |
38 | (propertize (format "%s@%s:" (user-login-name) (system-name)) | |
39 | 'face 'default) | |
40 | (propertize (abbreviate-file-name default-directory) | |
41 | 'face 'font-lock-comment-face) | |
42 | (propertize "\n" 'face 'default) | |
43 | (if (= (user-uid) 0) | |
44 | (propertize "#" 'face 'red) | |
45 | (propertize "$" 'face 'default)) | |
46 | (propertize " " 'face 'default)))) | |
3d7cc479 AB |
47 | (eval-when-compile |
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))) | |
679463c6 AB |
52 | (defun b/eshell-quit-or-delete-char (arg) |
53 | (interactive "p") | |
54 | (if (and (eolp) (looking-back eshell-prompt-regexp nil)) | |
55 | (eshell-life-is-too-much) | |
56 | (delete-char arg))) | |
679463c6 AB |
57 | (defun b/eshell-clear () |
58 | (interactive) | |
59 | (let ((inhibit-read-only t)) | |
60 | (erase-buffer)) | |
61 | (eshell-send-input)) | |
679463c6 AB |
62 | (defun b/eshell-setup () |
63 | (make-local-variable 'company-idle-delay) | |
64 | (defvar company-idle-delay) | |
3d7cc479 AB |
65 | (eval-when-compile |
66 | (defvar eshell-mode-map) | |
67 | (defvar eshell-hist-mode-map)) | |
679463c6 | 68 | (setq company-idle-delay nil) |
c84be134 AB |
69 | ;; local key bindings |
70 | (define-key eshell-mode-map (kbd "C-d") | |
71 | #'b/eshell-quit-or-delete-char) | |
72 | (define-key eshell-mode-map (kbd "C-S-l") | |
73 | #'b/eshell-clear) | |
74 | (define-key eshell-mode-map (kbd "M-r") | |
75 | #'counsel-esh-history) | |
76 | ;; (define-key eshell-mode-map [tab] | |
77 | ;; #'company-complete) | |
78 | (define-key eshell-hist-mode-map (kbd "M-r") | |
79 | #'counsel-esh-history))) | |
80 | ;; global key bindings | |
81 | (global-set-key (kbd "C-c a s e") #'eshell) | |
82 | ;; hooks | |
83 | (add-hook 'eshell-mode-hook #'b/eshell-setup) | |
679463c6 AB |
84 | |
85 | (provide 'bandali-eshell) | |
4c05c418 | 86 | ;;; bandali-eshell.el ends here |