I am trying to create a powershell snippet that will copy the first column of a multi-line piped input to clipboard.
The intended usage is: kubectl get pods | copyfirst.
This should allow me to have all pod names in the clipboard, and use Win+V to select the individual pod name that I need.
What I have so far is:
function copyfirst {
[CmdletBinding()]Param([Parameter(ValueFromPipeline)]$Param)
process {
$Param.Split(" ")[0] | Set-Clipboard
}
}
The problem is - this only copies the last entry to clipboard, while all the others are ignored.
If I change Set-Clipboard to some other command - it works as intended. For example echo outputs all pod names, not just the last one.