blob: 7004b1de7e2f72197888b818892ea5950f718b9d (
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
;;; -*- lexical-binding: t; -*-
(use-package eshell
:bind
(:map eshell-mode-map
("M-r" . consult-history))
:hook ((eshell-first-time-mode . kj/eshell-on-load))
:config
(add-hook 'eshell-mode-hook
(lambda ()
(setenv "PAGER" "cat"))
(setenv "EDITOR" "emacsclient"))
(setq eshell-prefer-lisp-functions nil
eshell-scroll-to-bottom-on-input 'all
eshell-hist-ignoredups t
eshell-destroy-buffer-when-process-dies t
eshell-error-if-no-glob t)
(setq tramp-remote-path '(tramp-own-remote-path))
(defun kj/eshell-on-load ()
(dolist (command '("htop" "tmux" "vim" "nvim" "watch"))
(add-to-list 'eshell-visual-commands
command))
;; (define-key eshell-prompt-mode-map (kbd "C-d") 'eshell-life-is-too-much)
)
(add-to-list 'eshell-complex-commands "ssh")
(add-to-list 'eshell-modules-list 'eshell-tramp)
(add-hook 'eshell-mode-hook 'visual-line-mode))
(use-package pcmpl-args)
(use-package esh-help
:init
(setup-esh-help-eldoc))
(use-package eshell-syntax-highlighting
:hook (eshell-mode . eshell-syntax-highlighting-mode))
(defun eshell/ssh (&rest args)
(if (= 1 (length args))
(throw 'eshell-replace-command
(eshell/cd
(format "/ssh:%s:" (car args))))
(throw 'eshell-replace-command
(eshell-parse-command "*ssh"
(eshell-stringify-list (flatten-tree args))))))
(defvar kj/eshell-here-directory)
(defun kj/eshell-buffer-name ()
(let ((base (concat "*eshell:" default-directory)))
(cond
((not (get-buffer base)) base)
(t (cl-loop for n from 2
for name = (format "%s<%d>" base n)
until (not (get-buffer name))
finally return name)))))
(defun kj/eshell-update-buffer-name ()
(interactive)
(rename-buffer (kj/eshell-buffer-name)))
(add-hook 'eshell-directory-change-hook 'kj/eshell-update-buffer-name)
(defun kj/new-eshell-here ()
(let ((default-directory kj/eshell-here-directory))
(eshell t)))
(defun kj/eshell-here ()
(interactive)
(unless (eq last-command 'kj/eshell-here)
(setq kj/eshell-here-directory
(if (derived-mode-p 'eshell-mode)
(with-current-buffer (other-buffer (current-buffer) t)
default-directory)
default-directory)))
(if (derived-mode-p 'eshell-mode)
(kj/new-eshell-here)
(eshell))
(kj/eshell-update-buffer-name))
(provide 'kj-eshell)
|