Skip to content

Instantly share code, notes, and snippets.

@johnbender
Created February 23, 2013 06:20
Show Gist options
  • Save johnbender/5018685 to your computer and use it in GitHub Desktop.
Save johnbender/5018685 to your computer and use it in GitHub Desktop.
Set up Chrome Secure Shell to handle solarized terminal colors
// Disable bold.
term_.prefs_.set('enable-bold', false)
// Use this for Solarized Dark
term_.prefs_.set('background-color', "#002b36");
term_.prefs_.set('foreground-color', "#839496");
term_.prefs_.set('color-palette-overrides', [
'#073642',
'#dc322f',
'#859900',
'#b58900',
'#268bd2',
'#d33682',
'#2aa198',
'#eee8d5',
'#002b36',
'#cb4b16',
'#586e75',
'#657b83',
'#839496',
'#6c71c4',
'#93a1a1',
'#fdf6e3'
]);
#!/bin/bash
#
# !!! CARGO CULTED https://github.com/benley/solarized-termcolor-osc4/blob/master/solarized.sh !!!!
#
#
# Author: benley@gmail.com (Benjamin Staffin)
# Set your terminal's color palette to match the Solarized color scheme by
# using escape sequences. Uses OSC 4 to set colors.
#
# This will work with many terminal emulators, but not all.
set -o nounset
# This next line would set the colors in the 256 color pallette which normally approximate
# solarized. Not a universal solution, but it helps with getting vim to look
# right! Stick this in your .vimrc just before "colorscheme solarized":
# let g:solarized_termtrans=1
# let g:solarized_termcolors=256
# See https://github.com/altercation/solarized/issues/8 for more information.
printf '\x1B]4;234;rgb:00/2b/36;235;rgb:07/36/42;240;rgb:58/6e/75;241;rgb:65/7b/83;244;rgb:83/94/96;245;rgb:93/a1/a1;254;rgb:ee/e8/d5;230;rgb:fd/f6/e3;136;rgb:b5/89/00;166;rgb:cb/4b/16;160;rgb:dc/32/2f;125;rgb:d3/36/82;61;rgb:6c/71/c4;33;rgb:26/8b/d2;37;rgb:2a/a1/98;64;rgb:85/99/00\a'
base03="00/2b/36"
base02="07/36/42"
base01="58/6e/75"
base00="65/7b/83"
base0="83/94/96"
base1="93/a1/a1"
base2="ee/e8/d5"
base3="fd/f6/e3"
yellow="b5/89/00"
orange="cb/4b/16"
red="dc/32/2f"
magenta="d3/36/82"
violet="6c/71/c4"
blue="26/8b/d2"
cyan="2a/a1/98"
green="85/99/00"
function cset() {
ANSI=$1
RGB=$2
printf "\x1b]4;$ANSI;rgb:${RGB}\a"
}
#black
cset 0 $base02
cset 8 $base03
#red
cset 1 $red
cset 9 $orange
#green
cset 2 $green
cset 10 $base01
#yellow
cset 3 $yellow
cset 11 $base00
#blue
cset 4 $blue
cset 12 $base0
#magenta
cset 5 $magenta
cset 13 $violet
#cyan
cset 6 $cyan
cset 14 $base1
#white
cset 7 $base2
cset 15 $base3
@njbair
Copy link

njbair commented Aug 11, 2013

This is great! I've already got solarized installed on my workstation shell, so all I had to do was open the Secure Shell extension, fire up Dev Tools, and paste the contents of prefs.js into the window.

Thanks for your work!

@sandesh-mq
Copy link

Thanks :)

@seadb
Copy link

seadb commented Oct 18, 2014

How do I install it?

Copy link

ghost commented Mar 4, 2015

brisondc@ Find the Secure Shell App, right click on it, go to options. Hit ctrl-shift-j to bring up a javascript console. Copy and paste the values from prefs.js into the console. Win!

By the way, thanks for this johnbender@

Copy link

ghost commented May 8, 2016

@kimdouglasmason This helped me too. Thanks!

@sricketts
Copy link

Thanks. This is almost working for me :)

I tried the prefs.js approach. The colors look right when I start to connect, but it looks like between Loading NaCl plugin... and done, the colors reset back to the default. I've googled all over and can't find anyone else with that problem. Any ideas?

@espoelstra
Copy link

Try using the values from this other config and paste them into the SSH Secure Shell "Options" page accessible from the Connection screen in that app, or if trying to apply to "Terminal" for the Linux VM in ChromeOS open the Terminal and hit Ctrl+Shift+P and fill out the same way as you would SSH Secure Shell.

@nicholaschiang
Copy link

Awesome, thanks for this @johnbender!

@dmos62
Copy link

dmos62 commented May 4, 2022

For those that would like to use some other color scheme, go to https://terminal.sexy/, find a scheme you like, under export options pick Chrome Secure Shell, take the generated key-value pairs.

If you're stuck using the now deprecated Chrome Secure Shell App, like me, once you're in options (to open use ctrl+shift+p while in the Chrome Secure Shell app) open the Javascript console (ctrl+shift+j) and put the generated key-value pairs in a dictionary and loop over it:

settings = {
"background-color": "#b5d8f6",
"foreground-color": "#2a343a",
"cursor-color":     "#2a343a",
"color-palette-overrides": ["#232c31","#2a5491","#237986","#a03b1e","#484d79","#c59820","#b02f30","#9ea7a6","#3f4944","#2a5491","#237986","#a03b1e","#484d79","#c59820","#b02f30","#b5d8f6"]
}

for (const [key, value] of Object.entries(settings)) {
  term_.prefs_.set(key, value)
}

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