|
| 1 | +#!/bin/sh |
| 2 | +# Cool Night |
| 3 | + |
| 4 | +# source for these helper functions: |
| 5 | +# https://github.com/chriskempson/base16-shell/blob/master/templates/default.mustache |
| 6 | +if [ -n "$TMUX" ]; then |
| 7 | + # Tell tmux to pass the escape sequences through |
| 8 | + # (Source: http://permalink.gmane.org/gmane.comp.terminal-emulators.tmux.user/1324) |
| 9 | + put_template() { printf '\033Ptmux;\033\033]4;%d;rgb:%s\033\033\\\033\\' $@; } |
| 10 | + put_template_var() { printf '\033Ptmux;\033\033]%d;rgb:%s\033\033\\\033\\' $@; } |
| 11 | + put_template_custom() { printf '\033Ptmux;\033\033]%s%s\033\033\\\033\\' $@; } |
| 12 | +elif [ "${TERM%%[-.]*}" = "screen" ]; then |
| 13 | + # GNU screen (screen, screen-256color, screen-256color-bce) |
| 14 | + put_template() { printf '\033P\033]4;%d;rgb:%s\007\033\\' $@; } |
| 15 | + put_template_var() { printf '\033P\033]%d;rgb:%s\007\033\\' $@; } |
| 16 | + put_template_custom() { printf '\033P\033]%s%s\007\033\\' $@; } |
| 17 | +elif [ "${TERM%%-*}" = "linux" ]; then |
| 18 | + put_template() { [ $1 -lt 16 ] && printf "\e]P%x%s" $1 $(echo $2 | sed 's/\///g'); } |
| 19 | + put_template_var() { true; } |
| 20 | + put_template_custom() { true; } |
| 21 | +else |
| 22 | + put_template() { printf '\033]4;%d;rgb:%s\033\\' $@; } |
| 23 | + put_template_var() { printf '\033]%d;rgb:%s\033\\' $@; } |
| 24 | + put_template_custom() { printf '\033]%s%s\033\\' $@; } |
| 25 | +fi |
| 26 | + |
| 27 | +# 16 color space |
| 28 | +put_template 0 "0b/3b/61" |
| 29 | +put_template 1 "ff/3a/3a" |
| 30 | +put_template 2 "52/ff/d0" |
| 31 | +put_template 3 "ff/f3/83" |
| 32 | +put_template 4 "13/76/f9" |
| 33 | +put_template 5 "c7/92/ea" |
| 34 | +put_template 6 "ff/5e/d4" |
| 35 | +put_template 7 "16/fd/a2" |
| 36 | +put_template 8 "63/68/6d" |
| 37 | +put_template 9 "ff/54/b0" |
| 38 | +put_template 10 "74/ff/d8" |
| 39 | +put_template 11 "fc/f5/ae" |
| 40 | +put_template 12 "38/8e/ff" |
| 41 | +put_template 13 "ae/81/ff" |
| 42 | +put_template 14 "ff/6a/d7" |
| 43 | +put_template 15 "60/fb/bf" |
| 44 | + |
| 45 | +color_foreground="ec/de/f4" |
| 46 | +color_background="01/0c/18" |
| 47 | + |
| 48 | +if [ -n "$ITERM_SESSION_ID" ]; then |
| 49 | + # iTerm2 proprietary escape codes |
| 50 | + put_template_custom Pg "ecdef4" |
| 51 | + put_template_custom Ph "010c18" |
| 52 | + put_template_custom Pi "eeeeee" |
| 53 | + put_template_custom Pj "38ff9c" |
| 54 | + put_template_custom Pk "000000" |
| 55 | + put_template_custom Pl "38ff9d" |
| 56 | + put_template_custom Pm "000000" |
| 57 | +else |
| 58 | + put_template_var 10 $color_foreground |
| 59 | + put_template_var 11 $color_background |
| 60 | + if [ "${TERM%%-*}" = "rxvt" ]; then |
| 61 | + put_template_var 708 $color_background # internal border (rxvt) |
| 62 | + fi |
| 63 | + put_template_custom 12 ";7" # cursor (reverse video) |
| 64 | +fi |
| 65 | + |
| 66 | +# clean up |
| 67 | +unset -f put_template |
| 68 | +unset -f put_template_var |
| 69 | +unset -f put_template_custom |
| 70 | + |
| 71 | +unset color_foreground |
| 72 | +unset color_background |
0 commit comments