Add Segment
#
Create the logicAdd a new file in the ./src/segments
folder: new.go
.
Ensure New
is a single verb indicating the context the segment renders.
You can use the following template as a guide.
When it comes to icon Properties, make sure to use the UTF32 representation (e.g. "\uEFF1") rather than the icon itself. This will facilitate the review process as not all environments display the icons based on the font being used. You can find these values and query for icons easily at Nerd Fonts.
For each segment, there's a single test file ensuring the functionality going forward. The convention
is new_test.go
, have a look at existing segment tests for inspiration. Oh My Posh makes
use of the test tables pattern for all newly added tests. See this blog post for more information.
#
Create a name for your Segmentsegment.go
contains the list of available SegmentType
's, which gives them a name we can map from the
.json
themes.
Add your segment.
#
Add the SegmentType mappingMap your SegmentType
to your Segment in the mapSegmentWithWriter
function (respect the alphabetical order).
#
Test your functionalityEven with unit tests, it's a good idea to build and validate the changes:
#
Add the documentationCreate a new markdown
file underneath the docs/docs/segments
folder called new.md
.
Use the following template as a guide.
#
Map the new documentation in the sidebarOpen sidebars.js
and add your document id (new
) to the items of the Segments category.
#
Add the JSON schemaEdit the themes/schema.json
file to add your segment.
At $.definitions.segment.properties.type.enum
, add your SegmentType
to the array:
At $.definitions.segment.allOf
, add your segment details:
#
Create a pull requestAnd be patient, I'm going as fast as I can ๐