Question

When developing websites in Mac OS X's terminal using iTerm2, I always have the same bash tabs open.

Until now, when I start coding, I open iTerm2 and fire up 3 tabs. I then cd to my project's folder, activate the virtual environment with `source venv/bin/activate' and do the three separate task I describe below.

I want to streamline this.

Here are the tasks I do in iTerms tabs:

  1. Running the development server, f.e. python3 manage runserver for Django
  2. Running tests, it's always just two commands python3 manage test and python3 manage functional_test
  3. Navigating the project folder with less, tree or to create new files with touch or subl or install a missing package with pip or pip3

Is there anything like a project script for iTerm/bash that says?

  • Start three tabs, all in the project's folder
  • Activate virtualenvin all of them

And how could I speed up the repeating commands such as for testing?

Was it helpful?

Solution

If you’re open to using tmux, you can activate the virtualenv before creating your session. In addition to that, if you’re okay with detaching from the session instead of ending it, well, that’s even better than scripting it to start up how you want it!

Of course, that’s still possible, too:

#!/bin/sh
tmux new-window python3 manage runserver
# or
tmux new-window 'python3 manage runserver; zsh -i'

And you can bind all your tasks to keys in tmux.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top