Skip to content

Instantly share code, notes, and snippets.

@Hazer
Last active November 17, 2024 04:45
Show Gist options
  • Save Hazer/d5c0c2fb65ec5891d61a010fe7724b95 to your computer and use it in GitHub Desktop.
Save Hazer/d5c0c2fb65ec5891d61a010fe7724b95 to your computer and use it in GitHub Desktop.
Set default editor macOS
# Zed
defaults write com.apple.LaunchServices/com.apple.launchservices.secure LSHandlers -array-add '{LSHandlerContentType=public.plain-text;LSHandlerRoleAll=dev.zed.Zed;}'
# Sublime Text 4
defaults write com.apple.LaunchServices/com.apple.launchservices.secure LSHandlers -array-add '{LSHandlerContentType=public.plain-text;LSHandlerRoleAll=com.sublimetext.4;}'
# Sublime Text 3
defaults write com.apple.LaunchServices/com.apple.launchservices.secure LSHandlers -array-add '{LSHandlerContentType=public.plain-text;LSHandlerRoleAll=com.sublimetext.3;}'
# VS Code
defaults write com.apple.LaunchServices/com.apple.launchservices.secure LSHandlers -array-add '{LSHandlerContentType=public.plain-text;LSHandlerRoleAll=com.microsoft.VSCode;}'
#### ===
# Can also set default editor for terminal, with the following:
# Set Zed for preferred editor for local and nano for remote sessions
if [[ -n $SSH_CONNECTION ]]; then
# If remote, we use nano
export EDITOR='nano'
else
export EDITOR='zed' # must have zed cli installed
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment