Skip to content

Commit b1a6d1c

Browse files
committed
support creating ssh using docker-tramp by add vterm-tramp-shells.
1 parent 9e5a208 commit b1a6d1c

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

vterm.el

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,14 @@ the executable."
168168
:type 'string
169169
:group 'vterm)
170170

171+
(defcustom vterm-tramp-shells '(("docker" "/bin/sh"))
172+
"The shell that gets run in the vterm for tramp.
173+
174+
`vterm-tramp-shells' has to be a list of pairs of the format:
175+
\(TRAMP-METHOD SHELL)"
176+
:type '(alist :key-type string :value-type string)
177+
:group 'vterm)
178+
171179
(defcustom vterm-buffer-name "*vterm*"
172180
"The basename used for vterm buffers.
173181
This is the default name used when running `vterm' or
@@ -707,7 +715,7 @@ Exceptions are defined by `vterm-keymap-exceptions'."
707715
;; See: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=220009
708716
(if (eq system-type 'berkeley-unix) "" "iutf8")
709717
(window-body-height)
710-
width vterm-shell))
718+
width (vterm--get-shell)))
711719
;; :coding 'no-conversion
712720
:connection-type 'pty
713721
:file-handler t
@@ -734,6 +742,14 @@ Exceptions are defined by `vterm-keymap-exceptions'."
734742
(setq next-error-function 'vterm-next-error-function)
735743
(setq-local bookmark-make-record-function 'vterm--bookmark-make-record))
736744

745+
(defun vterm--get-shell ()
746+
"Get the shell that gets run in the vterm."
747+
(if (ignore-errors (file-remote-p default-directory))
748+
(with-parsed-tramp-file-name default-directory nil
749+
(or (cadr (assoc method vterm-tramp-shells))
750+
vterm-shell))
751+
vterm-shell))
752+
737753
(defun vterm--bookmark-make-record ()
738754
"Create a vterm bookmark.
739755

0 commit comments

Comments
 (0)