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

Facing issues? Have Questions? Post them here! I am happy to answer!

Author Info:

Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.

Follow him on: X

You can also reach out to him via e-mail: rakesh@code2care.org



















Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap