Skip to content

Instantly share code, notes, and snippets.

@alexispurslane
Last active June 1, 2024 13:47
Show Gist options
  • Save alexispurslane/f60785a3895dd1d4487717e56f93349c to your computer and use it in GitHub Desktop.
Save alexispurslane/f60785a3895dd1d4487717e56f93349c to your computer and use it in GitHub Desktop.
Want to use Emacs's TRAMP to transparently enter containers you're using as distroboxes/devcontainers? Here's how.
(defun user/tramp-layer ()
"Enable TRAMP to use distrobox to transparently enter containers."
(use-package tramp
:commands (eshell shell term ansi-term)
:custom
(tramp-histfile-override "/dev/null")
:config
(add-to-list 'tramp-remote-path 'tramp-own-remote-path) ; make sure TRAMP/any shell you use checks the path variable of the container as well as its own
(message "Loading tramp...")
;; TRAMP 2.7.1 will have distrobox built in, so this won't be necessary for much longer!
(add-to-list 'tramp-methods
`("distrobox" . ((tramp-login-program "distrobox-enter")
(tramp-login-args
(("%h")
("-e" "%l")))
(tramp-remote-shell "/bin/sh")
(tramp-remote-shell-login ("-l"))
(tramp-remote-shell-args ("-i" "-c")))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment