feat(cursor): add setup script to symlink config and manage extensions

This commit is contained in:
2025-02-19 19:10:51 +00:00
parent 7064604079
commit 03eb561f1f
2 changed files with 185 additions and 0 deletions

43
cursor/extensions.txt Normal file
View File

@@ -0,0 +1,43 @@
# Cursor Extensions
# Generated on Wed Feb 19 19:05:55 GMT 2025
alefragnani.project-manager
antiantisepticeye.vscode-color-picker
arahata.linter-actionlint
bibhasdn.unique-lines
bodil.file-browser
carlos-algms.make-task-provider
connorshea.vscode-ruby-test-adapter
ctf0.macros
dnut.rewrap-revived
efbenson.scad
fnando.linter
foxundermoon.shell-format
github.remotehub
github.vscode-github-actions
github.vscode-pull-request-github
gofenix.go-lines
golang.go
gruntfuggly.todo-tree
hbenl.vscode-test-explorer
kahole.magit
karunamurti.haml
ms-azuretools.vscode-docker
ms-kubernetes-tools.vscode-kubernetes-tools
ms-vscode-remote.remote-containers
ms-vscode.remote-repositories
ms-vscode.test-adapter-converter
redhat.vscode-yaml
rrudi.vscode-dired
rust-lang.rust-analyzer
shan.code-settings-sync
shopify.ruby-extensions-pack
shopify.ruby-lsp
sorbet.sorbet-vscode-extension
sumneko.lua
swellaby.vscode-rust-test-adapter
tamasfe.even-better-toml
tuttieee.emacs-mcx
viktorzetterstrom.non-breaking-space-highlighter
wenhoujx.swiper
zhuangtongfa.material-theme

142
cursor/setup.sh Executable file
View File

@@ -0,0 +1,142 @@
#! /usr/bin/env bash
# Define source directory
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
_CURSOR_CONFIG_DIR=""
# Determine OS and set config directory
cursor_config_dir() {
if [[ -n "${_CURSOR_CONFIG_DIR}" ]]; then
echo "${_CURSOR_CONFIG_DIR}"
return
fi
case "$(uname -s)" in
"Darwin")
_CURSOR_CONFIG_DIR="${HOME}/Library/Application Support/Cursor/User"
;;
"Linux")
_CURSOR_CONFIG_DIR="${HOME}/.config/Cursor/User"
;;
*)
echo "Error: Unsupported operating system"
exit 1
;;
esac
echo "${_CURSOR_CONFIG_DIR}"
}
# Function to backup and symlink
backup_and_link() {
local source="$1"
local target="$2"
# Check if target already exists
if [[ -e "${target}" ]]; then
# If it's a symlink, check if it points to the same location
if [[ -L "${target}" ]]; then
local current_target
current_target="$(readlink "${target}")"
if [[ "${current_target}" == "${source}" ]]; then
echo "Skipping ${target} - already linked to ${source}"
return
fi
fi
echo "Backing up existing ${target} to ${target}.bak"
mv "${target}" "${target}.bak"
fi
# Create symlink
echo "Creating symlink for ${source} to ${target}"
ln -s "${source}" "${target}"
}
# Function to create symlinks
do_symlink() {
# Create Cursor config directory if it doesn't exist
local config_dir
config_dir="$(cursor_config_dir)"
mkdir -p "${config_dir}"
# Backup and symlink settings.json
backup_and_link "${SCRIPT_DIR}/settings.json" "${config_dir}/settings.json"
# Backup and symlink keybindings.json
backup_and_link "${SCRIPT_DIR}/keybindings.json" "${config_dir}/keybindings.json"
# Backup and symlink snippets directory
backup_and_link "${SCRIPT_DIR}/snippets" "${config_dir}/snippets"
echo "Symlink setup complete!"
}
# Replace do_dump_extensions function:
do_dump_extensions() {
if ! command -v cursor >/dev/null 2>&1; then
echo "Error: cursor command not found"
exit 1
fi
local extensions_file="${SCRIPT_DIR}/extensions.txt"
local current_date
current_date="$(date)"
{
echo "# Cursor Extensions"
echo "# Generated on ${current_date}"
echo
cursor --list-extensions
} >"${extensions_file}"
echo "Extensions list dumped to ${extensions_file}"
}
# Function to install extensions
do_install_extensions() {
local extensions_file="${SCRIPT_DIR}/extensions.txt"
if [[ ! -f "${extensions_file}" ]]; then
echo "Error: ${extensions_file} not found"
exit 1
fi
# Read extensions file, skip comments and empty lines
while IFS= read -r line; do
if [[ -n "${line}" && ! "${line}" =~ ^# ]]; then
echo "Installing extension: ${line}"
cursor --install-extension "${line}"
fi
done <"${extensions_file}"
echo "Extensions installation complete!"
}
# Help message function
show_help() {
echo "Available commands: symlink (or link), dump-extensions, install-extensions"
}
# Main command handler
case "${1:-}" in
"symlink" | "link")
do_symlink
;;
"dump-extensions" | "dump")
do_dump_extensions
;;
"install-extensions" | "install")
do_install_extensions
;;
"")
echo "Error: No command provided"
show_help
exit 1
;;
*)
echo "Error: Unknown command '$1'"
show_help
exit 1
;;
esac