This script automates the creation of a clickable .command file that executes a given shell script. It ensures that the selected shell script is executable and allows users to run it by double-clicking from macOS Finder or the Dock.
- Creates a
.commandfile that runs the specified shell script. - Ensures execution permissions by setting the shell script as executable.
- Provides user-friendly access by suggesting users drag the
.commandfile to the Dock. - Opens Finder automatically to facilitate easy access to the generated file.
- User Input: The script prompts for the full path of an existing shell script.
- Validation: It checks if the specified script file exists.
- File Generation: It creates a new
.commandfile alongside the original script. - Permission Fix: It ensures the
.commandfile and the original script are executable. - Execution Mechanism: When clicked, the
.commandfile runs the specified script in a new shell session. - Ease of Access: The script opens Finder and suggests dragging the
.commandfile to the Dock for quick execution.
-
Open a terminal and run the script:
./your_script_name.sh
-
Enter the full path of the shell script you want to make clickable, for example:
/Users/yourname/Documents/create_repo.sh -
The script will:
- Verify the script exists.
- Generate a corresponding
.commandfile. - Set the necessary permissions.
- Open Finder for easy access.
-
Drag the newly created
.commandfile to the Dock for quick access. -
Double-click the
.commandfile to execute your script anytime.
Enter the full path of your shell script (e.g., /Users/yourname/Documents/create_repo.sh):
/Users/johndoe/Scripts/my_script.sh
✅ Clickable '/Users/johndoe/Scripts/my_script.command' created!
📌 Drag '/Users/johndoe/Scripts/my_script.command' to the Dock for easy access!
Finder opens to the script’s location for easy dragging.
- macOS
- Bash (
#!/bin/bashinterpreter) - Terminal access to run the initial setup
- This script is designed for macOS users who want an easy way to run shell scripts by clicking instead of using the Terminal.
- The
.commandfile runs in a new shell session, ensuring environment variables are properly loaded. - If the
.commandfile doesn't open, check your System Preferences > Security & Privacy to allow scripts from unidentified developers.