Skip to content

Instantly share code, notes, and snippets.

@andy0130tw
Last active May 25, 2023 00:18
Show Gist options
  • Save andy0130tw/4b09b70486488727b5aa5a3355a19c2c to your computer and use it in GitHub Desktop.
Save andy0130tw/4b09b70486488727b5aa5a3355a19c2c to your computer and use it in GitHub Desktop.
How to tweak settings behind HTerm preferences in Chrome OS 84+.

How to tweak settings behind HTerm preferences in Chrome OS 84+.

Update (2022/11/14)

The interface seems to have changed (at least at 106). Now you can use the following promise-based APIs.

x = await term_.storage_.getItems()
term_.storage_.setItem(
  '/hterm/profiles/default/user-css',
  'https://fonts.googleapis.com/css2?family=Fira+Mono:wght@400;500;700&display=swap')

Deprecated instructions

  1. Press Ctrl+Shift+J.
  2. Use the following code to extract the setting object.
    hterm.defaultStorage.storage_.getSettings(console.log)
  3. Right click on the object, select "Save as global variable". (It is strongly recommended you backup this object) Suppose it is saved in temp1.
  4. Tweak. For example, the following code modify the terminal font to Fira Mono.
    Note that fonts outside the font list provided in the preference page are allowed, but they are erased as soon as you reach the preference page again.
    hterm.defaultStorage.storage_.setSettings({
      ...temp1,
      '/hterm/profiles/default/user-css-text': `x-screen { font-family: 'Fira Mono', 'Source Code Pro', 'Powerline For Source Code Pro', 'Noto Sans Mono' !important }`,
      '/hterm/profiles/default/user-css': 'http://mozilla.github.io/Fira/fira.css',
    }, console.log)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment