Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to set terminal colors? #59

Closed
Tyriar opened this issue May 31, 2016 · 10 comments
Closed

How to set terminal colors? #59

Tyriar opened this issue May 31, 2016 · 10 comments

Comments

@Tyriar
Copy link
Member

Tyriar commented May 31, 2016

I was looking into using xterm.js for vscode's integrated terminal but the colors seem to be gone after I swapped out jeremyramin/term.js.

image

Expected:

image

This is how I was setting the colors:

terminal.colors = [...]; // array of 16 string in format '#rrggbb'
terminal.refresh(0, terminal.rows);
@petschekr
Copy link

I believe xterm.js uses an external stylesheet instead of styles embedded into the JavaScript like term.js. Therefore you have to import xterm.css in your HTML. If you want to change the default colors, the stylesheet makes it a lot easier to override certain color rules. Adding it also makes the <textarea> used for input disappear.

@Tyriar
Copy link
Member Author

Tyriar commented Jun 1, 2016

Thanks, that clears that up :)

@Tyriar Tyriar closed this as completed Jun 1, 2016
@parisk
Copy link
Contributor

parisk commented Jun 1, 2016

Hi @Tyriar, @petschekr got it completely right; xterm.js depends on xterm.css for proper color rendering, in order to allow theming of the terminal.

I guess it would be helpful to document this in a more visible place though 😊 .

@zwhitchcox
Copy link
Contributor

This does not allow you to set the background color of the terminal

@zwhitchcox
Copy link
Contributor

I set the background terminal color with

term._core.renderer.colorManager.colors.background = {
  css: "#fdf6e3",
  rgba: "rgb(253, 246, 227)",
}

@Tyriar
Copy link
Member Author

Tyriar commented Oct 5, 2018

@zwhitchcox the current way to do this:

const term = new Terminal({
  'theme', { background: '#fdf6e3' }
});

// or

term.setOption('theme', { background: '#fdf6e3' });

@sdegutis
Copy link
Contributor

On a related note, are there any known themes out there or NPM packages containing themes?

@Tyriar
Copy link
Member Author

Tyriar commented Nov 26, 2019

@sdegutis not that I'm aware of

@sdegutis
Copy link
Contributor

@Tyriar Thanks, I'll just check out the ones VS Code comes with.

@Zzy-OvO
Copy link

Zzy-OvO commented May 15, 2024

Have you solved it?
What if I want to implement specific content using different colors?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants