Skip to content

Instantly share code, notes, and snippets.

@HellfireXD
Created February 24, 2016 17:55
Show Gist options
  • Save HellfireXD/7f8c5a0845a44dfa9e7d to your computer and use it in GitHub Desktop.
Save HellfireXD/7f8c5a0845a44dfa9e7d to your computer and use it in GitHub Desktop.
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
Copy link
Author

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