Skip to content

Instantly share code, notes, and snippets.

@kabouzeid
Last active November 6, 2022 20:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kabouzeid/63c704e92943b690507af074d9067701 to your computer and use it in GitHub Desktop.
Save kabouzeid/63c704e92943b690507af074d9067701 to your computer and use it in GitHub Desktop.
Set the default text editor on macOS for all types of source code files. Credits go to https://alexpeattie.com/blog/associate-source-code-files-with-editor-in-macos-using-duti/
#!/usr/bin/env bash
# USAGE: ./set_default_editor.sh "visual studio code"
APP_ID=$(osascript -e "id of app \"$*\"") # eg com.microsoft.VSCode
curl "https://raw.githubusercontent.com/github/linguist/master/lib/linguist/languages.yml" \
| yq -r "to_entries | (map(.value.extensions) | flatten) - [null] | unique | .[]" \
| xargs -L 1 -I "{}" duti -s "${APP_ID}" {} all
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment