Auto Execute a command or script on Mac Terminal Startup


In order to auto-execute a command or a script every time you open a Mac Terminal, follow the below steps,

  • Open Terminal App,
  • Go to Menu: Terminal -> Preferences... (Settings on macOS Ventura or later)
  • Go to Profile tab,
  • Now go to the shell tab,
  • Check "run command" under Startup and type the command or script that you want to execute.
Run command on Terminal Startup
Example:

Running a curl command to get the weather details every time you start a new terminal instance.

Get weather details Terminal
-




Have Questions? Post them here!