PoshCode Archive  Artifact Content

Artifact a9d1d4f666903dddc5e0fbd23677c5833f6e7a82bbed03054e26049af5b8e9b3:

  • File Start-Selected.ps1 — part of check-in [317f761a82] at 2018-06-10 12:56:49 on branch trunk — Usuallay I use this to start my browser with a URL in some PowerShell Script or retrieved by some Powershell Script. This is an ISE-Extension. (user: Bernd Kriszio size: 1097)

# encoding: ascii
# api: powershell
# title: Start-Selected
# description: Usuallay I use this to start my browser with a URL in some PowerShell Script or retrieved by some Powershell Script. This is an ISE-Extension.
# version: 0.1
# type: function
# author: Bernd Kriszio
# license: CC0
# function: Start-Selected
# x-poshcode-id: 1297
# x-archived: 2016-04-19T06:39:44
# x-published: 2010-08-28T07:19:00
#
#
#Hightlight the name of a file or URL and this will opened or shown in browser
if ($PSVersionTable.BuildVersion.build -le 7000)
{
    # PowerShell V2 CTP3
    function Start-Selected
    {
        $ed = $psise.CurrentOpenedFile.Editor
        start $ed.SelectedText
    }
}
else
{
    # PowerShell W7 
    function Start-Selected
    {
        $file = $psIse.CurrentPowerShellTab.Output.SelectedText
        if ($file -eq '')
        {
            $file = $psise.CurrentFile.Editor.SelectedText
        }
        if ($file)
        {
            start $file
        }    
    }
}
#Set-CustomMenu "Start Selected" {Start-Selected} 'Ctrl+Shift+S'