Skip to content

Instantly share code, notes, and snippets.

@mtvbrianking
Last active June 24, 2021 11:24
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 mtvbrianking/f5ae14af9a2e9d6d6618bcfef22ec83e to your computer and use it in GitHub Desktop.
Save mtvbrianking/f5ae14af9a2e9d6d6618bcfef22ec83e to your computer and use it in GitHub Desktop.
Windows sublime context menu
@echo off
SET sublPath=C:\Program Files\Sublime Text\sublime_text.exe
rem add context menu to all file types
@reg add "HKEY_CLASSES_ROOT\*\shell\Edit with Sublime Text" /t REG_SZ /v "" /d "Edit with Sublime Text" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Edit with Sublime Text" /t REG_EXPAND_SZ /v "Icon" /d "%sublPath%,0" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Edit with Sublime Text\command" /t REG_SZ /v "" /d "%sublPath% \"%%1\"" /f
rem add context menu to folders
@reg add "HKEY_CLASSES_ROOT\Directory\shell\Open with Sublime Text" /t REG_SZ /v "" /d "Open with Sublime Text" /f
@reg add "HKEY_CLASSES_ROOT\Directory\shell\Open with Sublime Text" /t REG_EXPAND_SZ /v "Icon" /d "%sublPath%,0" /f
@reg add "HKEY_CLASSES_ROOT\Directory\shell\Open with Sublime Text\command" /t REG_SZ /v "" /d "%sublPath% \"%%1\"" /f
rem add context menu to current folder
@reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\Background\shell\Open in Sublime Text" /t REG_SZ /v "" /d "Open in Sublime Text" /f
@reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\Background\shell\Open in Sublime Text" /t REG_EXPAND_SZ /v "Icon" /d "%sublPath%,0" /f
@reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\Background\shell\Open in Sublime Text\command" /t REG_SZ /v "" /d "%sublPath% \"%%v\"" /f
pause
@echo off
rem remove context menu from all file types
@reg delete "HKEY_CLASSES_ROOT\*\shell\Edit with Sublime Text" /f
rem remove context menu from folders
@reg delete "HKEY_CLASSES_ROOT\Directory\shell\Open with Sublime Text" /f
rem remove context menu from current folder
@reg delete "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\Background\shell\Open in Sublime Text" /f
pause
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment