-
-
Notifications
You must be signed in to change notification settings - Fork 19
/
Microsoft.PowerShellISE_profile.ps1
53 lines (45 loc) · 2.22 KB
/
Microsoft.PowerShellISE_profile.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#*************************************************************************************************
# Microsoft.PowerShell_profile.ps1 22 Jun 2013
#*************************************************************************************************
$script:shell = 'PowerShell'
if ($PSVersionTable.PSVersion.Major -lt 6) { $script:shell = 'WindowsPowerShell' }
$modules = Join-Path ([Environment]::GetFolderPath([Environment+SpecialFolder]::MyDocuments)) "$shell\Modules"
if (!$env:PSModulePath.Contains($modules)) { $env:PSModulePath = $modules + ";" + $env:PSModulePath }
Import-Module -Global -Name Addons.psd1
function AddMenuItem ($menu, $displayName, $action, $shortcut)
{
$item = $menu | ? { $_.DisplayName.Equals($displayName) }
if (!$item)
{
#Write-Host ... adding $displayName item
$menu.Add($displayName, $action, $shortcut) | Out-Null
}
else
{
#Write-Host ... $displayName item already exists
}
}
# Add-ons menu
$rootMenu = $psISE.CurrentPowerShellTab.AddOnsMenu.SubMenus
# Add-ons\Editor menu
$editMenu = ($rootMenu | ? { $_.DisplayName.Equals("Editor") })
if (!$editMenu)
{
$editMenu = $rootMenu.Add("Editor", $null, $null).SubMenus
AddMenuItem $editMenu "Close file" { Close-CurrentFile } "Alt+X"
AddMenuItem $editMenu "Copy colorized" { Copy-Colorized } "Alt+C"
AddMenuItem $editMenu "Make uppercase" { ConvertTo-Case -Upper } "Alt+U"
AddMenuItem $editMenu "Make lowercase" { ConvertTo-Case } "Alt+Shift+U"
AddMenuItem $editMenu "Set writable" { Set-FileWritable } "Alt+W"
AddMenuItem $editMenu "Sign File" { Write-Signature } "Alt+S"
}
Remove-variable 'editMenu'
# Add-ons menu items
AddMenuItem $rootMenu "Reset All Modules" { Reset-AllModules } "Alt+R"
AddMenuItem $rootMenu "Set ExecPol AllSigned" { Set-ExecutionPolicy allsigned } $null
AddMenuItem $rootMenu "Set ExecPol Unrestricted" { Set-ExecutionPolicy unrestricted } $null
AddMenuItem $rootMenu "Show Tab Filenames" { Get-IseFilenames } "Alt+F"
AddMenuItem $rootMenu "Open PS Profile" { Open-Profile } "Alt+O"
Remove-variable 'rootMenu'
# load the preferred theme
. Join-Path ([IO.Path]::GetDirectoryName($profile)) "\Themes\PSTheme_Selenitic.ps1" | Out-Null