Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 123 lines (123 sloc) 3.928 kb
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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
New-PsDrive -Name Mod -PSProvider FileSystem -Root (($env:PSMODULEPATH -split ";")[0])
Import-Module ISEPack
Set-Alias Open PowerShell_ise

<#
This function is now built-in to the editor so it is no longer needed.
I'm keeping it here so you can see how it works.
function GoTo-Line
{
$ed = $psise.CurrentOpenedFile.Editor
[int]$l = read-host
if ($l -le $ed.LineCount)
{
$ed.SetCaretPosition($l,1)
}
else
{O
$ed.SetCaretPosition($ed.LineCount,1)
}
}
#>
function Edit-Selected
{
    $ed = $psise.CurrentOpenedFile.Editor
    PowerShell_ise $ed.SelectedText
}

function global:Export-SessionFiles
{
    $psise.CurrentOpenedRunspace.OpenedFiles |%{
       if (!$_.isSaved)
       {
           $title = "Save File?"
           $message = "Do you want to Save `n`t$($_.FullPath)`nbefore exporting?"

           $yes = New-Object System.Management.Automation.Host.ChoiceDescription "&Yes", `
                "Save $($_.FullPath)."

           $no = New-Object System.Management.Automation.Host.ChoiceDescription "&No", `
                "Export but do not save $($_.fullpath)."

           $options = [System.Management.Automation.Host.ChoiceDescription[]]($yes, $no)

           if (($host.ui.PromptForChoice($title, $message, $options, 0)) -eq 0)
           {
               $_.Save()
           }
       }
       $psise.CurrentOpenedRunspace.Output.InsertText("`nExporting $($_.FullPath)")
        $_.FullPath
    } > ~/ISE-SessionFiles.txt
}

function Import-SessionFiles
{
    cat ~/ISE-SessionFiles.txt | %{ $psise.CurrentOpenedRunspace.OpenedFiles.add($_) }
}

$null = $psISE.CustomMenu.Submenus.Add("Edit Selected", {Edit-Selected}, 'Ctrl+E')
$null = $psISE.CustomMenu.Submenus.Add("Export Session Files", {Export-SessionFiles}, 'Ctrl+SHIFT+E')
$null = $psISE.CustomMenu.Submenus.Add("Import Session Files", {Import-SessionFiles}, 'Ctrl+SHIFT+I')






























































Something went wrong with that request. Please try again.