Skip to content

Instantly share code, notes, and snippets.

@anthony-dandrea
Created February 23, 2025 23:17
Show Gist options
  • Save anthony-dandrea/ff5f8f2cf58dfb9bf89cfd56fe1ca4e6 to your computer and use it in GitHub Desktop.
Save anthony-dandrea/ff5f8f2cf58dfb9bf89cfd56fe1ca4e6 to your computer and use it in GitHub Desktop.
Default browser & apps
#!/bin/bash
# For setting default browser and apps for file types.
# Run with `sudo ./defaultApps
# Notes:
# - Requires `duti` to be installed: `brew install duti`
# - To find app IDs, run: `osascript -e 'id of app "<AppName>"'`
# - To get currently set app ID for a file: `mdls -name kMDItemContentType <file.ext>`
# - Make sure file is executable: `chmod +x defaultApps.sh`
# Step 1: Set default browser
DEFAULT_BROWSER="com.brave.Browser"
duti -s "$DEFAULT_BROWSER" public.url all
duti -s "$DEFAULT_BROWSER" http all
duti -s "$DEFAULT_BROWSER" https all
echo "Set default browser ✅"
# Step 2: Set default apps
DEFAULT_CODE_APP="com.microsoft.VSCode"
CODE_EXT_LIST="js jsx ts tsx java scala go py rb php css scss less json yaml yml xml sh bat cmd ps1 sql swift kt kts groovy gradle properties ini conf cfg log txt csv tsv md markdown rst r rmd rdata rproj rhistory rprofile rdb rds rda public.plain-text public.source-code public.json public.yaml"
for ext in $CODE_EXT_LIST; do
duti -s "$DEFAULT_CODE_APP" "$ext" all
done
echo "Set extensions ✅"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment