Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Sublime Text 3 Context Menu
$Test = Test-path 'C:\Program Files\Sublime Text 3\sublime_text.exe'
If ($Test -eq $True) {
$st3Path = 'C:\Program Files\Sublime Text 3\sublime_text.exe'
} Else {
$st3Path = 'C:\Program Files (x86)\Sublime Text 3\sublime_text.exe'
}
# add it for all file types
Function FileTypes {
# Setting Path
$regpath = 'Registry::HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 3'
# Creating Keys
New-Item -Path "$regpath" -Force |
New-ItemProperty -name '(Default)' -Value 'Open with Sublime Text 3' -Type String -Force |
New-ItemProperty -Name 'Icon' -Value "$st3Path,0" -Type ExpandString -Force
New-Item -Path "$regpath\command" -Force |
New-ItemProperty -Name '(Default)' -Value "$st3Path `"%1`"" -Type String -Force
}
# add it for directories
Function Directories {
# Setting Path
$regpath = 'Registry::HKEY_CLASSES_ROOT\Directory\shell\Open with Sublime Text 3'
# Creating Keys
New-Item -Path "$regpath" -Force |
New-ItemProperty -Name '(Default)' -Value 'Open with Sublime Text 3' -Type String -Force |
New-ItemProperty -Name 'Icon' -Value "$st3Path,0" -Type ExpandString -Force
New-Item -Path "$regpath\command" -Force |
New-ItemProperty -Name '(Default)' -Value "$st3Path `"%1`"" -Type String -Force
# Setting Path
$regpath = 'Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Directory\Background\shell\Open with Sublime Text 3'
# Creating Keys
New-Item -Path "$regpath" -Force |
New-ItemProperty -Type String -Name '(Default)' -Value 'Open with Sublime Text 3' -Force |
New-ItemProperty -Type ExpandString -Name 'Icon' -Value "$st3Path,0" -Force
New-Item -Path "$regpath\command" -Force |
New-ItemProperty -Type String -Name '(Default)' -Value "$st3Path `"%v`"" -Force
}
# add it for folders
Function Folders {
$regpath = 'Registry::HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text 3'
New-Item -Path "$regpath" -Force |
New-ItemProperty -Name '(Default)' -Value 'Open with Sublime Text 3' -Type String -Force |
New-ItemProperty -Name 'Icon' -Value "$st3Path,0" -Type ExpandString -Force
New-Item -Path "$regpath\command" -Force |
New-ItemProperty -Name '(Default)' -Value "$st3Path `"%1`"" -Type String -Force
}
# Script
Clear-Host
FileTypes
Directories
Folders
@HellfireXD

This comment has been minimized.

Copy link
Owner Author

commented Feb 24, 2016

If you have any suggestions or requests let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.