Skip to main content

Snippety Helper

Snippety by default supports only basic bash scripts. It works this way because App Store applications are sandboxed and don't have access to external folders, applications, and many other things.

If you want to unlock a full potential of the Command Line Script placeholder, you can install Snippety Helper. It will launch a small program allowing you to run most scripts from Snippety.

Installation

Open Terminal and run the following command:

cd ~/Downloads && /bin/bash -c "$(curl -fsSL https://snippety.app/SnippetyHelper-Installer.sh)"

Snippety Helper requires Homebrew, fswatch, and coreutils that will be installed automatically.

After the installation is finished, you will find the application in a hidden folder: ~/Downloads/.snippety-helper. Just delete the folder to uninstall.

To start Snippety Helper follow the instructions and run:

~/Downloads/.snippety-helper/bin/snippety-helper.sh

Usage

Now, in Snippety you can enable extended scripts support by using the following command in script placeholders:

snippety-helper "YOUR_COMMAND"

Example placeholder:

{@script|None|snippety-helper "ls"|YES@}

Updates

~/Downloads/.snippety-helper/bin/update.sh

Uninstallation

~/Downloads/.snippety-helper/bin/uninstall.sh

Launching Snippety Helper at login

If you launched the script manually before, make sure to kill it to avoid two scripts running at the same time.

There are two ways to launch Snippety Helper automatically without keeping a running terminal:

1. Using Automator

You can create an Automator application and add it to login items. Just follow the instruction below: Video Tutorial

The script to be pasted in Automator:

PATH="/opt/homebrew/bin:/usr/local/bin/:$PATH" ~/Downloads/.snippety-helper/bin/snippety-helper.sh &> ~/Downloads/.snippety-helper/output.txt

After the Automator app is created, launch it for the first time manually and try it with Snippety. It starts in the background, so don't worry, nothing happens once you double click the app. The automator icon should appear in the menu bar.

2. Creating Launch Agent

More reliable solution is to create a Launch Agent. The macOS will automatically controll the script and relaunch it if needed. The only downside is that this approach requires to configure additional permissions.

  1. Create a file named app.snippety.helper.plist in ~/Library/LaunchAgents. Make sure to replace <USERNAME> with your username.
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
    <key>Label</key>
    <string>app.snippety.helper</string>
    <key>ProgramArguments</key>
    <array>
    <string>/bin/bash</string>
    <string>/Users/<USERNAME>/Downloads/.snippety-helper/bin/snippety-helper.sh</string>
    </array>
    <key>StandardErrorPath</key>
    <string>/Users/<USERNAME>/Downloads/.snippety-helper/data/error.log</string>
    <key>StandardOutPath</key>
    <string>/Users/<USERNAME>/Downloads/.snippety-helper/data/output.log</string>
    <key>RunAtLoad</key>
    <true/>
    <key>KeepAlive</key>
    <true/>
    <key>EnvironmentVariables</key>
    <dict>
    <key>PATH</key>
    <string>/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin</string>
    </dict>
    </dict>
    </plist>
  2. Go to System Settings -> Privacy & Security -> Full Disk Access.
  3. Add /bin/bash (CMD+Shift+G to quickly navigate there).
  4. Run agent: launchctl load ~/Library/LaunchAgents/app.snippety.helper.plist (required only once).

To uninstall Launch Agent just run:

launchctl unload ~/Library/LaunchAgents/app.snippety.helper.plist && rm ~/Library/LaunchAgents/app.snippety.helper.plist

Warning

Avoid running this script with sudo. This way you could introduce a gateway for harmful applications!