#!/bin/sh if [ "${TERM%%-*}" = 'linux' ]; then return 2>/dev/null || exit 0 fi black="11/11/11" red="f9/26/72" green="a6/e2/2e" yellow="f4/bf/75" blue="66/d9/ef" magenta="ae/81/ff" cyan="a1/ef/e4" white="cccccc" black2="75/71/5e" white2="f8/f8/f8" # TODO: name these? color16="fd/97/1f" # Base 09 color17="cc/66/33" # Base 0F color18="38/38/30" # Base 01 color19="49/48/3e" # Base 02 color20="a5/9f/85" # Base 04 color21="f5/f4/f1" # Base 06 if [ -n "$TMUX" ]; then # tell tmux to pass the escape sequences through # (Source: http://permalink.gmane.org/gmane.comp.terminal-emulators.tmux.user/1324) printf_template="\033Ptmux;\033\033]4;%d;rgb:%s\007\033\\" printf_template_var="\033Ptmux;\033\033]%d;rgb:%s\007\033\\" printf_template_custom="\033Ptmux;\033\033]%s%s\007\033\\" elif [ "${TERM%%-*}" = "screen" ]; then # GNU screen (screen, screen-256color, screen-256color-bce) printf_template="\033P\033]4;%d;rgb:%s\007\033\\" printf_template_var="\033P\033]%d;rgb:%s\007\033\\" printf_template_custom="\033P\033]%s%s\007\033\\" elif [[ $- != *i* ]]; then # non-interactive alias printf=/bin/false else printf_template="\033]4;%d;rgb:%s\033\\" printf_template_var="\033]%d;rgb:%s\033\\" printf_template_custom="\033]%s%s\033\\" fi c() { t="${1}"; shift c="${1}"; shift for n in "$@"; do printf "$t" "$n" "$c" done } ct() { c "$printf_template" "$@"; } cv() { c "$printf_template" "$@"; } cc() { c "$printf_template" "$@"; } ct $black 0 ct $red 1 9 ct $green 2 10 ct $yellow 3 11 ct $blue 4 12 ct $magenta 5 13 ct $cyan 6 14 ct $white 7 10 ct $black2 8 ct $white2 15 ct $color16 16 ct $color17 17 ct $color18 18 ct $color19 19 ct $color20 20 ct $color21 21 if [ -n "$ITERM_SESSION_ID" ]; then # iTerm2 proprietary escape codes printf $printf_template_custom Pg f8f8f2 # forground printf $printf_template_custom Ph 111111 # background printf $printf_template_custom Pi f8f8f2 # bold color printf $printf_template_custom Pj 49483e # selection color printf $printf_template_custom Pk f8f8f2 # selected text color printf $printf_template_custom Pl f8f8f2 # cursor printf $printf_template_custom Pm 111111 # cursor text else cv $white 10 cv $black 11 cc ";7" 12 fi unset -f c unset -f ct unset -f cv unset -f cc unset black unset red unset green unset yellow unset blue unset magenta unset cyan unset white unset black2 unset white2 unset printf_template unset printf_template_var unset printf_template_custom unset color16 unset color17 unset color18 unset color19 unset color20 unset color21