Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save ninmonkey/e9968c829185a310574e61f2365105a4 to your computer and use it in GitHub Desktop.

Select an option

Save ninmonkey/e9968c829185a310574e61f2365105a4 to your computer and use it in GitHub Desktop.
Tiny Set-Clipboard Sugar
# Here's tiny clipboard sugar for a profile
# context: there was a thread about creating a custom clipboard uri, and clipboard cmdlets
# <https://discord.com/channels/180528040881815552/447476117629304853/1260981998479081562>
# It's nice to get a confirmation that your clip was saved
$PSDefaultParameterValues['Set-ClipBoard:PassThru'] = $true
Set-alias 'cl' 'Set-ClipBoard' # 'sc' already exists
Set-Alias 'gcl' 'Get-Clipboard'
function GetClipboardItem {
<#
.description
This sets your clipboard returns a non-null value,
if and only if the path exists
invalid paths skip set-clipbaord
# optionally you can set a global, and set-
#>
param()
process {
$Item = Get-Item -ea ignore $_
if( -not $item ) { return }
$global:GI = $Item
$Item | Set-Clipboard -passthru:$false
$Item
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment