summaryrefslogtreecommitdiff
path: root/.config/emacs/modules/bd--shells.el
blob: ae34bbeda81e3c493ee20ebc20e44265647b2483 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
;; -*- lexical-binding: t; -*-


(require 'all-the-icons)


;;;; term
(with-eval-after-load "term" (defalias 'term 'ansi-term))

;;;; eshell
(defun bd/get-prompt-path ()
  (abbreviate-file-name (eshell/pwd)))

(defun bd/eshell-prompt ()
  "Assemble a shell prompt including host, git
status, and path."
  (concat
   "\n"
   (propertize (system-name) 'face `(:foreground "#edb54b"))
   (format " %s " (all-the-icons-fileicon "gn"))
   (propertize (bd/get-prompt-path) 'face `(:foreground "#33859d"))
   (propertize (format-time-string " %a, %R") 'face `(:foreground "#888ba5"))
   (propertize "\n> " 'face `(:foreground "#c33027"))))


(require 'esh-mode)
(keymap-set eshell-mode-map "<tab>" 'completion-at-point)
(setopt eshell-prompt-function 'bd/eshell-prompt
        eshell-prompt-regexp "^> "
        eshell-scroll-to-bottom-on-input 'this
        eshell-banner-message (concat "\n" (propertize " " 'display (create-image (expand-file-name "~/.config/emacs/images/raven.png") 'png nil :scale 0.2 :align-to "center")) "\n"))


;;;; shell
(require 'shell)
(keymap-global-set "C-z C-e" (lambda ()
                               (interactive)
                               (let ((curr-buffer (current-buffer))
                                     (shell (shell)))
                                 (switch-to-buffer curr-buffer)
                                 (display-buffer (get-buffer shell))
                                 (switch-to-buffer-other-window shell))))
(keymap-set eshell-mode-map "C-q" 'delete-window) ; mostly for side window
(keymap-set shell-mode-map "C-c C-k" #'comint-clear-buffer)
(setopt shell-command-prompt-show-cwd t
        shell-highlight-undef-enable t
        shell-kill-buffer-on-exit t
        comint-prompt-read-only t)


(provide 'bd--shells)