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 Answers 4

27

Profiles -> General -> Command

iterm-screenshot

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

1
  • 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
    Commented Feb 11, 2021 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
  • 2
    How to run multiple commands one after another in same profile tab?
    – Metal Gear
    Commented Sep 5, 2014 at 7:42
  • Can't seem to execute multiple commands either using iTerm2 - attempting to 'make configure', and then 'make service'. Any ideas appreciated!
    – zero_cool
    Commented Oct 27, 2015 at 17:15
  • 4
    You can separate commands with a ; and that will allow multiple commands on one line. In this example make configure; make service should work. Commented Oct 28, 2015 at 21:20
  • 1
    Try command1 && command2 Commented Feb 13, 2020 at 1:38
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

1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .