Skip to content

Instantly share code, notes, and snippets.

@rasmusmerzin
Last active April 19, 2026 18:30
Show Gist options
  • Select an option

  • Save rasmusmerzin/01d6823911e9e2774d9c1a17be18da0e to your computer and use it in GitHub Desktop.

Select an option

Save rasmusmerzin/01d6823911e9e2774d9c1a17be18da0e to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# Usage: rgb [Red 0-5] [Green 0-5] [Blue 0-5]
c=$((16+(${1:-0}*36)+(${2:-0}*6)+(${3:-0}*1)))
if [[ -t 1 ]]
then printf '\e[38:5:%dm%-3d\e[m\n' $c $c
else echo $c
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment