Skip to content

Instantly share code, notes, and snippets.

@kiendang
Created June 15, 2018 18:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kiendang/26338b09912328099a089eb718e1a159 to your computer and use it in GitHub Desktop.
Save kiendang/26338b09912328099a089eb718e1a159 to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# auto match window title and tab background color with
# terminal background color for iTerm2
# append to your .bashrc, .zshrc or whatever
# does not really work with High Sierra
# to reset:
# echo -e "\033]6;1;bg;*;default\a"
osascript -e \
'tell application "iTerm"
tell current session of current window
get background color
end tell
end tell' |\
tr -d ',' |\
xargs -n 1 -I {} expr {} / 257 |\
paste <(echo -e 'red\ngreen\nblue') - |\
awk '{ print "\033]6;1;bg;"$1";brightness;"$2"\a" }'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment