Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
View docker-compose services logs in split tmux panes
# Requires pyyaml
import os
import yaml
run = os.system
new_window = lambda cmd: run('tmux new-window -n "logs" "{}"'.format(cmd))
split_vertical = lambda cmd: run('tmux split-window "{}"'.format(cmd))
split_horizontal = lambda cmd: run('tmux split-window -h "{}"'.format(cmd))
even_vertical = lambda: run('tmux select-layout even-vertical')
if __name__ == '__main__':
config_text = open('docker-compose.yaml').read()
except IOError:
config_text = open('docker-compose.yml').read()
config = yaml.load(config_text)
services = config['services'].keys()
new_window('docker-compose logs -f {}'.format(services[0]))
for service in services[1:]:
split_horizontal('docker-compose logs -f {}'.format(service))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.