summaryrefslogtreecommitdiff
path: root/emacs/.config/emacs-kj/lisp/kj-eshell.el
blob: 3787c671c6a638aa5babd5a88fd61e09b89bb802 (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
;;; -*- lexical-binding: t; -*-
(use-package eshell
  :bind
  (:map eshell-hist-mode-map
        ("M-r" . consult-history))

  :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-error-if-no-glob t)
  (setq tramp-remote-path '(tramp-own-remote-path))

  (add-to-list 'eshell-modules-list 'eshell-tramp)
  (add-to-list 'eshell-load-hook #'kj/on-eshell-load)

  (add-hook 'eshell-mode-hook 'visual-line-mode))

(use-package esh-help
  :init
  (setup-esh-help-eldoc))

(use-package eshell-syntax-highlighting
  :hook (eshell-mode . eshell-syntax-highlighting-mode))

(use-package fish-completion
  :config
  (setq fish-completion-fallback-on-bash-p t)
  :init
  (fish-completion-mode 1))

(defun kj/on-eshell-load (&args rest)
  (add-to-list 'eshell-visual-commands
               '("htop" "tmux" "vim" "nvim"))
  (add-to-list 'eshell-complex-commands "ssh"))

(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))))))

(provide 'kj-eshell)