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

[Feature request] Make it work on Windows Terminal /WSL2 #413

Open
JulianGR opened this issue Jan 4, 2024 · 2 comments
Open

[Feature request] Make it work on Windows Terminal /WSL2 #413

JulianGR opened this issue Jan 4, 2024 · 2 comments

Comments

@JulianGR
Copy link

JulianGR commented Jan 4, 2024

Hello,

I love Gogh and use it on my Kali VM. Lately, I've became a fan of WSL2 and Gogh doesn't seem to be working on WSL. I'm aware of #183 (comment) and that there is no way that WSL changes the colors of Windows (maybe now there is, since a couple of years have passed?), but what about making Gogh work in Windows Terminal?

I'm not talking abount running Gogh inside WSL and it changing the Windows Terminal configuration, but rather running Gogh directly on Windows Terminal. I'm also aware that other tool exists, such as colortool, but I quite like Gogh

@zoltan-kecskemethy-epam
Copy link

zoltan-kecskemethy-epam commented Feb 22, 2024

I've a semi-automated migration process to convert a scheme from this repo and added it into Windows terminal.
Not sure, but we might be able to turn it a script.

Let me describe what I did.

Windows terminal has its full configuration including color schemes defined in json format.
Usually located at C:\Users\<username>\AppData\Local\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json
There are many things in the config but there is a "schemes" section looks like:

    "schemes": 
    [
        {
            "background": "#1A1B26",
            "black": "#414868",
            "blue": "#7AA2F7",
            "brightBlack": "#414868",
            "brightBlue": "#7AA2F7",
            "brightCyan": "#7DCFFF",
            "brightGreen": "#9ECE6A",
            "brightPurple": "#7DCFFF",
            "brightRed": "#F7768E",
            "brightWhite": "#C0CAF5",
            "brightYellow": "#E0AF68",
            "cursorColor": "#FFFFFF",
            "cyan": "#7DCFFF",
            "foreground": "#C0CAF5",
            "green": "#9ECE6A",
            "name": "TokyoNight",
            "purple": "#7DCFFF",
            "red": "#F7768E",
            "selectionBackground": "#FFFFFF",
            "white": "#A9B1D6",
            "yellow": "#E0AF68"
        },
      <we-want-to-add-new-scheme-here>
    ],

I've used alacritty's json_str structure from here: https://github.com/Gogh-Co/Gogh/blob/master/apply-colors.sh#L472C1-L531C2

so created a windows terminal compatible json structure ...

win_term_json_str="\
{\
    \"schemes\": [\
        {\
            \"black\": \"$COLOR_01\",\
            \"red\": \"$COLOR_02\",\
            \"green\": \"$COLOR_03\",\
            \"yellow\":\"$COLOR_04\",\
            \"blue\":\"$COLOR_05\",\
            \"magenta\": \"$COLOR_06\",\
            \"cyan\":\"$COLOR_07\",\
            \"white\": \"$COLOR_08\",\
            \"brightblack\":\"$COLOR_09\",\
            \"brightred\":\"$COLOR_10\",\
            \"brightgreen\":\"$COLOR_11\",\
            \"brightyellow\": \"$COLOR_12\",\
            \"brightblue\": \"$COLOR_13\",\
            \"brightmagenta\":\"$COLOR_14\",\
            \"brightcyan\": \"$COLOR_15\",\
            \"brightwhite\":\"$COLOR_16\",\
            \"background\": \"$BACKGROUND_COLOR\",\
            \"foreground\": \"$FOREGROUND_COLOR\",\
            \"cursorColor\": \"$CURSOR_COLOR\",\
            \"selectionBackground\": \"$COLOR_16\",\
            \"name\": \"$PROFILE_NAME\"\
        }\
    ]\
}"

I was not sure which color to use for "selectionBackground" - as this looks to be missing - so I've just repeated COLOR_16 there.

As a final step we would need to merge above json into the main config...

Main config path in WSL could be mounted as
/mnt/c/Users/$USER/AppData/Local/Packages/Microsoft.WindowsTerminal_8wekyb3d8bbwe/LocalState/settings.json

We can use jq tool for the merge.

So the overall process using zenburn scheme

cd install
source zenburn.sh
export win_term_json_str="\
{\
    \"schemes\": [\
        {\
            \"black\": \"$COLOR_01\",\
            \"red\": \"$COLOR_02\",\
            \"green\": \"$COLOR_03\",\
            \"yellow\":\"$COLOR_04\",\
            \"blue\":\"$COLOR_05\",\
            \"magenta\": \"$COLOR_06\",\
            \"cyan\":\"$COLOR_07\",\
            \"white\": \"$COLOR_08\",\
            \"brightblack\":\"$COLOR_09\",\
            \"brightred\":\"$COLOR_10\",\
            \"brightgreen\":\"$COLOR_11\",\
            \"brightyellow\": \"$COLOR_12\",\
            \"brightblue\": \"$COLOR_13\",\
            \"brightmagenta\":\"$COLOR_14\",\
            \"brightcyan\": \"$COLOR_15\",\
            \"brightwhite\":\"$COLOR_16\",\
            \"background\": \"$BACKGROUND_COLOR\",\
            \"foreground\": \"$FOREGROUND_COLOR\",\
            \"cursorColor\": \"$CURSOR_COLOR\",\
            \"selectionBackground\": \"$COLOR_16\",\
            \"name\": \"$PROFILE_NAME\"\
        }\
    ]\
}"
echo $win_term_json_str | jq . > /tmp/win-term-scheme.json
cp /mnt/c/Users/$USER/AppData/Local/Packages/Microsoft.WindowsTerminal_8wekyb3d8bbwe/LocalState/settings.json /tmp
jq -s '.[0] * .[1]' /tmp/win-term-scheme.json /tmp/settings.json > /tmp/new-settings.json

This is not foolproof, so make a backup of your config before overwriting it.
Also this is the reason why I've made changes in files in /tmp ...

@zoltan-kecskemethy-epam

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

2 participants