macOS Terminal – How to Automatically Issue Command in One Tab

macosterminal

When I use terminal on OSX, I normally have console terminal open with a number of different tabs. In one of those tabs I have a localhost server and in another tab I have a different localhost server. I have saved this window configuration as a windows group that is reopened when I restart terminal, say upon rebooting.

When I restart terminal, I want the two tabs with servers in them to restart the servers.

How do I do this?

Best Answer

This may help you. Go to Preferences under the Terminal menu and a panel opens. Click on the Profiles icon on the top left of the panel. This opens a new panel as shown below.

enter image description here

Click on the shell tab at the top of the new panel. The first item, as shown in the image, is where you can define a command or commands to run when the tab is opened.