|
| 1 | +#!/bin/sh |
| 2 | +# One Dark Two |
| 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 "1d/1f/23" |
| 29 | +put_template 1 "e2/78/81" |
| 30 | +put_template 2 "98/c3/79" |
| 31 | +put_template 3 "ea/c7/86" |
| 32 | +put_template 4 "71/b9/f4" |
| 33 | +put_template 5 "c8/8b/da" |
| 34 | +put_template 6 "62/ba/c6" |
| 35 | +put_template 7 "c9/cc/d3" |
| 36 | +put_template 8 "4a/50/5a" |
| 37 | +put_template 9 "e6/89/91" |
| 38 | +put_template 10 "a8/cc/8e" |
| 39 | +put_template 11 "ed/cf/97" |
| 40 | +put_template 12 "8d/c7/f6" |
| 41 | +put_template 13 "d3/a2/e2" |
| 42 | +put_template 14 "78/c4/ce" |
| 43 | +put_template 15 "e6/e6/e6" |
| 44 | + |
| 45 | +color_foreground="e6/e6/e6" |
| 46 | +color_background="21/25/2b" |
| 47 | + |
| 48 | +if [ -n "$ITERM_SESSION_ID" ]; then |
| 49 | + # iTerm2 proprietary escape codes |
| 50 | + put_template_custom Pg "e6e6e6" |
| 51 | + put_template_custom Ph "21252b" |
| 52 | + put_template_custom Pi "e6e6e6" |
| 53 | + put_template_custom Pj "393e47" |
| 54 | + put_template_custom Pk "e6e6e6" |
| 55 | + put_template_custom Pl "e6e6e6" |
| 56 | + put_template_custom Pm "1d1f23" |
| 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