Last active
September 2, 2023 11:34
-
-
Save mdgrs-mei/327d543bab91116471191c37d68268e2 to your computer and use it in GitHub Desktop.
Format file to add links to Select-String outputs
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
<?xml version="1.0" encoding="utf-8"?> | |
<Configuration> | |
<ViewDefinitions> | |
<View> | |
<Name>MatchInfo</Name> | |
<ViewSelectedBy> | |
<TypeName>Microsoft.PowerShell.Commands.MatchInfo</TypeName> | |
</ViewSelectedBy> | |
<CustomControl> | |
<CustomEntries> | |
<CustomEntry> | |
<CustomItem> | |
<ExpressionBinding> | |
<ScriptBlock> | |
$currentDir = (Get-Location).Path | |
$relativePath = $_.RelativePath($currentDir) | |
$originalLine = $_.ToEmphasizedString($currentDir) | |
if ($_.Path -and ($_.Path -ne 'InputStream')) | |
{ | |
$linkString = $PSStyle.FormatHyperlink($relativePath, $_.Path) | |
$originalLine.Replace($relativePath, $linkString) | |
} | |
else | |
{ | |
$originalLine | |
} | |
</ScriptBlock> | |
</ExpressionBinding> | |
</CustomItem> | |
</CustomEntry> | |
</CustomEntries> | |
</CustomControl> | |
</View> | |
</ViewDefinitions> | |
</Configuration> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can apply the format with
Update-FormatData
command.It works on Windows Terminal and PowerShell 7.2.
MatchinfoLinkFormat.mp4