Skip to content

Instantly share code, notes, and snippets.

@h2oota
Last active December 15, 2015 22:09
Show Gist options
  • Save h2oota/5330689 to your computer and use it in GitHub Desktop.
Save h2oota/5330689 to your computer and use it in GitHub Desktop.
solarized configuration file generator for PuTTY
@echo off
setlocal
set sess_ok=
set tc=
if not "%1" == "/tc" goto next
set tc=0
shift
:next
if not "%1" == "/tcl" goto next
set tc=1
shift
if "%2" == "" goto usage
set mode=%1
set sess=%2
for /f %%k in ('reg query HKCU\Software\SimonTatham\PuTTY\Sessions') do call :check_sess "%%k" "%sess%"
if not "%sess_ok%" == "" goto sess_ok
echo %sess% : session not found
exit /b 1
:sess_ok
if "%mode%" == "/l" goto light
if "%mode%" == "/d" goto dark
goto usage
:light
call :header
echo "Colour0"="101,123,131">>"%sess%.reg"
echo "Colour1"="88,110,117">>"%sess%.reg"
echo "Colour2"="253,246,227">>"%sess%.reg"
echo "Colour3"="238,232,213">>"%sess%.reg"
echo "Colour4"="238,232,213">>"%sess%.reg"
echo "Colour5"="101,123,131">>"%sess%.reg"
call :solarized
if not "%tc%" == "" call :termcap
echo "%sess%.reg" is ready for import.
endlocal
goto :eof
:dark
call :header
echo "Colour0"="131,148,150">>"%sess%.reg"
echo "Colour1"="147,161,161">>"%sess%.reg"
echo "Colour2"="0,43,54">>"%sess%.reg"
echo "Colour3"="7,54,66">>"%sess%.reg"
echo "Colour4"="0,43,54">>"%sess%.reg"
echo "Colour5"="238,232,213">>"%sess%.reg"
call :solarized
if not "%tc%" == "" call :termcap
echo "%sess%.reg" is ready for import.
endlocal
goto :eof
:usage
echo Usage: %~n0 [/tc] /d session
echo %~n0 [/tc] /l session
echo /tc : generate TERMCAP environment
echo /d /l: dark or light
exit /b 1
:check_sess
if "%~n1" == "%~2" set sess_ok=%~2
exit /b
:header
echo Windows Registry Editor Version 5.00>"%sess%.reg"
echo [HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\Sessions\%sess%]>>"%sess%.reg"
exit /b
:solarized
echo "Colour6"="7,54,66">>"%sess%.reg"
echo "Colour7"="0,43,54">>"%sess%.reg"
echo "Colour8"="220,50,47">>"%sess%.reg"
echo "Colour9"="203,75,22">>"%sess%.reg"
echo "Colour10"="133,153,0">>"%sess%.reg"
echo "Colour11"="88,110,117">>"%sess%.reg"
echo "Colour12"="181,137,0">>"%sess%.reg"
echo "Colour13"="101,123,131">>"%sess%.reg"
echo "Colour14"="38,139,210">>"%sess%.reg"
echo "Colour15"="131,148,150">>"%sess%.reg"
echo "Colour16"="211,54,130">>"%sess%.reg"
echo "Colour17"="108,113,196">>"%sess%.reg"
echo "Colour18"="42,161,152">>"%sess%.reg"
echo "Colour19"="147,161,161">>"%sess%.reg"
echo "Colour20"="238,232,213">>"%sess%.reg"
echo "Colour21"="253,246,227">>"%sess%.reg"
exit /b
:termcap
if %tc% == 0 goto termcap_0
echo "Environment"="TERMCAP=putty-solarized:Co#16:pa#256:ti\\=\\\\E[?1049h:te\\=\\\\E[?1049l:eA\\=\\\\E(B\\\\E)0:as\\=^N:ae\\=^O:ac\\=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~..--++\\,\\,hhII00:tc\\=xterm-256color:">>"%sess%.reg"
echo "TerminalType"="putty-solarized">>"%sess%.reg"
exit /b
:termcap_0
echo "Environment"="TERMCAP=putty-solarized:Co#16:pa#256:ti\\=\\\\E[?1049h:te\\=\\\\E[?1049l:tc\\=xterm-256color:">>"%sess%.reg"
echo "TerminalType"="putty-solarized">>"%sess%.reg"
exit /b

solarized configuration file generator for PuTTY

Usage

putty-solarized [/tc | /tcl] /d | /l session_name

  • /tc generate setting of TERMCAP environment variable. it will be passed to sshd.
  • /tcl In addition to /tc, line drawing capability will be generated.
  • /d /l dark or light
  • session_name the session name for PuTTY

Output

session_name.reg

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment