eshell at server directory

Share on:

Here is a little Emacs-macro that creates an eshell buffer with current directory set to a server directory path.

(defmacro srv-eshell (server-nick path )
  `(defun ,(intern (concat server-nick "-eshell")) ()
       (interactive)
     (let* ((eshell-buffer-name ,(concat server-nick "-eshell"))
            (eshell-buffer   (eshell)))

       )
     (end-of-buffer)
     (eshell-kill-input)
     (insert ,(concat  "cd " path))
     (eshell-send-input))
    )

Use the macro like this:

(srv-eshell "afws" "/scp:joakim@192.168.201.58:")

Now you get an interactive function you can call with m-x afws-eshell. This will open an eshell buffer called afws-eshell, with the current directory set to /scp:joakim@192.168.201.58: .

Tramp will sort out the rest.