Skip to content

Instantly share code, notes, and snippets.

@mikemcduffie
Forked from valosekj/run_app_from_terminal.md
Created September 8, 2025 05:01
Show Gist options
  • Select an option

  • Save mikemcduffie/97bf929032f8112b521c6712a4d7cf19 to your computer and use it in GitHub Desktop.

Select an option

Save mikemcduffie/97bf929032f8112b521c6712a4d7cf19 to your computer and use it in GitHub Desktop.
Run arbitrary application from terminal on MacOS #blog

Run arbitrary application from terminal on MacOS

Sometimes, it is convenient to have possibility to start/run any application (like your internet browser or text editor) directly from your terminal. Most of these applications however do not create shortcut for easy run from terminal during their installation. Below is short manual how to create this shortcut manually.

Steps

  1. Open terminal (cmd + space --> type terminal)

  2. Navigate to /usr/local/bin:

cd /usr/local/bin
  1. Create a new sh script for your selected application you want to run from terminal. In this case, e.g., Google Chrome. I am using nano text editor, so type:
nano chrome

Then insert following two lines into your editor:

#!/bin/bash

/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome $@

(Pay attention to spaces in path to your app above. Replace them by \ )

Then press ctrl + O for save and ctrl + X for exit nano text editor.

  1. Make your script executable:
chmod 770 chrome
  1. Restart your shell:
source /etc/zshr

or

source /etc/bashrc
  1. Voila! Now, you can run simple run chrome command in your terminal.
chrome <your_webpage>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment