28

How do I set a command on a profile so that when I start a new terminal window, it fires off that command.

Specifically, I'd like to be able to set my virtualenv with:

workon ENV

So that it starts automatically into my virtual environment when that I use that profile.

4 Answers4

27

Profiles -> General -> Command

iterm-screenshot

Everytime you open a new tab your bash profile will be sourced.

alakin_11
  • 397
  • 3
  • 3
  • 1
    What if you only want to launch it the first time iterm2 starts up? And not every time a new tab is opened? – Jens Bodal Feb 11 '21 at 19:44
10

Got it, there is an option added in the development branch of iTerm that adds a "Send text at start" option to the profile settings. This will eventually be added to a (more) stable version of iTerm.

4

In iTerm2, preferences>profiles>tab general, there is an option in Command called send text at start that executes any command you put there after login.

In particular, I typically have

source ~/.virtualenvs/.../bin/activate

for profiles that use Python.

4

Using the image to illustrate, please note the command selection and Send text at start: option.

enter image description here

iNoob
  • 141
  • 1
  • 1
    This should be an edit to the accepted answer https://apple.stackexchange.com/a/115870/237 – mmmmmm May 07 '20 at 10:38