-
Notifications
You must be signed in to change notification settings - Fork 3
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
Export image with current shell's theme #2
Comments
will fix colors after patching the ansi parser |
added a new feature and flag |
The improved functionality now includes compatibility with a variety of themes such as “vscode,” “xterm,” “ubuntu,” “eclipse,” “mirc,” “putty,” “winxp,” “terminal,” “win10,” and “win_power-shell.” Additionally, there’s flexibility to personalize each color within any chosen theme. This is achieved by using the custom-theme- prefix followed by the color name (for example, fg, bg, white, etc.). The custom-defined colors will take precedence, replacing the default colors of the selected theme. |
I'm not really sure what the point of a theme is. I just want it to look like my screen. I'll try it out in a little while. |
I get your point; however, since the plugins API doesn’t grant me the capability to get your existing shell theme, this method allows you to customize the output to your preference. |
I understand now. I do think there's a way to query the terminal and get colors. I've seen it somewhere but maybe not all terminals support it. |
I wrote this little thing tonight. It doesn't work perfectly because someone broke the def get-terminal-colors [] {
let color_00 = (input $"(ansi -o '4;0;?')(ansi st)" --bytes-until-any "\e\\" -s)
let color_01 = (input $"(ansi -o '4;1;?')(ansi st)" --bytes-until-any "\e\\" -s)
let color_02 = (input $"(ansi -o '4;2;?')(ansi st)" --bytes-until-any "\e\\" -s)
let color_03 = (input $"(ansi -o '4;3;?')(ansi st)" --bytes-until-any "\e\\" -s)
let color_04 = (input $"(ansi -o '4;4;?')(ansi st)" --bytes-until-any "\e\\" -s)
let color_05 = (input $"(ansi -o '4;5;?')(ansi st)" --bytes-until-any "\e\\" -s)
let color_06 = (input $"(ansi -o '4;6;?')(ansi st)" --bytes-until-any "\e\\" -s)
let color_07 = (input $"(ansi -o '4;7;?')(ansi st)" --bytes-until-any "\e\\" -s)
let color_08 = (input $"(ansi -o '4;8;?')(ansi st)" --bytes-until-any "\e\\" -s)
let color_09 = (input $"(ansi -o '4;9;?')(ansi st)" --bytes-until-any "\e\\" -s)
let color_10 = (input $"(ansi -o '4;10;?')(ansi st)" --bytes-until-any "\e\\" -s)
let color_11 = (input $"(ansi -o '4;11;?')(ansi st)" --bytes-until-any "\e\\" -s)
let color_12 = (input $"(ansi -o '4;12;?')(ansi st)" --bytes-until-any "\e\\" -s)
let color_13 = (input $"(ansi -o '4;13;?')(ansi st)" --bytes-until-any "\e\\" -s)
let color_14 = (input $"(ansi -o '4;14;?')(ansi st)" --bytes-until-any "\e\\" -s)
let color_15 = (input $"(ansi -o '4;15;?')(ansi st)" --bytes-until-any "\e\\" -s)
# goes through 4;255;?
[
$color_00
$color_01
$color_02
$color_03
$color_04
$color_05
$color_06
$color_07
$color_08
$color_09
$color_10
$color_11
$color_12
$color_13
$color_14
$color_15
] | each {|col|
let rgb = $col | split row : | get 1 | split row /
let red = ($rgb | get 0 | str substring 0..2)
let green = ($rgb | get 1 | str substring 0..2)
let blue = ($rgb | get 2 | str substring 0..2)
{
red: $red
green: $green
blue: $blue
hex: $"#($red)($green)($blue)"
rgb: $"RGB(char lp)($red | into int -r 16), ($green | into int -r 16), ($blue | into int -r 16)(char rp)"
}
}
} |
I'll try to make it work but I don't think i can because of how stdin/out are controlled in nu-plugins |
I tweaked this conversion a little bit so it's a little more accurate with converting 16bits to 8bits. def get-terminal-colors [] {
let color_00 = (input $"(ansi -o '4;0;?')(ansi st)" --bytes-until-any "\e\\" -s)
let color_01 = (input $"(ansi -o '4;1;?')(ansi st)" --bytes-until-any "\e\\" -s)
let color_02 = (input $"(ansi -o '4;2;?')(ansi st)" --bytes-until-any "\e\\" -s)
let color_03 = (input $"(ansi -o '4;3;?')(ansi st)" --bytes-until-any "\e\\" -s)
let color_04 = (input $"(ansi -o '4;4;?')(ansi st)" --bytes-until-any "\e\\" -s)
let color_05 = (input $"(ansi -o '4;5;?')(ansi st)" --bytes-until-any "\e\\" -s)
let color_06 = (input $"(ansi -o '4;6;?')(ansi st)" --bytes-until-any "\e\\" -s)
let color_07 = (input $"(ansi -o '4;7;?')(ansi st)" --bytes-until-any "\e\\" -s)
let color_08 = (input $"(ansi -o '4;8;?')(ansi st)" --bytes-until-any "\e\\" -s)
let color_09 = (input $"(ansi -o '4;9;?')(ansi st)" --bytes-until-any "\e\\" -s)
let color_10 = (input $"(ansi -o '4;10;?')(ansi st)" --bytes-until-any "\e\\" -s)
let color_11 = (input $"(ansi -o '4;11;?')(ansi st)" --bytes-until-any "\e\\" -s)
let color_12 = (input $"(ansi -o '4;12;?')(ansi st)" --bytes-until-any "\e\\" -s)
let color_13 = (input $"(ansi -o '4;13;?')(ansi st)" --bytes-until-any "\e\\" -s)
let color_14 = (input $"(ansi -o '4;14;?')(ansi st)" --bytes-until-any "\e\\" -s)
let color_15 = (input $"(ansi -o '4;15;?')(ansi st)" --bytes-until-any "\e\\" -s)
# goes through 4;255;?
[
$color_00 $color_01 $color_02 $color_03
$color_04 $color_05 $color_06 $color_07
$color_08 $color_09 $color_10 $color_11
$color_12 $color_13 $color_14 $color_15
] | each {|col|
let rgb = $col | split row : | get 1 | split row /
# 16bit rgb to 8bit = 0xe7e7 | bits and 0x00ff
let red = ($"0x($rgb | get 0)" | into int | bits and 0x00ff)
let green = ($"0x($rgb | get 1)" | into int | bits and 0x00ff)
let blue = ($"0x($rgb | get 2)" | into int | bits and 0x00ff)
let red_hx = ($red | fmt).lowerhex | str substring 2..
let green_hx = ($green | fmt).lowerhex | str substring 2..
let blue_hx = ($blue | fmt).lowerhex | str substring 2..
{
red: $red_hx
green: $green_hx
blue: $blue_hx
hex: $"#($red_hx)($green_hx)($blue_hx)"
rgb: $"RGB(char lp)($red), ($green), ($blue)(char rp)"
}
}
} |
This is from
to png
This is from
ls
in the terminalYou'll notice other problems between these images too.
to png
looks good but it's not quite right. It's really noticeable on the header and footer labels as well as the row indexes.The text was updated successfully, but these errors were encountered: