Skip to content

Associate various file extensions with a specified application on macOS

License

Notifications You must be signed in to change notification settings

AlanGabbianelli/associate-file-extensions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

Associate File Extensions

Purpose

This script is designed to associate various file extensions with a specified application on macOS. By default, it associates the file extensions with Visual Studio Code - Insiders (because that's what I use).

Dependencies

  • Homebrew
  • duti
  • The application to associate the file extensions with

Usage

  • To use the default editor (Visual Studio Code - Insiders), run:
    associate_file_extensions.sh
  • To use a different editor, run:
    associate_file_extensions.sh <app_name>
    where <app_name> is the name of an editor of your choice.

How it works

The script defines a few functions for printing colored text to the terminal. It then sets the HOMEBREW_NO_AUTO_UPDATE environment variable to prevent brew from auto-updating during installation. It installs duti via brew install duti if it's not already installed.

The script defines an array of file extensions to associate with the specified application. For each extension, it runs a duti command that associates the extension with the specified application.

The duti command has this syntax: duti -s <app_id> <extension> all, where <app_id> is the ID of the application to associate the file extension with, and <extension> is the file extension to associate. The all flag is used to associate the extension with all possible file types (e.g., public.json, public.text, etc.).

The script prints a yellow message to the terminal before running each duti command to let the user know what command is being executed. If the command is successful, it prints a green message. If the command fails, it prints a red error message.

Notes

To associate additional file extensions with the specified application, they can be added to the extensions array.

Credits

Highly inspired by Darragh ORiordan's article Set vscode as the default editor for text files on mac.

License

LICENSE

About

Associate various file extensions with a specified application on macOS

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages