Last active
June 24, 2025 13:06
-
-
Save PaulRBerg/12461cf852e852dc257a31211b91213d to your computer and use it in GitHub Desktop.
Script to set Cursor as the default editor for all development file extensions on macOS using duti: https://github.com/moretension/duti/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env zsh | |
# Set up the default application for file types. | |
# Strict mode: https://gist.github.com/vncsna/64825d5609c146e80de8b1fd623011ca | |
set -euo pipefail | |
# grab Cursor's bundle-ID | |
BUNDLE_ID=$(osascript -e 'id of app "Cursor"') | |
# Extensions in alphabetical order | |
EXTENSIONS=( | |
bash | |
c | |
cc | |
conf | |
cpp | |
css | |
csv | |
cxx | |
dockerfile | |
dockerignore | |
editorconfig | |
env | |
eslintrc | |
gitignore | |
go | |
gql | |
graphql | |
h | |
hpp | |
ini | |
java | |
js | |
jsx | |
json | |
jsonc | |
just | |
lock | |
log | |
mdc | |
md | |
mdx | |
mjs | |
mts | |
php | |
prisma | |
proto | |
py | |
rb | |
rs | |
sass | |
sh | |
sol | |
sql | |
svg | |
toml | |
ts | |
tsx | |
txt | |
xml | |
yaml | |
yml | |
zsh | |
) | |
# Check if duti is installed, if not, install it using Homebrew | |
if ! command -v duti >/dev/null 2>&1; then | |
echo "duti not found. Installing with Homebrew..." | |
brew install duti | |
fi | |
# Generate the duti configuration file | |
# Format: <bundle-id> <extension> <role> | |
# Example: com.todesktop.230313mzl4w4u92 .js all | |
{ | |
# Loop through each file extension | |
for ext in "${EXTENSIONS[@]}"; do | |
# Print each line in the format: bundle-id<tab>.<extension><tab>all | |
printf "%s\t.%s\tall\n" "$BUNDLE_ID" "$ext" | |
done | |
} > ~/.duti | |
# apply the new defaults | |
duti ~/.duti |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment