Contributing to Open Source: Terminal-Icons

Join me for my story of contributing to the open source Terminal-Icons project on GitHub.

Contributing to Open Source: Terminal-Icons
Styled .hbs files when using the dir command in PowerShell.

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 .hbs files.

GitHub - devblackops/Terminal-Icons: A PowerShell module to show file and folder icons in the terminal
A PowerShell module to show file and folder icons in the terminal - GitHub - devblackops/Terminal-Icons: A PowerShell module to show file and folder icons in the terminal

Background

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.  

No styling for .hbs files.

Development

The development itself was quite straightforward. Two files needed to be modified:

  1. Terminal-Icons/Data/colorThemes/devblackops.psd1 (colours)
  2. 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:

Styling for .hbs files.

From here the .vscode settings took over to auto format and I was ready for testing.

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:

  1. This is what I would like it to look like
  2. This is what it currently looks like
  3. 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:

Successfully merged!

The Result

My changes were bundled up and released with version 0.7.0. At the time of writing this, version 0.8.0 is out:

Terminal-Icons version 0.8.0. 

Which means if I go over to check out the icons and colour for .hbs files:

Working coloured and icon'd .hbs files.

They work!

To Conclude

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!".