osx - Open new tab in ITerm2 and run commands there with zsh script -


i want make shell script startup project env. i'm using iterm2 zsh , oh-my-zsh installed.

i want to:

  1. open directory
  2. activate python virtualenv
  3. run django manage command
  4. switch new tab
  5. change directory
  6. run gulp command watch frontend changes

all got this:

#!/bin/zsh cd ~/projects/python/project_name source ~/virtualenvs/project_name/bin/activate python ./backend/manage.py runserver  tab cd front gulp watch 

and can expect doesn't work. can point me direction should or possible shell script?

completely possible.

i did pretty same thing you're trying (although rails project) using npm package called ttab.

  1. install npm.
  2. install ttab.
  3. you can run commands in new tab so:
# first switch directory cd front # open new tab in directory , execute ttab -g eval "gulp watch" 

note: can execute several commands if needed, gulp watch; rails s.

  1. if need run command on original tab on different directory, can create procedure/function in script file that:
# define function before called gotofolder() {   cd ~/mydirectory }  # start other tabs (...)  # change original tab directory gotofolder # run rails or whatever ./bin/rails s 

if want take @ how did this, please checkout confereai.sh script in my mdfr repo.


Comments