Skip to content

πŸŽ‰ One-click solution to set VSCode or Cursor as the default application for development files.

License

Notifications You must be signed in to change notification settings

luoling8192/defaults-to-vscode

Repository files navigation

πŸš€ VSCode Default App Setter

One-click solution to set VSCode as the default application for development files.

Now, you can also set Cursor as the default application for development files.

✨ Features

  • πŸ”„ Automatically detect all file types supported by VSCode
  • 🎯 Set VSCode as default app with one click
  • πŸ“ Support common programming languages and config files
  • πŸ“Š Display setting results statistics
  • ⚑️ Fast and efficient batch processing

πŸ“‹ Supported File Types

Including but not limited to:

  • πŸ’» Programming Languages

    • Python (.py)
    • JavaScript/TypeScript (.js, .ts)
    • HTML/CSS (.html, .css)
    • Java (.java)
    • C/C++ (.c, .cpp)
    • Go (.go)
    • Rust (.rs)
  • πŸ“„ Configuration Files

    • JSON (.json)
    • YAML (.yml, .yaml)
    • XML (.xml)
    • INI (.ini)
    • Config (.conf)
  • πŸ“ Text Files

    • Plain Text (.txt)
    • Markdown (.md)
    • Log Files (.log)

πŸ›  Prerequisites

macOS

  • macOS system
  • VSCode installed
  • duti installed

Windows

  • Windows 10/11
  • VSCode or Cursor installed
  • PowerShell 5.0+
  • Administrator privileges

πŸ“¦ Installation

macOS

Install duti (if not already installed):

brew install duti

windows

It is not necessary.

πŸš€ Usage

macOS

Set VSCode as default application

Simply run the script:

bash -c "$(curl -fsSL https://raw.githubusercontent.com/luoling8192/defaults-to-vscode/HEAD/set_vscode_defaults.sh)"

Set Cursor as default application

Simply run the script:

bash -c "$(curl -fsSL https://raw.githubusercontent.com/luoling8192/defaults-to-vscode/HEAD/set_cursor_defaults.sh)"

Windows

Method 1: Local Installation (Recommended)

  1. Download the script file

    • For VSCode: Download set_vscode_defaults_win.ps1
    • For Cursor: Download set_cursor_defaults_win.ps1
  2. Run PowerShell as Administrator

    • Right-click PowerShell
    • Select "Run as Administrator"
  3. Navigate to script directory

cd "path\to\script\folder"
  1. Set execution policy and run script
# Allow script execution
Set-ExecutionPolicy Bypass -Scope Process -Force

# Run VSCode script
.\set_vscode_defaults_win.ps1

# Or run Cursor script
.\set_cursor_defaults_win.ps1

Method 2: Remote Installation

Set VSCode as Default
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/luoling8192/defaults-to-vscode/main/set_vscode_defaults_win.ps1'))
Set Cursor as Default
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/luoling8192/defaults-to-vscode/main/set_cursor_defaults_win.ps1'))

πŸ“Š Output Example

Setting VSCode as default application for all supported file types...
Setting default application for UTI: public.plain-text
βœ“ Success: public.plain-text
Setting default application for UTI: public.python-script
βœ“ Success: public.python-script
...
Operation completed!
Successfully set: 42
Failed: 3

⚠️ Troubleshooting

macOS

  • If you get permission errors, try running with sudo
  • Make sure VSCode is installed in the default location
  • Check if duti is properly installed

Windows

Common Issues

  1. Execution Policy Error

    Set-ExecutionPolicy Bypass -Scope Process -Force
  2. Application Not Found

    • Ensure VSCode/Cursor is properly installed
    • VSCode default installation paths:
  3. Insufficient Permissions

    • Ensure PowerShell is run as Administrator
    • Check user account permissions
  4. Download Failure

    • Check network connection
    • Try local installation method

Recovery Options

  • Script creates backups in registry_backups folder
  • Double-click backup file to restore
  • Or manually set in Control Panel

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

  • duti for providing the command-line tool
  • The VSCode team for the amazing editor

πŸ” Note

Some file associations might fail due to system restrictions or invalid UTIs. This is normal behavior and won't affect the overall functionality.

πŸ“¬ Contact

If you have any questions or suggestions, please open an issue in the repository.


Made with ❀️ for developers who love VSCode

Star History Chart

About

πŸŽ‰ One-click solution to set VSCode or Cursor as the default application for development files.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •