Last active
November 9, 2023 10:17
-
-
Save drbh/fb2e9ca5455a2bff5cf51ffa3d89a27c to your computer and use it in GitHub Desktop.
Programmatically change the background color of iTerm - or set it randomly
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set_term_bgcolor(){ | |
local R=$1 | |
local G=$2 | |
local B=$3 | |
/usr/bin/osascript <<EOF | |
tell application "iTerm" | |
tell current session of current window | |
set background color to {$(echo "scale=2; ($1/255.0)*65535" | bc),$(echo "scale=2; ($2/255.0)*65535" | bc),$(echo "scale=2; ($3/255.0)*65535" | bc)} | |
end tell | |
end tell | |
EOF | |
} | |
set_random_bgcolor(){ | |
set_term_bgcolor $(echo $(echo 0."$RANDOM")*255 | bc) $(echo $(echo 0."$RANDOM")*255 | bc) $(echo $(echo 0."$RANDOM")*255 | bc) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is great for helping you to come up with new color palettes. I rely on 4-5 different ones and feel like I've run out of options.