PowerShell Gemini Code Block Generator
Metadata
Date of Creation: 19/07/2025 [DD/MM/YYYY]
Description
Simple script that takes code you copied to clipboard, asks you for language it is in and puts code with ANSI Sequences
Dependencies
- PowerShell Core (7+) [Tested on 7.5.2]
- Bat cli [Tested on 0.25.0]
- Gum cli [Tested on 0.14.5] (Optional, Read below how to drop it)
Not using Gum cli
You can exchange line:
$Language = (gum input --prompt "Specify language of snippet > ")
to:
$Language = (Read-Host "Specify language of snippet > ")
to drop dependency on gum entirely. I was too lazy to find Read-Host command (because I already forgot this command because I switched to nushell long time ago).
Code
#!/usr/bin/env -S pwsh -NoProfile
Write-Host "Getting clipboard content..."
$Code = (Get-Clipboard)
Write-Host "Setting snippet language..."
$Language = (gum input --prompt "Specify language of snippet > ")
$Code | bat --color always --decorations never -P -l $Language | Set-Clipboard