The rest of the code is here: Write.Html.pq
// aliases
Write.Format = String.Write.Format,
Write.Element = Write.Html.Element,
Write.Key = Write.Html.KeyValue,
Tag = Write.Html.Element,| #Requires -PSEdition Desktop | |
| [CmdletBinding()] | |
| param ( | |
| [ValidateSet('AllUsers', 'CurrentUser')] | |
| [string] | |
| $Scope = 'CurrentUser' | |
| ) | |
| $ErrorActionPreference = 'Stop' |
| # Copyright: (c) 2024, Jordan Borean (@jborean93) <[email protected]> | |
| # MIT License (see LICENSE or https://opensource.org/licenses/MIT) | |
| #Requires -Module Ctypes | |
| Function Split-ExeArgument { | |
| [OutputType([string])] | |
| [CmdletBinding()] | |
| param ( | |
| [Parameter(Mandatory, ValueFromPipeline)] |
The rest of the code is here: Write.Html.pq
// aliases
Write.Format = String.Write.Format,
Write.Element = Write.Html.Element,
Write.Key = Write.Html.KeyValue,
Tag = Write.Html.Element,| using namespace System.Collections.Generic | |
| Import-module Pansies | |
| function Dotfiles.Select-Some { | |
| <# | |
| .SYNOPSIS | |
| select 1 item, 5, or a specific count. | |
| .NOTES | |
| - [ ] future: rewrite using steppable pipeline for an earlier exit | |
| .EXAMPLE |
| function ConvertTo-MarkdownTable { | |
| <# | |
| .DESCRIPTION | |
| Convert an object to a markdown table. | |
| .PARAMETER InputObject | |
| The object to convert to a markdown table. | |
| .PARAMETER Property | |
| The properties to display in the table. |
| using namespace System.Collections.Generic | |
| using namespace Microsoft.PowerShell.Commands.Internal.Format | |
| #Inspired by: https://gist.github.com/aaroncalderon/09a2833831c0f3a3bb57fe2224963942 | |
| <# | |
| .Synopsis | |
| Converts PowerShell Objects or Format-Table output to Markdown | |
| #> | |
| Function ConvertTo-Markdown { | |
| [CmdletBinding()] |
| Update-TypeData -TypeName '_RegexAnsi' -MemberType ScriptMethod -MemberName ToString -Force -Value { | |
| return ($this.Value ? $this.value : $this.Text) | |
| } | |
| Update-TypeData -TypeName 'System.Management.Automation.Internal.StringDecorated' -MemberType ScriptMethod -MemberName ToString -Force -Value { | |
| return $this.IsDecorated | |
| } | |
| function Get-AnsiEscape { | |
| <# | |
| .DESCRIPTION | |
| Get-AnsiEscape can be used to strip, escape, or regex VT codes from a string. |
| function Set-DemoPrompt { | |
| <# | |
| .SYNOPSIS | |
| Creates a simple prompt with WT highlighting using a temporary module. | |
| minor trickery with setting an alias for prompt so we can easily restore old prompt on module removal. | |
| .NOTES | |
| it adds terminal prompt markings for WT Preview. | |
| see links below for more info | |
| .LINK | |
| https://learn.microsoft.com/en-us/windows/terminal/tutorials/shell-integration#powershell-pwshexe/ |
| function Add-ClipboardProtocolHandler { | |
| # clipboard:// | |
| $custom = Get-Command "$env:temp\customclip.exe" -CommandType Application -ErrorAction 'Stop' | |
| $uri = 'clipboard' | |
| if (!(Test-Path "HKCU:\Software\Classes\$uri")) { | |
| New-Item "HKCU:\Software\Classes\$uri" | |
| } | |
| Set-ItemProperty "HKCU:\Software\Classes\$uri" '(Default)' "URL:$uri Protocol" | |
| Set-ItemProperty "HKCU:\Software\Classes\$uri" 'URL Protocol' '' | |
| if (!(Test-Path "HKCU:\Software\Classes\$uri\shell")) { |
| function ConvertTo-TableFormat { | |
| <# | |
| .SYNOPSIS | |
| Rebuild an object based on the Format Data for the object. | |
| .DESCRIPTION | |
| Allows an object to be rebuilt based on the view data for the object. Uses Select-Object to create a new PSCustomObject. | |
| #> | |
| [CmdletBinding()] | |
| param ( |