Skip to content

Instantly share code, notes, and snippets.

@zacwest
Last active December 5, 2022 22:51
Show Gist options
  • Save zacwest/daa6361c370224cb22b50d38132f932e to your computer and use it in GitHub Desktop.
Save zacwest/daa6361c370224cb22b50d38132f932e to your computer and use it in GitHub Desktop.
Associate Sublime Text with various programming file extensions
#!/bin/bash
if ! command -v duti &> /dev/null; then
brew install duti
fi
declare -a extensions=(
## uti-based
public.plain-text
public.source-code
public.unix-executable
public.data # this is generic `.gitignore`-esque extensionless things
## extensions
.adl
.aspx
.atom
.bash
.bat
.bzl
.c
.c++
.cc
.cfg
.cl
.cmake
.coffee
.cpp
.css
.csv
.cxx
.d
.diff
.dtd
.ejs
.el
.elm
.erb
.fish
.go
.gradle
.groovy
.h
.h++
.haml
.hh
.hpp
.hs
.htm
.html
.hxml
.hxx
.ini
.java
.js
.json
.jsp
.jsx
.kt
.less
.lhs
.lisp
.lm
.m
.markdown
.md
.mk
.mkd
.mm
.patch
.php
.php3
.php4
.php5
.phtml
.pl
.plist
.pm
.properties
.proto
.py
.pyw
.rb
.rss
.rst
.sas
.sass
.scala
.scss
.sh
.spec
.sql
.svg
.swift
.tcl
.text
.textile
.toml
.tpl
.ts
.tsv
.tsx
.txt
.vb
.vbs
.vhd
.vhdl
.xml
.xsd
.xsl
.yaml
.ym
.yml
)
for extension in ${extensions[@]}; do
duti -s com.sublimetext.4 $extension all
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment