Published by Phil Balchin

After a few months in development and local testing, it's now time to formally go live with a Tmux plugin that I have been building in my spare time. tmux-devcontainers is a Tmux plugin to:

  • Show the status of the devcontainers for the current workspace
  • A menu that provides quick access to common commands like starting/restarting/removing devcontainers
  • A key binding to open a new window and execute a new login shell inside the primary devcontainer.

Devcontainers are an open-source format for specifying how to use the docker containers for your app or service, as a development environment. So instead of needing to install and setup a local environment, and resolve any dependency conflicts, you can instead use your docker file and docker compose configuration, to run your project in an isolated development container. The full spec for devconatiners is available at https://containers.dev. Devcontainers have been integrated with VSCode and GitHub code spaces for some time, and for terminal, and Tmux users, there is the devcontainers-cli tool that provides commands to configure manage devcontainer lifecycles. Using this CLI, tmux-devcontainers aims to provide a VSCode like experience for status, menu commands, and key bindings for all common uses of the DevContainers CLI.

tmux-devcontainers was built to support my personal development environment. It works for my style of development, and my personal projects which are mostly based around docker-compose configuration. I'm sure there are other Docker configurations that may not fully work, but it is also very early days, and there are plenty of bugs, and new features that I plan to implement. Of cause being open source, I'll always appreciate new issues and Pull Requests.

Installation

Tmux Plugin Manager is the easiest method for installing. Adding the following to your tmux config file:

set -g @plugin 'phil/tmux-devcontainers'

At release, the plugin has a few prerequisites:

Docker and devcontainer-cli are pretty self explanatory. Jq is used to make reading json configuration files easier.

Status bar integration

tmux-devcontainers provides status bar placeholders to show the status of the devcontainers:

set -g status-right '#{devcontainers_workspace} #{devcontainers_status}'
  • #{devcontainers_workspace}: shows the name of the devcontainer workspace.
  • #{devcontainers_status}: shows the status of each container in the workspace.

Menu commands

Commands to manage devcontainers. Commands run in new windows and try to be unintrusive by automatically closing on success.

Key bindings

tmux-devcontainers provides default key bindings to interact with the devcontainers:

  • prefix + E: creates a new tmux pane with a login shell in the devcontainer.
  • prefix + (Ctrl + e): shows a menu to interact with the devcontainers in the current workspace.

Key bindings can be customised by setting the following options in your Tmux configuration file:

set-option -g @devcontainers_exec_key 'T' # default: 'E'
set-option -g @devcontainers_menu_key 'M' # default: 'Ctrl + e'

GitHub: phil/tmux-devcontainers

https://github.com/phil/tmux-devcontainers

About the Author

Phil Balchin is a full-time software developer at Zendesk, previously at Heroku/Salesforce, and Kyan, as well as a part-time photographer living in Guildford, Surrey, UK.

facebook.com/phil.balchin | instagram.com/maniacalrobot | last.fm/users/maniacalrobot | picfair.com/maniacalrobot | maniacalrobot.tumblr.com | twitter.com/maniacalrobot