Skip to content

Instantly share code, notes, and snippets.

@pstoev
Last active August 30, 2019 03:24
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save pstoev/feaf7797cd795cff72a5 to your computer and use it in GitHub Desktop.
Save pstoev/feaf7797cd795cff72a5 to your computer and use it in GitHub Desktop.
@echo off
rem Based on a gist for adding sublime text 2:
rem https://gist.github.com/mrchief/5628677
SET st3Path=C:\Program Files\Sublime Text 3\sublime_text.exe
rem add it for all file types
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with ST3" /t REG_SZ /v "" /d "Open with ST3" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with ST3" /t REG_EXPAND_SZ /v "Icon" /d "%st3Path%,0" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with ST3\command" /t REG_SZ /v "" /d "%st3Path% \"%%1\"" /f
rem add it for folders
@reg add "HKEY_CLASSES_ROOT\Folder\shell\Open with ST3" /t REG_SZ /v "" /d "Open with ST3" /f
@reg add "HKEY_CLASSES_ROOT\Folder\shell\Open with ST3" /t REG_EXPAND_SZ /v "Icon" /d "%st3Path%,0" /f
@reg add "HKEY_CLASSES_ROOT\Folder\shell\Open with ST3\command" /t REG_SZ /v "" /d "%st3Path% \"%%1\"" /f
@reg add "HKEY_CLASSES_ROOT\directory\background\shell\Open with ST3" /t REG_SZ /v "" /d "Open with ST3" /f
@reg add "HKEY_CLASSES_ROOT\directory\background\shell\Open with ST3" /t REG_EXPAND_SZ /v "Icon" /d "%st3Path%,0" /f
@reg add "HKEY_CLASSES_ROOT\directory\background\shell\Open with ST3\command" /t REG_SZ /v "" /d "%st3Path% \"%%V\"" /f
pause
@Atid-Gharbi
Copy link

Hi, it works fine with files, but with folders it opens 2 sublime text windows. Any idea how to fix this? I'm on windows 10

@TechplexEngineer
Copy link

@Atid-G The reason you are seeing two Sublime windows open is because you have a feature called Hot Exit enabled. This lets you exit Sublime and have it remember the state of your open files.

The way I got around this issue is to add the following two options to the Preferences.sublime-settings file

    "remember_open_files": false,
    "hot_exit": false

Incase you don't know Preferences.sublime-settings lives in your sublime user directory. To access this Open Sublime, click Preferences, then Browse Packages.., then double click the User folder. Here is where you should create Preferences.sublime-settings if it doesn't already exist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment