Skip to content

Instantly share code, notes, and snippets.

@Nicolas-Richard
Created June 13, 2023 22:36
Show Gist options
  • Select an option

  • Save Nicolas-Richard/d3e5757e39eeef933e01f33fb6816e09 to your computer and use it in GitHub Desktop.

Select an option

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)
#!/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."
@Nicolas-Richard

Copy link
Copy Markdown
Author

if you are tired of Xcode trying to open every file ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment