Last active
August 25, 2024 21:06
-
-
Save lottamus/582cfcd873e4be5c8cc5283819f749fe to your computer and use it in GitHub Desktop.
Set cursor.app as the default application for file extensions
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
| #!/bin/bash | |
| # Function to check if duti is installed | |
| check_duti() { | |
| if ! command -v duti &> /dev/null; then | |
| echo "duti is not installed. Installing duti..." | |
| if command -v brew &> /dev/null; then | |
| brew install duti | |
| else | |
| echo "Homebrew is not installed. Please install Homebrew first." | |
| exit 1 | |
| fi | |
| else | |
| echo "duti is already installed." | |
| fi | |
| } | |
| # Check and install duti if necessary | |
| check_duti | |
| # Retrieve the bundle ID for the Cursor app | |
| cursorBundleID=$(osascript -e 'id of app "Cursor"') | |
| # List of file extensions | |
| extensions=("ts" "tsx" "js" "jsx" "css" "json" "yaml" "yml" "mdx" "md" "env" "sh") | |
| # Loop through each extension and set Cursor as the default app | |
| echo "Setting Cursor as the default application for the following extensions:" | |
| for ext in "${extensions[@]}"; do | |
| echo ".$ext" | |
| duti -s $cursorBundleID .$ext all | |
| done | |
| echo "Setting Cursor as the default editor for git" | |
| git config --global core.editor "cursor --wait" | |
| echo "Done!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment