Created
June 13, 2023 22:36
-
-
Save Nicolas-Richard/d3e5757e39eeef933e01f33fb6816e09 to your computer and use it in GitHub Desktop.
Make all text files and code files open with Sublime on MacOS (using 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
| #!/bin/bash | |
| # You need https://github.com/moretension/duti (installable via `brew`) | |
| # and of course Sublime | |
| # Set the bundle identifier for Sublime Text | |
| sublime_bundle_identifier="com.sublimetext.4" | |
| # List of file extensions | |
| file_extensions=( | |
| # Text Files | |
| "txt" "rtf" "md" "markdown" "log" "csv" | |
| # Ruby | |
| "rb" "erb" "rake" "gemspec" "ru" "rhtml" | |
| # Python | |
| "py" "pyw" "pyc" "pyo" "pyd" "pyx" "pxd" "pxi" "scons" | |
| # Go | |
| "go" | |
| # Configuration Files | |
| "cfg" "conf" "ini" "yml" "yaml" "json" "toml" "xml" "properties" | |
| # Terraform | |
| "tf" "tfvars" "tfstate" | |
| # Kubernetes | |
| "yaml" "yml" | |
| # Shell scripts | |
| "sh" "bash" "zsh" "csh" "ksh" "fish" | |
| # Docker | |
| "dockerfile" | |
| # Ansible | |
| "ansible" | |
| # Java | |
| "java" "class" "jar" | |
| # JavaScript | |
| "js" "jsx" "ts" "tsx" | |
| # HTML/CSS | |
| "html" "htm" "css" "scss" "sass" | |
| # SQL | |
| "sql" | |
| # Git | |
| "gitignore" "gitattributes" | |
| # Other | |
| "xml" "plist" "csv" "ini" "env" "makefile" | |
| ) | |
| # Loop through each file extension and set Sublime Text as the default application | |
| for extension in "${file_extensions[@]}"; do | |
| duti -s "$sublime_bundle_identifier" .$extension all | |
| done | |
| echo "Default application set to Sublime Text for specified file extensions." |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
if you are tired of Xcode trying to open every file ...