Last Updated on January 12, 2019 by Mathew Diekhake
Terminal has got a number of really amazing commands that can save you a lot of time to do things on your Mac. Whenever you want to run a command, you can simply launch the Terminal app from the Launchpad and type in the command and execute it.
The issue here is that you need to launch Terminal each time you wish to issue a command. If there’s a command that you use every now and then, then you will want to setup a keyboard shortcut for it so that when you press it the command automatically runs on your machine.
There are actually two ways to do that, and the following guide shows both the ways for you:
Running a Terminal Command using a Keyboard Shortcut on a Mac
In this method, you will learn how you can use a third-party app to run a Terminal command using a keyboard shortcut. The app is available for free to download and use on Macs, and you can get it using the link mentioned below.
First of all, download the iCanHazShortcut app on your Mac. Once downloaded, double-click on the downloaded file and then drag the app onto the “Applications” folder to install the app on your Mac.
Once you have dragged and dropped the app onto the Applications folder, it should be available in your Mac’s Launchpad. Click on the Launchpad in your Dock and search for and click on “iCanHazShortcut” and the app should launch.
When the app launches, you will see a screen similar to the following. On this screen, you can see all of the shortcuts you have created in the app. Since you have just installed the app, the list will be empty. To add a new command that can be run using a keyboard shortcut, simply click on the green plus sign and it should let you do that.
On the following screen, you should see two fields. One that says Shortcut where you can define the shortcut for the command and the second that says Action where you can input the command that will be triggered when the shortcut key is pressed.
Click in the “Shortcut” field and press the shortcut keys you want to set up for the command. Then, click in the “Action” field and type in the command you want to run using the keyboard shortcut.
Click on the green sign when you are done specifying a shortcut key and a command to save the changes.
You will come back to the main screen of the app, and you will now see your newly added shortcut there. As you can see, it shows both the shortcut key as well as the command attached to it.
From now on, when this key is pressed, the specified command will run on your Mac.
Using Automator to Run Terminal Commands with Shortcut Keys
If you do not want to use that app, you can create a service in Automator that does the exact job as the app does.
Open the Automator app on your Mac by clicking on Launchpad in your Dock and searching for and clicking on “Automator.”
When Automator launches, select “Service” as the new document type that you wish to create.
On the following screen, drag the action named “Run Shell Script” from left over to the workflow panel on the right. After dragging it, type in your command into its box.
Save your service by pressing “Command + S” on your keyboard.
Now, click on the Apple logo in the top-left corner of your screen and select “System Preferences.” Then, click on “Keyboard” followed by “Shortcuts.” Choose “Services” from the left panel and then find the service you just created and you should be able to assign it a keyboard shortcut.
You can now press this keyboard shortcut, and the command you entered in Automator should run on your Mac.
So, those were two ways to run Terminal commands using a keyboard shortcut on your Mac.
Related Tutorials
- How To Find Your WiFi Password In Mac
- How To Take Your Android’s Screenshots On Your Mac
- How To Reset A User Password In macOS Sierra
- How To Install ADB And Configure Your Mac To Work With It
- How To Remove Settings Icons From The Preferences Panel On A Mac