summary refs log tree commit diff stats
path: root/lisp/acdw-shell.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/acdw-shell.el')
-rw-r--r--lisp/acdw-shell.el141
1 files changed, 0 insertions, 141 deletions
diff --git a/lisp/acdw-shell.el b/lisp/acdw-shell.el deleted file mode 100644 index ce63bdc..0000000 --- a/lisp/acdw-shell.el +++ /dev/null
@@ -1,141 +0,0 @@
1;;; acdw-shell.el ---Shell config -*- lexical-binding: t; -*-
2
3;;; Code:
4
5(defvar eshell-buffer-format "*eshell:%s*"
6 "Format for eshell buffer names.")
7
8(defun eshell-rename-pwd ()
9 (rename-buffer (format eshell-buffer-format default-directory) t))
10
11(defun eshell-last-dir ()
12 (goto-char (point-max))
13 (insert "cd -")
14 (eshell-send-input))
15
16(defun eshellp (buffer-or-name)
17 (with-current-buffer buffer-or-name
18 (derived-mode-p 'eshell-mode)))
19
20(defun +eshell (&optional new)
21 (interactive "P")
22 (let ((dir default-directory)
23 (bname (format eshell-buffer-format default-directory))
24 (display-comint-buffer-action 'pop-to-buffer))
25 (if-let ((buf (and (not new)
26 (or (get-buffer bname)
27 (seq-find #'eshellp
28 (reverse (buffer-list)))))))
29 (pop-to-buffer buf)
30 (eshell new))
31 (eshell-rename-pwd)
32 (unless (equal default-directory dir)
33 (eshell/cd dir)
34 (eshell-send-input)
35 (goto-char (point-max)))))
36
37(defun +eshell-quit (&optional choose)
38 (interactive "P")
39 (if choose
40 (let* ((bufs (mapcar #'buffer-name
41 (seq-filter #'eshellp
42 (buffer-list))))
43 (buf (get-buffer
44 (completing-read "Eshell: "
45 bufs nil t nil nil (car bufs)))))
46 (quit-window)
47 (pop-to-buffer buf))
48 (quit-window)))
49
50(defun acdw/eshell-prompt ()
51 "My custom eshell prompt."
52 (concat (if (= 0 eshell-last-command-status)
53 "^_^ "
54 ";_; ")
55 (abbreviate-file-name (eshell/pwd))
56 (if (= (user-uid) 0) " # " " $ ")))
57
58
59;;; Packages
60
61(use-package eshell
62 :init
63 (add-hook 'eshell-post-command-hook #'eshell-rename-pwd)
64 (setopt eshell-modules-list
65 '(eshell-alias
66 eshell-basic
67 eshell-cmpl
68 eshell-dirs
69 eshell-elecslash
70 eshell-hist
71 eshell-ls
72 eshell-prompt
73 eshell-smart
74 eshell-extpipe
75 eshell-glob
76 eshell-hist
77 eshell-ls
78 eshell-pred
79 eshell-prompt
80 eshell-script
81 eshell-term
82 eshell-unix))
83 :commands eshell
84 :bind (("C-z" . +eshell)
85 :map eshell-mode-map
86 ("C-z" . +eshell-quit)
87 ("C-o" . eshell-last-dir))
88 :config
89 (require 'esh-module)
90 (require 'em-smart)
91 (require 'em-tramp)
92 (setq eshell-destroy-buffer-when-process-dies t
93 eshell-error-if-no-glob t
94 eshell-hist-ignoredups t
95 eshell-kill-on-exit t
96 eshell-prefer-lisp-functions t
97 eshell-prefer-lisp-variables t
98 eshell-scroll-to-bottom-on-input 'this
99 eshell-banner-message ""
100 eshell-hist-ignoredups 'erase
101 eshell-history-size 512
102 eshell-input-filter (lambda (input)
103 (or (eshell-input-filter-default input)
104 (eshell-input-filter-initial-space input)))
105 eshell-prompt-function #'acdw/eshell-prompt)
106 (add-hook 'eshell-mode-hook
107 (defun eshell-setup ()
108 (hungry-delete-mode -1)
109 (setq-local outline-regexp eshell-prompt-regexp
110 page-delimiter eshell-prompt-regexp
111 imenu-generic-expression
112 '(("Prompt" " $ \\(.*\\)" 1))
113 truncate-lines t)
114 (setenv "PAGER" "cat"))))
115
116(use-package eat
117 :ensure t
118 :hook (eshell-load-hook . eat-eshell-mode))
119
120(use-package exec-path-from-shell
121 :when (eq system-type 'gnu/linux)
122 :ensure t
123 :config
124 (add-to-list 'exec-path-from-shell-variables "SSH_AUTH_SOCK")
125 (add-to-list 'exec-path-from-shell-variables "SSH_AGENT_PID")
126 (add-to-list 'exec-path-from-shell-variables "GPG_AGENT_INFO")
127 (add-to-list 'exec-path-from-shell-variables "LANG")
128 (add-to-list 'exec-path-from-shell-variables "LC_CTYPE")
129 (add-to-list 'exec-path-from-shell-variables "XDG_CONFIG_HOME")
130 (add-to-list 'exec-path-from-shell-variables "XDG_CONFIG_DIRS")
131 (add-to-list 'exec-path-from-shell-variables "XDG_DATA_HOME")
132 (add-to-list 'exec-path-from-shell-variables "XDG_DATA_DIRS")
133 (add-to-list 'exec-path-from-shell-variables "XDG_CACHE_HOME")
134 (exec-path-from-shell-initialize))
135
136(use-package eshell-bookmark
137 :ensure t
138 :hook (eshell-mode-hook . eshell-bookmark-setup))
139
140(provide 'acdw-shell)
141;;; acdw-shell.el ends here