Skip to content

Instantly share code, notes, and snippets.

@fisadev
Created December 3, 2015 14:57
Show Gist options
  • Save fisadev/044af2854ba38bcd6ef8 to your computer and use it in GitHub Desktop.
Save fisadev/044af2854ba38bcd6ef8 to your computer and use it in GitHub Desktop.
A python script to launch my tmux things at once
#!/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')
@Shivanshu156
Copy link

You saved my day 🥇

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment