Skip to content

Instantly share code, notes, and snippets.

@joeblackwaslike
Created August 14, 2025 01:49
Show Gist options
  • Save joeblackwaslike/802b9ddc135ba85d31a14b21b341807a to your computer and use it in GitHub Desktop.
Save joeblackwaslike/802b9ddc135ba85d31a14b21b341807a to your computer and use it in GitHub Desktop.
This script can be used to automate the installation of extensions from the cursor marketplace. The `--input-file` option should be used to point to a text file containing a list of cursor extensionIds one per line. The default path when not provided is `cursor-exts.txt`.
#!/usr/bin/env bash
# ============================================================================
# Maintainer: Joe Black
# Contact: https://github.com/joeblackwaslike
#
# Copyright (c) 2025 Joe Black
#
# License: MIT
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
# In short: Do what you want, just credit Joe Black. For questions, suggestions,
# or contributions, reach out via GitHub.
# ============================================================================
# Function to display usage/help message
show_usage() {
local script_name="$(basename "$0")"
echo "Usage: $script_name [--input-file <file>]"
echo -e "\n--input-file <file>: Path to a file containing one Cursor/VS Code extension ID per line (default: cursor-exts.txt)."
echo -e "\nThis script installs the latest extension from the cursor marketplace for each extension ID listed in the input file."
}
# Function to display error and usage, then exit
error_and_usage() {
echo "Error: $1"
show_usage
exit 1
}
# Default values for CLI flags
input_file="cursor-exts.txt"
# Parse arguments
if [[ "$1" == "--help" ]]; then
show_usage
exit 0
fi
# Parse CLI flags
while [[ $# -gt 0 ]]; do
case "$1" in
--input-file)
input_file="$2"
shift 2
;;
*)
error_and_usage "Unknown argument: $1"
;;
esac
done
# Check if input file exists
if [[ ! -f "$input_file" ]]; then
error_and_usage "File '$input_file' not found!"
fi
# Read file line by line and process each extension ID
while IFS= read -r extensionId; do
# Skip empty lines and lines starting with # (comments)
if [[ -z "$extensionId" || "$extensionId" =~ ^# ]]; then
continue
fi
# Validate extensionId format (should be publisher.name)
if ! [[ "$extensionId" =~ ^[^.]+\.[^.]+$ ]]; then
echo "Warning: Skipping invalid extension ID: $extensionId"
continue
else
echo "Installing extension from cursor marketplace: $extensionId"
cursor --install-extension "$extensionId"
fi
done < "$input_file"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment