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.

Revisions

  1. Hazer revised this gist Nov 17, 2024. 1 changed file with 13 additions and 1 deletion.
    14 changes: 13 additions & 1 deletion default_editor.sh
    Original file line number Diff line number Diff line change
    @@ -8,4 +8,16 @@ defaults write com.apple.LaunchServices/com.apple.launchservices.secure LSHandle
    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;}'
    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
  2. Hazer created this gist Nov 17, 2024.
    11 changes: 11 additions & 0 deletions default_editor.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    # 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;}'