summaryrefslogtreecommitdiff
path: root/emacs/.config/emacs-kj/eshell.el
blob: b47591598bf106ae593650c995df89bd96d0c302 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
;;; -*- lexical-binding: t; -*-
(use-package eshell
  :config
  (add-hook 'eshell-mode-hook
            (lambda ()
              (setenv "PAGER" "cat"))
            (setenv "EDITOR" "emacsclient"))
  (setq eshell-prefer-lisp-functions t)
  (setq tramp-remote-path '(tramp-own-remote-path))

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

(defun kj/on-eshell-load (&args rest)
  (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))))))