Skip to content

Wrapper around devcontainers for Emacs, similar to VSCode DevContainers plugin

License

Notifications You must be signed in to change notification settings

bradschwartz/devcontainer.el

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 

Repository files navigation

devcontainer.el

A wrapper around DevContainers. Currently just wraps the literal CLI tool.

The best way to use this package is to clone this repository locally, add it to your load-path, and modify your init scripts with the following:

(add-hook 'dired-before-readin-hook #'devcontainer-dir-open-hook)

This devcontainer-dir-open-hook will run whenever a directory is opened by Emacs, but before the directory is actually opened in a buffer. If it finds that it is a valid Devcontainer-using directory, it will:

  1. Prompt asking if it should open in the devcontainer - flow aborts if respond with n
  2. Start that devcontainer using the CLI
  3. Connect to it using TRAMP via docker-tramp package
  4. Replace dired buffer with the TRAMP session
  5. Add a hook to stop the devcontainer when emacs is stopped (kill-emacs-hook)

Caveats

This does not work with Emacs in server mode and opening a new window with emacsclient [--tty]. The window opens, prompted to open in container, and then entire window auto closes itself. No container is ever started, but you don't get to edit anything either. Tested on Darwin with Homebrew-installed Emacs. Steps to reproduce:

brew install emacs
brew services restart emacs
emacsclient .

Dependencies

  • devcontainer in PATH
  • docker in PATH - no other assumptions made on daemon, although its probably best to have it local
  • Emacs packages:
    • shell
    • json
    • docker-tramp

About

Wrapper around devcontainers for Emacs, similar to VSCode DevContainers plugin

Topics

Resources

License

Stars

Watchers

Forks