Skip to content

Instantly share code, notes, and snippets.

@osbre
Last active August 13, 2024 21:51
Show Gist options
  • Save osbre/f2dbb2d881d78b3a55b19f6e08fb081e to your computer and use it in GitHub Desktop.
Save osbre/f2dbb2d881d78b3a55b19f6e08fb081e to your computer and use it in GitHub Desktop.
# Install duti
echo "Installing duti..."
brew install duti
# Set Sublime Text 4 as default for various code and config formats
echo "Setting Sublime Text 4 as default for code and config formats..."
# Sublime Text 4 bundle identifier
SUBLIME_ID="com.sublimetext.4"
# Programming languages
prog_langs=(".py" ".java" ".c" ".cpp" ".h" ".hpp" ".cs" ".js" ".ts" ".html" ".css" ".php" ".rb" ".go" ".rust" ".swift" ".kt" ".scala" ".dart" ".lua" ".pl" ".r" ".sql" ".m" ".mm" ".sh" ".bash" ".zsh" ".fish")
# Markup and data formats
markup_data=(".xml" ".json" ".yaml" ".yml" ".toml" ".ini" ".csv" ".md" ".markdown" ".tex" ".rst" ".asciidoc")
# Config files
config_files=(".conf" ".cfg" ".config" ".properties" ".env" ".gitignore" ".gitconfig" ".npmrc" ".babelrc" ".eslintrc" ".prettierrc" ".stylelintrc" ".editorconfig")
# Web development
web_dev=(".jsx" ".tsx" ".vue" ".svelte" ".scss" ".sass" ".less" ".styl" ".pug" ".jade" ".haml" ".ejs" ".hbs" ".twig")
# Database
db_files=(".sqlite" ".db")
# Set Sublime Text 4 as default for all formats
for format in "${prog_langs[@]}" "${markup_data[@]}" "${config_files[@]}" "${web_dev[@]}" "${db_files[@]}"; do
duti -s "$SUBLIME_ID" "$format" all
echo "Set Sublime Text 4 as default for $format"
done
# Set Sublime Text 4 as default for files without extension (like Makefile, Dockerfile)
duti -s "$SUBLIME_ID" public.plain-text all
duti -s "$SUBLIME_ID" public.unix-executable all
echo "Sublime Text 4 has been set as the default editor for various code and config formats."
# Install duti
echo "Installing duti..."
brew install duti
# Set VLC as default for various media formats
echo "Setting VLC as default for media formats..."
# Video formats
video_formats=(".mp4" ".mov" ".avi" ".mkv" ".flv" ".wmv" ".m4v" ".mpg" ".mpeg" ".3gp" ".3g2" ".webm" ".ogv" ".ts" ".m2ts")
# Audio formats
audio_formats=(".mp3" ".wav" ".aac" ".m4a" ".flac" ".ogg" ".wma" ".aiff" ".alac" ".ac3" ".mka")
# Playlist formats
playlist_formats=(".m3u" ".m3u8" ".pls" ".cue")
# Set VLC as default for all formats
for format in "${video_formats[@]}" "${audio_formats[@]}" "${playlist_formats[@]}"; do
duti -s org.videolan.vlc "$format" all
echo "Set VLC as default for $format"
done
echo "VLC has been set as the default player for various media formats."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment