Skip to content

Commit

Permalink
feat(Clipboard.ps1): add new Copy-ToClipboard function to handle text…
Browse files Browse the repository at this point in the history
… copying to clipboard
  • Loading branch information
Bluzzi committed Aug 29, 2024
1 parent f0b7f8c commit e4e056e
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions Core/Functions/Clipboard.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Function to copy text to the clipboard
function Copy-ToClipboard {
param (
[Parameter(ValueFromPipeline=$true)]
[string]$text
)

begin {
$sb = [System.Text.StringBuilder]::new()
}

process {
$sb.AppendLine($text) | Out-Null
}

end {
if ($PSVersionTable.PSVersion.Major -lt 5) {
Write-Error "Your version of PowerShell does not support Set-Clipboard."
return
}

Set-Clipboard -Value $sb.ToString()
Write-Host "The content has been copied to the clipboard."
}
}

0 comments on commit e4e056e

Please sign in to comment.