Last active
April 15, 2025 09:23
-
-
Save stormychel/5aa7fc447172417424897e3348dc05bd to your computer and use it in GitHub Desktop.
PowerShell pbcopy function for Windows (mimics macOS pbcopy)
This file contains hidden or 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
<# | |
pbcopy.ps1 β A PowerShell function to mimic macOS `pbcopy` | |
π Usage: | |
"Hello world" | pbcopy | |
pbcopy # then type text, Ctrl+Z + Enter | |
π Install: | |
- Save this file somewhere on disk, e.g. C:\Scripts\pbcopy.ps1 | |
- Open your PowerShell profile: notepad $PROFILE | |
- Add this line: . "C:\Scripts\pbcopy.ps1" | |
- Reload profile: . $PROFILE | |
β Now you can use `pbcopy` like on macOS. | |
#> | |
function pbcopy { | |
param([string]$input = $null) | |
if (-not $input) { | |
$input = Get-Content -Raw -Path "CON" | |
} | |
$input | Set-Clipboard | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment