-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #170 from StartAutomating/Posh-Tips-And-Tricks
Posh 0.1.3 - Posh Tips and Tricks
- Loading branch information
Showing
84 changed files
with
2,416 additions
and
203 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
Write-FormatView -TypeName n/a -Name "Posh.Link" -AsControl -Action { | ||
@( | ||
if ($_.Name -and $_.Url) { | ||
if ($psStyle.FormatHyperlink -and -not $env:GITHUB_WORKSPACE) { | ||
$psStyle.FormatHyperlink($_.Name, $_.Url) | ||
} else { | ||
"[$($_.Name)]($($_.Url))" | ||
} | ||
} elseif ($_.Url) { | ||
$uri = [uri]$_.Url | ||
if ($psStyle.FormatHyperlink -and -not $env:GITHUB_WORKSPACE) { | ||
$psStyle.FormatHyperlink($_.Url, $uri) | ||
} else { | ||
"[$($_.Url)]($($uri))" | ||
} | ||
} | ||
) -join '' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Write-FormatView -TypeName Posh.Module.Link -Action { | ||
Write-FormatViewExpression -ScriptBlock { $_ } -ControlName Posh.Link | ||
} -GroupByProperty Source | ||
|
||
Write-FormatView -TypeName Posh.Module.Link -Property Name, Url -GroupByProperty Source |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,5 @@ | ||
Write-FormatView -TypeName Posh.Module.Screenshot -Action { | ||
@( | ||
if ($_.Name -and $_.Url) { | ||
if ($psStyle.FormatHyperlink -and -not $env:GITHUB_WORKSPACE) { | ||
$psStyle.FormatHyperlink($_.Name, $_.Url) | ||
} else { | ||
"![$($_.Name)]($($_.Url))" | ||
} | ||
} elseif ($_.Url) { | ||
$uri = [uri]$_.Url | ||
if ($psStyle.FormatHyperlink -and -not $env:GITHUB_WORKSPACE) { | ||
$psStyle.FormatHyperlink($_.Url, $uri) | ||
} else { | ||
"![$($_.Url)]($($uri))" | ||
} | ||
} | ||
) -join '' | ||
Write-FormatViewExpression -ScriptBlock { $_ } -ControlName Posh.Link | ||
} -GroupByProperty Source | ||
|
||
Write-FormatView -TypeName Posh.Module.Screenshot -Property Name, Url -GroupByProperty Source |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,5 @@ | ||
Write-FormatView -TypeName Posh.Module.Video -Action { | ||
@( | ||
if ($_.Name -and $_.Url) { | ||
if ($psStyle.FormatHyperlink -and -not $env:GITHUB_WORKSPACE) { | ||
$psStyle.FormatHyperlink($_.Name, $_.Url) | ||
} else { | ||
"[$($_.Name)]($($_.Url))" | ||
} | ||
} elseif ($_.Url) { | ||
$uri = [uri]$_.Url | ||
if ($psStyle.FormatHyperlink -and -not $env:GITHUB_WORKSPACE) { | ||
$psStyle.FormatHyperlink($_.Url, $uri) | ||
} else { | ||
"[$($_.Url)]($($uri))" | ||
} | ||
} | ||
) -join '' | ||
Write-FormatViewExpression -ScriptBlock { $_ } -ControlName Posh.Link | ||
} -GroupByProperty Source | ||
|
||
Write-FormatView -TypeName Posh.Module.Video -Property Name, Url -GroupByProperty Source |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Write-FormatView -TypeName Posh.Preset.Collection -Action { | ||
Write-FormatViewExpression -ScriptBlock { | ||
Show-Markdown -InputObject $_.README | ||
} | ||
|
||
Write-FormatViewExpression -Newline | ||
|
||
|
||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Write-FormatView -TypeName Posh.Tip.Collection -Action { | ||
Write-FormatViewExpression -Property Random -ControlName Posh.Tip.Control | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
Write-FormatView -TypeName Posh.Tip.Command -Action { | ||
Write-FormatViewExpression -ScriptBlock { $_ } -ControlName Posh.Tip.Control | ||
} | ||
|
||
Write-FormatView -TypeName n/a -Name Posh.Tip.Control -AsControl -Action { | ||
Write-FormatViewExpression -ScriptBlock { | ||
$showDemoCommand = $ExecutionContext.SessionState.InvokeCommand.GetCommand('Show-Demo', 'Function') | ||
if ($showDemoCommand -and $_.Content -is [scriptblock]) { | ||
Show-Demo -DemoScript $_.Content -AutoPlay | Out-Null | ||
} else { | ||
$_.Content | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
Write-FormatView -TypeName Microsoft.PowerShell.Commands.MatchInfo -Action { | ||
$matchInfo = $_ | ||
$isFileMatch = $matchInfo.Path -and ($matchInfo.Path -ne 'InputStream') | ||
$currentLocation = $ExecutionContext.SessionState.Path.CurrentLocation | ||
$relativePath = $matchInfo.RelativePath($currentLocation) | ||
$originalLine = $( | ||
if ($matchInfo.ToEmphasizedString) { | ||
$matchInfo.ToEmphasizedString($currentLocation) | ||
} elseif ($isFileMatch) { | ||
$matchInfo.ToString().Replace($matchInfo.Path, $relativePath) | ||
} else { | ||
$matchInfo.ToString() | ||
} | ||
) | ||
|
||
if ($PSStyle) { | ||
$PoshModule = $posh | ||
if ($isFileMatch) { | ||
# Match in a file item | ||
$colorTable = @( | ||
$PSStyle.Foreground.Green | ||
$PSStyle.Foreground.Yellow | ||
) | ||
|
||
$colorIndex = . $PoshModule { | ||
# Create a module scope variable | ||
if (-not $script:MatchInfoColorIndex) { | ||
$script:MatchInfoColorIndex = @{ | ||
index = 0 | ||
lastFilepath = $args[0] | ||
} | ||
} | ||
$script:MatchInfoColorIndex | ||
} $relativePath | ||
if ($colorIndex.lastFilepath -ne $relativePath) { | ||
$colorIndex.index = ($colorIndex.index + 1) % $colorTable.Count | ||
$colorIndex.lastFilepath = $relativePath | ||
} | ||
|
||
$color = $colorTable[$colorIndex.index] | ||
$coloredPath = $color + $relativePath + $PSStyle.Reset | ||
|
||
if ($PSStyle.FormatHyperlink -and -not $env:GITHUB_WORKSPACE) { | ||
$hyperLink = $PSStyle.FormatHyperlink($coloredPath, $matchInfo.Path) | ||
$originalLine.Replace($relativePath, $hyperLink) | ||
} else { | ||
$originalLine.Replace($relativePath, $coloredPath) | ||
} | ||
} else { | ||
# Match in a text input | ||
$originalLine | ||
} | ||
} else { | ||
$originalLine | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Write-FormatView -TypeName Microsoft.PowerShell.Commands.SelectXmlInfo -Property Node, Pattern -GroupByProperty "Path" |
Oops, something went wrong.