Coder Social home page Coder Social logo

liamg / tml Goto Github PK

View Code? Open in Web Editor NEW
729.0 8.0 19.0 52 KB

:rainbow::computer::art: A tiny markup language for terminal output. Makes formatting output in CLI apps easier!

License: The Unlicense

Go 95.11% Makefile 4.89%
terminal tui terminal-ui colours colors cli cli-app

tml's Introduction

tml - Terminal Markup Language

Build Status GoDoc

A Go module (and standalone binary) to make the output of coloured/formatted text in the terminal easier and more readable.

You can use it in your Go programs, and bash etc. too.

Example screenshot

Usage in Go

The output of coloured/formatted text is easy using the following syntax:

package main

import "github.com/liamg/tml"

func main() {
    tml.Printf("<red>this text is <bold>red</bold></red> and the following is <green>%s</green>\n", "not red")
}

Usage in Bash

First, install tml:

Install Go and run the following command.

# For Go 1.16+
# Make sure that `$GOPATH/bin` is in your `$PATH`, because that's where this gets installed

go install github.com/liamg/tml/tml@latest

# For Go <1.16

go get -u github.com/liamg/tml/tml

Then you can simply pipe text containing tags to tml:

#!/bin/bash

echo "<red>this text is <bold>red</bold></red> and the following is <green>not red</green>" | tml

Format

Each tag is enclosed in angle brackets, much like HTML.

You can nest tags as deeply as you like.

It's not required to close tags you've opened, though it can make for easier reading.

Available Tags

Foreground Colours

  • <red>
  • <green>
  • <yellow>
  • <blue>
  • <magenta>
  • <cyan>
  • <lightgrey>
  • <darkgrey>
  • <black>
  • <white>
  • <lightred>
  • <lightgreen>
  • <lightyellow>
  • <lightblue>
  • <lightmagenta>
  • <lightcyan>

Background Colours

  • <bg-red>
  • <bg-green>
  • <bg-yellow>
  • <bg-blue>
  • <bg-magenta>
  • <bg-cyan>
  • <bg-lightgrey>
  • <bg-darkgrey>
  • <bg-black>
  • <bg-white>
  • <bg-lightred>
  • <bg-lightgreen>
  • <bg-lightyellow>
  • <bg-lightblue>
  • <bg-lightmagenta>
  • <bg-lightcyan>

Attributes

  • <bold>
  • <dim>
  • <italic>
  • <underline>
  • <blink>
  • <reverse>
  • <hidden>

tml's People

Contributors

0xbharath avatar liamg avatar owenrumney avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tml's Issues

Package availability

My team does a lot of bash scripting as part of our development tools, and TML looks really interesting. We currently have custom echo_<color> commands duplicated across several repositories, and it would be great if we could drop those.

I think the two things that we would need to roll TML out across several repos would be:

  • A maintained Homebrew package so our team could locally run brew install tml.
  • A maintained Debian package so we could install the tool inside of our Docker images.

Would you be open to adding those things to this repository? We could contribute if that would be helpful.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.