### Install soco-cli Source: https://github.com/raycast/script-commands/blob/master/commands/media/sonos/README.md Install the soco-cli tool using pip. This is a prerequisite for controlling Sonos devices. ```bash pip install soco-cli ``` -------------------------------- ### Install and Configure Find My Raycast Script Source: https://github.com/raycast/script-commands/blob/master/commands/apps/find-my/README.md Clone the repository, install dependencies, and configure your environment variables. Ensure the script is executable. ```bash git clone https://github.com/vsvaidya27/fmp-raycast cd fmp-raycast npm install cp .env.example .env # Edit .env with your real credentials chmod +x fmp.js ``` -------------------------------- ### Install Bitwarden CLI and jq Source: https://github.com/raycast/script-commands/blob/master/commands/productivity/bitwarden/README.md Installs the necessary dependencies for the Bitwarden package using Homebrew. Ensure you have Homebrew installed before running this command. ```shell $ brew install bitwarden-cli jq ``` -------------------------------- ### Install LGWebOSRemote Library Source: https://github.com/raycast/script-commands/blob/master/commands/remote-control/lg-tv/README.md Install the LGWebOSRemote library system-wide using pipx. This is a prerequisite for using the LG TV script commands. ```bash pipx install git+https://github.com/klattimer/LGWebOSRemote ``` -------------------------------- ### Install fzf Utility Source: https://github.com/raycast/script-commands/blob/master/commands/apps/mullvad/README.md Install the 'fzf' utility using Homebrew. This is a dependency for the 'Search Countries, Cities, and Hostnames' command. ```sh $ brew install fzf ``` -------------------------------- ### LG TV Scan Output Example Source: https://github.com/raycast/script-commands/blob/master/commands/remote-control/lg-tv/README.md Example JSON output from the 'Scan' command, which lists detected LG TVs on the network. Copy the TV's IP address from this output for authentication. ```json {"result": "ok", "count": 1, "list": [{"uuid": "some-long-id", "model": "OLED55C11LB", "address": "192.168.1.200"}]} ``` -------------------------------- ### Example Folder Structure for Script Commands Source: https://github.com/raycast/script-commands/blob/master/CONTRIBUTING.md Organize related scripts into sub-directories to avoid clutter and improve discoverability. Use a dedicated 'images' folder for script-related assets. ```markdown . commands └─ media ├─ spotify ├─ apple-music └─ youtube ``` ```markdown . commands └─ media └─ spotify └─ images └─ spotify-logo.png └─ spotify-next-track.applescript └─ spotify-prev-track.applescript ``` -------------------------------- ### Check for jq Dependency in Bash Source: https://context7.com/raycast/script-commands/llms.txt Ensures the 'jq' command-line JSON processor is installed before proceeding. Exits with an error message if jq is not found, providing installation instructions. ```bash #!/bin/bash # Check for dependency before doing any work if ! command -v jq &>/dev/null; then echo "Missing dependency: jq" echo "Install with: brew install jq" exit 1 fi clipboard=$(pbpaste) if [ -z "$clipboard" ]; then echo "Clipboard is empty" exit 1 fi echo "$clipboard" | jq '.' 2>&1 || { echo "Invalid JSON in clipboard" exit 1 } ``` -------------------------------- ### Format JSON Clipboard (Bash) Source: https://context7.com/raycast/script-commands/llms.txt Formats JSON content from the clipboard using `jq`. Requires `jq` to be installed via Homebrew. ```bash #!/bin/bash # Dependency: requires `jq` for JSON parsing # Install via Homebrew: brew install jq # @raycast.schemaVersion 1 # @raycast.title Format JSON Clipboard # @raycast.mode fullOutput # @raycast.packageName Developer Utils ``` -------------------------------- ### Ask Gemini with Context (Node.js) Source: https://context7.com/raycast/script-commands/llms.txt Opens Gemini in Chrome, optionally passing selected text as context. Requires Node.js and `chrome-cli`. Fails if `chrome-cli` is not installed. ```javascript #!/usr/bin/env node // Dependency: requires Node.js — https://nodejs.org // Install: brew install node // Required parameters: // @raycast.schemaVersion 1 // @raycast.title Ask Gemini // @raycast.mode silent // @raycast.packageName Gemini // @raycast.icon ./images/icon-gemini.svg // @raycast.argument1 { "type": "text", "placeholder": "Selected Text", "optional": true } // @raycast.argument2 { "type": "text", "placeholder": "Prompt" } // Documentation: // @raycast.description Open Gemini in Chrome and submit a prompt with optional context. // @raycast.author Your Name // @raycast.authorURL https://github.com/yourname const { execSync } = require("child_process"); const selectedText = process.argv[2] || ""; const prompt = process.argv[3]; if (!prompt) { console.error("A prompt is required"); process.exit(1); } // Verify chrome-cli dependency try { execSync("which chrome-cli", { stdio: "ignore" }); } catch { console.error("chrome-cli is required: brew install chrome-cli"); process.exit(1); } // Open or focus Gemini tab const tabs = JSON.parse(execSync("chrome-cli list tabs")).tabs; const geminiTab = tabs.find(t => t.url.startsWith("https://gemini.google.com/")); if (geminiTab) { execSync(`chrome-cli activate -t ${geminiTab.id}`); } else { execSync("chrome-cli open 'https://gemini.google.com/app'"); } console.log("Gemini opened"); // Arguments are accessed via process.argv starting at index 2 ``` -------------------------------- ### Declare and Install jq Dependency in Bash Script Source: https://github.com/raycast/script-commands/blob/master/CONTRIBUTING.md When a Bash script requires a specific CLI tool like `jq`, declare it in a comment block with installation instructions. Ensure your script includes a check for the command's existence and exits gracefully if it's missing. ```bash #!/bin/bash # Dependency: This script requires `jq` cli installed: https://stedolan.github.io/jq/ # Install via homebrew: `brew install jq` # @raycast.schemaVersion 1 # @raycast.title Prettify JSON from Clipboard ... ``` ```bash if ! command -v download &> /dev/null; then echo "download command is required (https://github.com/kevva/download-cli)."; exit 1; fi ``` -------------------------------- ### Node.js Example for Colored Output Source: https://github.com/raycast/script-commands/blob/master/documentation/OUTPUTMODES.md This Node.js code logs a string with ANSI escape codes to the console, setting red text on a green background before resetting the formatting. ```javascript console.log('\x1b[31;42mred text on green background\x1b[0m') ``` -------------------------------- ### Get CPU Usage Source: https://context7.com/raycast/script-commands/llms.txt This script fetches and displays the current CPU usage. It's designed to be run in Raycast and refreshed periodically. ```bash # @raycast.icon 🖥️ output=$(top -l 1 | grep "CPU usage") cpu_usage=$(echo "$output" | awk -F " " '{print $3}' | cut -d% -f1) echo "CPU: ${cpu_usage}%" # Output: "CPU: 12.3%" shown live in command list, refreshed every 10 seconds ``` -------------------------------- ### Osascript Example for Colored Output Source: https://github.com/raycast/script-commands/blob/master/documentation/OUTPUTMODES.md This osascript command executes a shell script to print colored text. It uses ANSI escape codes to set red text on a green background and then resets the formatting. ```osascript do shell script "echo '\033[31;42mred text on green background\033[0m'" ``` -------------------------------- ### Swift Example for Colored Output Source: https://github.com/raycast/script-commands/blob/master/documentation/OUTPUTMODES.md This Swift code snippet prints a string with ANSI escape codes for colored output. It sets the foreground to red and background to green, then resets the formatting. ```swift print("\u{001B}[31;42mred text on green background\u{001B}[0m") ``` -------------------------------- ### Declare App Requirement in Bash Script Source: https://github.com/raycast/script-commands/blob/master/CONTRIBUTING.md If a script relies on a specific application, note the required app and version in a comment block at the top of the script, along with installation guidance. ```bash #!/bin/bash # Note: Plash v2.2.0 required # Install via Mac App Store: https://apps.apple.com/app/id1494023538 # @raycast.schemaVersion 1 ``` -------------------------------- ### Bash Script Error Handling Example Source: https://github.com/raycast/script-commands/blob/master/README.md This bash script demonstrates how to handle errors by checking a regular expression match. If the value is invalid, it prints an error message and exits with a status code of 1, signaling failure to Raycast. ```bash if ! [[ $value =~ $regex ]] ; then echo "Invalid value provided" exit 1 else ... fi ``` -------------------------------- ### Bash tput Example for Colored Output Source: https://github.com/raycast/script-commands/blob/master/documentation/OUTPUTMODES.md This bash script uses `tput` to set terminal attributes for colored output. It sets the foreground to red and background to green, then resets attributes. Ensure `TERM` is set to `linux` for compatibility. ```bash export TERM=linux; echo "$(tput setaf 1)$(tput setab 2)red text on green background$(tput sgr0)"; ``` -------------------------------- ### Bash Example for Colored Output Source: https://github.com/raycast/script-commands/blob/master/documentation/OUTPUTMODES.md This bash script demonstrates how to output colored text on a colored background using ANSI escape codes. The `echo -e` command interprets backslash escapes, and `\[033[31;42m` sets red foreground and green background, while `\[033[0m` resets the formatting. ```bash echo -e '\033[31;42mred text on green background\033[0m' ``` -------------------------------- ### Run the Toolkit CLI Source: https://github.com/raycast/script-commands/blob/master/Tools/Toolkit/CONTRIBUTING.md After building, you can execute the Toolkit CLI using the generated binary. Navigate to the repository root first. ```bash ./toolkit ``` -------------------------------- ### Build the Toolkit CLI Source: https://github.com/raycast/script-commands/blob/master/Tools/Toolkit/CONTRIBUTING.md Follow these steps to build the command-line interface binary. This involves running 'make build' in the repository root. ```bash make build ``` -------------------------------- ### Raycast Toolkit CLI Overview Source: https://github.com/raycast/script-commands/blob/master/Tools/Toolkit/README.md This displays the general usage and available subcommands for the Raycast Toolkit CLI. Use 'generate-documentation' to create documentation files. ```txt OVERVIEW: A tool to generate automatized documentation USAGE: toolkit [--version] OPTIONS: -v, --version Print the version and exit -h, --help Show help information. SUBCOMMANDS: generate-documentation Generate the documentation in JSON and Markdown format See 'toolkit help ' for detailed help. ``` -------------------------------- ### Open Project in Xcode Source: https://github.com/raycast/script-commands/blob/master/Tools/Toolkit/CONTRIBUTING.md Use this command to open the project directory in Xcode. Xcode will automatically download necessary Swift Packages. ```bash open -a Xcode.app . ``` -------------------------------- ### Display System Info (Swift) Source: https://context7.com/raycast/script-commands/llms.txt Displays the macOS version and hardware model using the `sw_vers` command. Supports ANSI colors in full output mode. ```swift #!/usr/bin/swift // Required parameters: // @raycast.schemaVersion 1 // @raycast.title System Info // @raycast.mode fullOutput // @raycast.packageName System // @raycast.icon 🖥️ // Documentation: // @raycast.description Display macOS version and hardware model. // @raycast.author Your Name // @raycast.authorURL https://github.com/yourname import Foundation let process = Process() process.launchPath = "/usr/bin/sw_vers" let pipe = Pipe() process.standardOutput = pipe process.launch() process.waitUntilExit() let output = String(data: pipe.fileHandleForReading.readDataToEndOfFile(), encoding: .utf8) ?? "" print("\u{001B}[36mSystem Information\u{001B}[0m") print(output) // ANSI colors work in fullOutput mode; \u{001B} is the escape character in Swift ``` -------------------------------- ### Connect VPN with Password Argument Source: https://context7.com/raycast/script-commands/llms.txt This script securely connects to a VPN using a host and a masked password input. It validates that both host and password are provided. ```bash #!/bin/bash # @raycast.schemaVersion 1 # @raycast.title Connect VPN # @raycast.mode compact # @raycast.packageName Network # @raycast.argument1 { "type": "text", "placeholder": "VPN host" } # @raycast.argument2 { "type": "password", "placeholder": "Password" } HOST="$1" PASS="$2" if [ -z "$HOST" ] || [ -z "$PASS" ]; then echo "Host and password are required" exit 1 fi echo "Connecting to $HOST..." # password field input is masked with asterisks in Raycast UI ``` -------------------------------- ### Troubleshoot Node.js Path in fmp.js Source: https://github.com/raycast/script-commands/blob/master/commands/apps/find-my/README.md If Raycast cannot find Node.js, update the shebang line in `fmp.js` with the full path to your Node.js executable. ```bash which node ``` ```sh #!/usr/bin/env node ``` ```sh #!/full/path/to/node ``` -------------------------------- ### Disk Usage Script Command Source: https://context7.com/raycast/script-commands/llms.txt A fullOutput mode script command to display disk usage summary and top 5 largest directories. It uses ANSI colors for headers. ```bash #!/bin/bash # @raycast.schemaVersion 1 # @raycast.title Disk Usage # @raycast.mode fullOutput # @raycast.packageName System # @raycast.icon 💾 echo -e "\033[33mDisk Usage Summary\033[0m" df -h | grep -E "^/dev|Filesystem" echo "" echo -e "\033[36mTop 5 largest directories in ~:\033[0m" du -sh ~/*/ 2>/dev/null | sort -rh | head -5 # Output: Full-screen view with colored headers and table ``` -------------------------------- ### Run Quip Script Command from Terminal Source: https://github.com/raycast/script-commands/blob/master/commands/apps/quip/README.org Execute a generated Quip script command directly from your terminal. This is useful for testing or running commands outside of Raycast. ```shell ./quip-new-note.py "New note title" ``` -------------------------------- ### Prettify JSON from Clipboard with Error Handling Source: https://context7.com/raycast/script-commands/llms.txt This script prettifies JSON content copied to the clipboard using `jq`. It includes error handling for missing `jq` dependency and empty or invalid JSON. ```bash #!/bin/bash # @raycast.schemaVersion 1 # @raycast.title Prettify JSON from Clipboard # @raycast.mode fullOutput # @raycast.packageName Developer Utils # Dependency: requires jq — brew install jq if ! command -v jq &>/dev/null; then echo "jq is required: brew install jq" exit 1 fi clipboard=$(pbpaste) if [ -z "$clipboard" ]; then echo "Clipboard is empty" exit 1 fi echo "$clipboard" | jq . || { echo "Invalid JSON in clipboard"; exit 1; } # Exit code 0 → success; exit code 1 → Raycast shows error toast # with the last echoed line as the message ``` -------------------------------- ### Template File Naming Convention Source: https://github.com/raycast/script-commands/blob/master/CONTRIBUTING.md Use the '.template.' suffix for scripts that require user modifications before execution. This prevents automatic parsing by Raycast and prompts users to customize the script. ```bash github-notifications.template.sh ``` -------------------------------- ### Display System Status with ANSI Color Output Source: https://context7.com/raycast/script-commands/llms.txt This script displays system status information (disk, RAM, uptime) using ANSI escape codes for colored and formatted text output in Raycast. ```bash #!/bin/bash # @raycast.schemaVersion 1 # @raycast.title System Status # @raycast.mode fullOutput # @raycast.packageName System RED='\033[31m' GREEN='\033[32m' YELLOW='\033[33m' CYAN='\033[36m' RESET='\033[0m' UNDERLINE='\033[4m' echo -e "${UNDERLINE}System Status${RESET}" echo -e "${GREEN}✅ Disk:${RESET} $(df -h / | awk 'NR==2{print $4}') free" echo -e "${YELLOW}⚠️ RAM:${RESET} $(memory_pressure | grep 'System-wide' | awk '{print $NF}')" echo -e "${CYAN}ℹ️ Uptime:${RESET} $(uptime | awk -F'up ' '{print $2}' | awk -F',' '{print $1}')" # 8-bit color example: echo -e "\033[38;5;208mOrange text\033[0m" # 24-bit (true color) example: echo -e "\033[38;2;255;100;0mCustom RGB text\033[0m" ``` -------------------------------- ### Define Custom Arguments for a Script Command Source: https://github.com/raycast/script-commands/blob/master/documentation/ARGUMENTS.md Use `argument[1..3]` metadata to specify custom arguments that will be displayed as inputs in the search bar when the script is selected. The value should be valid JSON with fields like `type`, `placeholder`, `optional`, and `percentEncoded`. ```bash #!/bin/bash # Required parameters: # @raycast.schemaVersion 1 # @raycast.title Search Flights # @raycast.mode silent # Optional parameters: # @raycast.icon 🛩 # @raycast.packageName Web Searches # @raycast.argument1 { "type": "text", "placeholder": "from city", "percentEncoded": true } # @raycast.argument2 { "type": "text", "placeholder": "to city", "optional": true, "percentEncoded": true } open "https://www.google.com/search?q=flights%20from%20$1%20to%20$2" ``` -------------------------------- ### Search Mullvad VPN Locations Source: https://github.com/raycast/script-commands/blob/master/commands/apps/mullvad/README.md Search for available countries, cities, and hostnames for Mullvad VPN connections. Use 'y' for the 'Show Hostnames?' argument to include hostnames in the output. Results are sorted by relevance. ```sh COUNTRIES: USA (us) Austria (at) Australia (au) United Arab Emirates (ae) CITIES: Salt Lake City, UT (slc) Brussels (bru) Dusseldorf (dus) Secaucus, NJ (uyk) Sao Paulo (sao) Budapest (bud) Bucharest (buh) HOSTNAMES: us-mia-201 (193.27.12.2) - OpenVPN, hosted by M247 us-nyc-201 (89.46.62.15) - OpenVPN, hosted by M247 us-nyc-202 (89.46.62.28) - OpenVPN, hosted by M247 us-nyc-203 (89.46.62.41) - OpenVPN, hosted by M247 us-nyc-204 (89.46.62.54) - OpenVPN, hosted by M247 ... ```