PowerShell Gemini Code Block Generator | Patryk Adamczyk's Log

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

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