After renewing my development environment in 2021, I found that handlebars
.hbs files weren't coloured by Terminal-Icons. Seeing as the project allowed for public submissions for pull requests, I decided to follow through and add colouring for
Terminal-Icons is a PowerShell module that decorates the output of the
dir command with colours and icons.
It's imported the same way as any other PowerShell module and you yourself can install it with:
Install-Module -Name Terminal-Icons -Repository PSGallery
You'll then need to import it to use it. You could add it to your PowerShell
$PROFILE with this line:
Import-Module -Name Terminal-Icons
My issue was that Ghost, which this blog runs off (at the time of writing this), uses handlebars for templating. These files have the file extension of
.hbs which Terminal-Icons at the time did not support. I wanted that file type supported, so off I went to understand how to contribute.
The development itself was quite straightforward. Two files needed to be modified:
- Terminal-Icons/Data/colorThemes/devblackops.psd1 (colours)
- Terminal-Icons/Data/iconThemes/devblackops.psd1 (icons)
The colours updated with:
'.hbs' = 'E37933'
And the icons updated with:
'.hbs' = 'nf-seti-mustache'
How did I work out what colour and what icon? Turns out a well known theme Seti has already worked what colours and icons suit. I also double checked these against the handlebars website and they looked perfect. After adding those two lines above, and building (
build.ps1), my output looked looked like:
From here the .vscode settings took over to auto format and I was ready for testing.
I'd never unit tested PowerShell scripts before this and one of the requirements to do a pull request is that the tests pass. Turns out I needed to install the PowerShell testing framework Pester. Once I did that and ran
.build.ps1 again I got the following successful output:
Time to contribute.
The Pull Request
Pull requests in this repo require an issue beforehand with a description of what's up and what needs to change. Thankfully since I had already done the development I could provide accurate screenshots of what I wanted the final output to be.
You can find it all in this issue link: https://github.com/devblackops/Terminal-Icons/issues/50 but roughly it's:
- This is what I would like it to look like
- This is what it currently looks like
- This is the inspiration for what I want it to look like
One month later, I was given the ok to create a PR: https://github.com/devblackops/Terminal-Icons/pull/53. I filled in the PR template provided, showed that I did some testing, and waited.
Two days later, my PR was accepted:
Which means if I go over to check out the icons and colour for
I hope you enjoyed reading just one way to contribute to open source projects. I had a great time contributing to this project, so much so I even tried GitHub sponsoring for the first time. Big thanks to @devblackops. Now if ever my friends use this with
.hbs files, I can point to that and go "hey I helped with that!".