- Scripts are small files that contain a list of commands that tells your Mac what functions to perform and when. Fortunately, Apple is kind enough to provide you with several completed scripts with your installation of Yosemite. You can find a large cache of scripts in the scripts folder, found in the Library folder, under Scripts.
- The same is the case from the command line. There are two commands for moving and copying: mv and cp.The first does the same as dragging a file to a new location on the same hard disk; the second.
- Shell scripts must be executable files in order to run. You can use the chmod command to indicate that the text file is executable (that is, its contents can be run as a shell script). In the Terminal app on your Mac, use the cd command to move into the directory that contains the file you want to make executable.
- Run chmod u+x /Desktop/myCommandScript.command in your terminal, where /Desktop/myCommandScript.command is the path to your script.
The Generic Script file type, file format description, and Mac, Windows, and Linux programs listed on this page have been individually researched and verified by the FileInfo team. We strive for 100% accuracy and only publish information about file formats that we have tested and validated.
Ever thought of having an application to run it directly instead of multiple shell commands?
And won’t it be cool to just convert your shell script into a Mac application and use it just like any other mac applications?
So let’s learn today to create mac app from a shell script.
Before jumping into the application creation, we will quickly see how an application folder structure in Mac looks like:
The bare minimum folder structure is something like below that you will find for any applications in Mac.
(app-name).app
├── Contents
│ └── MacOS
│ └── (app-name)
└── Icon
├── Contents
│ └── MacOS
│ └── (app-name)
└── Icon
So now let’s get started. We need mainly three things for our application:
- An executable shell script which will make your shell script as an application.
- Your actual shell script to make it as an application.
- Add an icon to your application. (Not Mandatory but looks cool like real app)
Let’s walk through these steps one by one:
- An executable shell script which will make your shell script as an application:
- Create a file with the above script and save it in
/usr/local/bin
. - Then make the above file as executable with the command from command line/Terminal:
sudo chmod +x /usr/local/bin/appify
Note:- You can give it any name and no extension is required for the file.
- For reference, we will give it a name as ‘appify’
- We are saving the file at
/usr/local/bin
so that we can directly call ‘appify’ script. If you want to save at any other place like your username directory then you will have to call the script with its full path like ‘/User/your-username/appify’
- Create a file with the above script and save it in
- Your actual shell script to make it as an application:
- Now have your script file with .sh extension ready and run the below command to make you shell script as a Mac application.
- Add an icon to your application:
This one is very simple.- Just copy any image you want as the app icon.
- Right-click your new application select “Get Info”.
- Select the app icon on the top left corner by clicking it just once.
- and then either hit ⌘ + V to paste it or go to ‘Edit’ from menu link and select paste.
- With this, it will overwrite the default icon with your new icon.
Now your application is ready to use just like any other application.
Below is a quick simple demo example to see the above process in action:
I hope this post will help you learn how to create mac app from a shell script.
References:
Related
Generally, most scripts are written in Script Editor documents. Scripts can also be written in Xcode, but this is typically for scripts that require advanced user interfaces.
- Launch Script Editor in
/Applications/Utilities/
. - If the script isn’t configured for the correct language, choose the language in the navigation bar.TipIf you always use the same language, set it as the default language in the General pane of Script Editor preferences. See General Preferences.
- Write your script code in the editing area. Newly written code is uncompiled and formatted as new text.
- Click the Compile button () to compile the script and check for syntax errors.If a syntax error occurs, an alert is displayed.If the script compiles, code formatting is applied at this time.
Mac Run Shell Script
Tip
Running Package Scripts Mac
You can change the formatting attributes, such as font and color, of uncompiled and compiled text in the Formatting pane of Script Editor preferences. See Formatting Preferences.