-
-
Save fisadev/044af2854ba38bcd6ef8 to your computer and use it in GitHub Desktop.
A python script to launch my tmux things at once
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# coding: utf-8 | |
from os import system | |
PROJECT_PATH = 'path_to_your_project' | |
ACTIVATE_VENV = '. path_to_your_virtualenv/bin/activate' | |
def tmux(command): | |
system('tmux %s' % command) | |
def tmux_shell(command): | |
tmux('send-keys "%s" "C-m"' % command) | |
# example: one tab with vim, other tab with two consoles (vertical split) | |
# with virtualenvs on the project, and a third tab with the server running | |
# vim in project | |
tmux('select-window -t 0') | |
tmux_shell('cd %s' % PROJECT_PATH) | |
tmux_shell('vim') | |
tmux('rename-window "vim"') | |
# console in project | |
tmux('new-window') | |
tmux('select-window -t 1') | |
tmux_shell('cd %s' % PROJECT_PATH) | |
tmux_shell(ACTIVATE_VENV) | |
tmux('rename-window "consola"') | |
# second console as split | |
tmux('split-window -v') | |
tmux('select-pane -t 1') | |
tmux_shell('cd %s' % PROJECT_PATH) | |
tmux_shell(ACTIVATE_VENV) | |
tmux('rename-window "consola"') | |
# local server | |
tmux('new-window') | |
tmux('select-window -t 2') | |
tmux_shell('cd %s' % PROJECT_PATH) | |
tmux_shell(ACTIVATE_VENV) | |
tmux_shell('python manage.py runserver') | |
tmux('rename-window "server"') | |
# go back to the first window | |
tmux('select-window -t 0') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You saved my day 🥇