mirror of
https://github.com/lifepillar/vim-solarized8.git
synced 2025-12-10 07:46:58 +00:00
Add script to change an xterm color palette.
This commit is contained in:
74
templates/_fix-256-palette.colortemplate
Normal file
74
templates/_fix-256-palette.colortemplate
Normal file
@@ -0,0 +1,74 @@
|
||||
auxfile scripts/@shortname.sh
|
||||
#!/bin/sh
|
||||
# Modify 256-color palette in supported terminals
|
||||
# Script adapted from https://github.com/chriskempson/base16-shell
|
||||
set -o errexit
|
||||
|
||||
hex2rgb() {
|
||||
local s=$1
|
||||
local r=${s:1:2}
|
||||
local g=${s:3:2}
|
||||
local b=${s:5:2}
|
||||
echo "$r/$g/$b"
|
||||
}
|
||||
|
||||
if [ "${TERM%%-*}" = 'linux' ]; then
|
||||
# This script doesn't support linux console
|
||||
return 2>/dev/null || exit 0
|
||||
fi
|
||||
|
||||
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\\"
|
||||
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
|
||||
|
||||
printf $printf_template @term256base03 $(hex2rgb "@guibase03")
|
||||
printf $printf_template @term256base02 $(hex2rgb "@guibase02")
|
||||
printf $printf_template @term256base01 $(hex2rgb "@guibase01")
|
||||
printf $printf_template @term256base00 $(hex2rgb "@guibase00")
|
||||
printf $printf_template @term256base0 $(hex2rgb "@guibase0")
|
||||
printf $printf_template @term256base1 $(hex2rgb "@guibase1")
|
||||
printf $printf_template @term256base2 $(hex2rgb "@guibase2")
|
||||
printf $printf_template @term256base3 $(hex2rgb "@guibase3")
|
||||
printf $printf_template @term256yellow $(hex2rgb "@guiyellow")
|
||||
printf $printf_template @term256orange $(hex2rgb "@guiorange")
|
||||
printf $printf_template @term256red $(hex2rgb "@guired")
|
||||
printf $printf_template @term256magenta $(hex2rgb "@guimagenta")
|
||||
printf $printf_template @term256violet $(hex2rgb "@guiviolet")
|
||||
printf $printf_template @term256blue $(hex2rgb "@guiblue")
|
||||
printf $printf_template @term256cyan $(hex2rgb "@guicyan")
|
||||
printf $printf_template @term256green $(hex2rgb "@guigreen")
|
||||
|
||||
# foreground / background / cursor color
|
||||
# if [ -n "$ITERM_SESSION_ID" ]; then
|
||||
# # iTerm2 proprietary escape codes
|
||||
# printf $printf_template_custom Pg 93a1a1 # forground
|
||||
# printf $printf_template_custom Ph 002b36 # background
|
||||
# printf $printf_template_custom Pi 93a1a1 # bold color
|
||||
# printf $printf_template_custom Pj 586e75 # selection color
|
||||
# printf $printf_template_custom Pk 93a1a1 # selected text color
|
||||
# printf $printf_template_custom Pl 93a1a1 # cursor
|
||||
# printf $printf_template_custom Pm 002b36 # cursor text
|
||||
# else
|
||||
# printf $printf_template_var 10 $color_foreground
|
||||
# printf $printf_template_var 11 $color_background
|
||||
# printf $printf_template_var 12 $color_cursor
|
||||
# fi
|
||||
|
||||
unset printf_template
|
||||
unset printf_template_var
|
||||
unset printf_template_custom
|
||||
endauxfile
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
" Source this script to parse all the templates in this folder and
|
||||
" generate corresponding colorschemes in the colors folder (the colors folder
|
||||
" will be created if it does not exist).
|
||||
" Note: existing files in the colors folder are overridden.
|
||||
|
||||
let s:curdir = fnamemodify(resolve(expand('<sfile>:p')), ':h')
|
||||
let s:parent = fnamemodify(s:curdir, ':h')
|
||||
let s:errors = 0
|
||||
|
||||
execute 'lcd' s:curdir
|
||||
|
||||
for s:template in glob(s:curdir . '/solarized8*.colortemplate', 1, 1)
|
||||
let s:template_name = fnamemodify(s:template, ':t:r')
|
||||
if s:template_name == 'solarized8'
|
||||
let g:colortemplate_no_doc = 0
|
||||
else
|
||||
let g:colortemplate_no_doc = 1
|
||||
endif
|
||||
execute "edit" s:template
|
||||
execute "Colortemplate!" fnameescape(s:parent)
|
||||
if g:colortemplate_exit_status != 0
|
||||
echoerr 'ERROR:' s:template_name 'could not be built'
|
||||
let s:errors = 1
|
||||
endif
|
||||
endfor
|
||||
|
||||
if s:errors > 0
|
||||
redraw
|
||||
echo "\r"
|
||||
echoerr "There were errors: see messages"
|
||||
endif
|
||||
@@ -40,6 +40,10 @@ Color: green #859900 ~ 2
|
||||
Color: back #002b36 ~ 8
|
||||
# }}}
|
||||
|
||||
# Fix 256-color palette in supported terminals {{{
|
||||
Include: _fix-256-palette.colortemplate
|
||||
# }}}
|
||||
|
||||
# Default highlight groups {{{
|
||||
verbatim
|
||||
if !has('gui_running') && get(g:, '@optionprefix_termtrans', 0)
|
||||
|
||||
Reference in New Issue
Block a user