Skip to content

Instantly share code, notes, and snippets.

@exogen
Created October 13, 2011 21:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save exogen/1285572 to your computer and use it in GitHub Desktop.
Save exogen/1285572 to your computer and use it in GitHub Desktop.
Convert RGB values to hex and copy the result to the clipboard (Mac)
#!/bin/bash
# rgb2hex -- Convert RGB values to hex and copy the result to the clipboard (Mac)
# usage: rgb2hex [r] [g] [b]
hex=$(python -c "print '#%02x%02x%02x' % (${1:-0}, ${2:-0}, ${3:-0})")
echo -n $hex | pbcopy
echo $hex
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment