plastikfan / TerminalBuddy

Utility module for Windows Terminal
MIT License
0 stars 0 forks source link

Elizium.TerminalBuddy

A B A B A B A B

Utility module for Windows Terminal.

The new Windows Terminal is a great replacement for the tiring and aging console. However, in it's current form, it is not very easy to configure owing to there not being a Settings UI. On top of that, it is not easy to leverage the fine work of others in the creation of schemes for other console/terminal style applications on other platforms; more specifically, iterm2.

TerminalBuddy aims to be a stop gap that performs bulk conversion of iterm colour schemes to be used within Windows Terminal.

Installation

Terminal Buddy is a powershell module published on PowerShellGallery and can be installed using the install-module command:

install-module -Name Elizium.TerminalBuddy

or to install for all users:

install-module -Name Elizium.TerminalBuddy -scope ALLUSERS

Note, this needs be executed under an elevated admin powershell session.

Dependencies

This module is dependent on the Elizium.Krayola, which should be installed automatically.

Import iterm schemes into Windows Terminal

This can be achieved by running the ConvertFrom-ItermColors command which has the following parameters

There are quite a few parameters here, but thankfully, they don't all need to be specified as there are reasonable defaults for most.

There are multiple ways to use this function:

The function errs on the side of caution, and by default works in 'Dry Run' mode. Due to the caveats, this method is effectively the same as not using the $SaveTerminalSettings switch, using $Out instead, because in this scenario, the user would be expected to open up the generated file and copy the generated scheme objects into the current Settings file. This is the recommended way to use this command.

If the user wants to integrate the generated schemes into the Settings file automatically, then the $Force switch should be specified. In this case, the current live Settings file is backed up and then over-written by the new content. Existing schemes are preserved.

:heavy_exclamation_mark: And the caveats ...

Generate Out file

Convert a single file into Out file

ConvertFrom-ItermColors -Path 'C:\shared\Themes\ITerm2\Schemes\Banana Blueberry.itermcolors' -Out ~/terminal-settings.single.output.json

picture

Converts single file Banana Blueberry.itermcolors into the output file ~/terminal-settings.single.output.json

Bulk convert multiple files into Out file

ConvertFrom-ItermColors -Path C:\shared\Themes\ITerm2\Schemes -Filter "B*.itermcolors" -Out ~/terminal-settings.output.json

picture

This converts all itermcolors files beginning with B, found in C:\shared\Themes\ITerm2\Schemes and creates an output file ~/terminal-settings.output.json which is a JSON object with a single schemes property with the converted schemes.

Dry Run mode

Convert a single file into Dry Run file

ConvertFrom-ItermColors -Path 'C:\shared\Themes\ITerm2\Schemes\Banana Blueberry.itermcolors' -SaveTerminalSettings

picture

Converts single file Banana Blueberry.itermcolors scheme, merges into live settings file, writing to the default dry run file (~/Windows.Terminal.dry-run.settings.json)

Bulk convert multiple files into Dry Run file

ConvertFrom-ItermColors -Path C:\shared\Themes\ITerm2\Schemes\ -Filter 'B*.itermcolors' -SaveTerminalSettings

picture

This converts all itermcolors files beginning with B, found in C:\shared\Themes\ITerm2\Schemes, merges into live settings file, writing to the default dry run file (~/Windows.Terminal.dry-run.settings.json)

Live settings update

de-activated, until caveats can be resolved, if ever :zzz:

Convert a single file into Live settings file

ConvertFrom-ItermColors -Path 'C:\shared\Themes\ITerm2\Schemes\Banana Blueberry.itermcolors' -SaveTerminalSettings -Force

picture

Converts single file Banana Blueberry.itermcolors scheme, merges into live settings file, (in theory overwriting live settings file), but instead writing to ~/Windows.Terminal.pseudo.settings.json.

Bulk convert multiple files Live settings file

ConvertFrom-ItermColors -Path C:\shared\Themes\ITerm2\Schemes\ -Filter 'B*.itermcolors' -SaveTerminalSettings -Force

picture

This converts all itermcolors files beginning with B, found in C:\shared\Themes\ITerm2\Schemes, merges into live settings file, (in theory overwriting live settings file), but instead writing to ~/Windows.Terminal.pseudo.settings.json.

Manual intervention required

After the output file has been generated, as the command indicates at the end of it's run, the user needs to manually copy over the generated schemes from the schemes property directly into the schemes entry in the live Terminal Settings file, (usually in '~\AppData\Local\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\settings.json'). Since the schemes already defined before the command was run, are merged with the new ones, it is safe to simply copy and over-write the existing schemes property without fear of losing the old ones.

This step is only require because of the caveats previously described.

... And finally

In case you're wondering what iterm scheme is illustrated in the screen shots, it is the AdventureTime and the font is agave NF r.

If you're not sure which iterm scheme to use, just download the whole pack from iterm2-color-schemes, and use Terminal Buddy to bulk convert as many as you'd like to try.