Simple terminal color manipulation for Linux/Unix systems using ANSI escape codes.
- 🎨 16 colors (8 normal + 8 bright)
- 📝 Text color manipulation
- 🖼️ Background color manipulation
- 🖥️ Full terminal screen coloring
- 🧹 Clear screen
- 🔄 Reset to default colors
- 📦 Zero dependencies
- 🐧 Linux/Unix/Mac compatible
go get github.com/ams-tech-fin/tcspackage main
import (
"fmt"
"github.com/ams-tech-fin/tcs"
)
func main() {
// Set text color
tcs.SetTextColor(tcs.BrightRed)
fmt.Println("Red text")
// Set background color
tcs.SetBackgroundColor(tcs.Blue)
fmt.Println("Blue background")
// Set both
tcs.SetColors(tcs.BrightYellow, tcs.Blue)
fmt.Println("Yellow on blue")
// Reset colors
tcs.Reset()
}tcs.Black
tcs.Red
tcs.Green
tcs.Yellow
tcs.Blue
tcs.Magenta
tcs.Cyan
tcs.White
tcs.BrightBlack // Gray
tcs.BrightRed
tcs.BrightGreen
tcs.BrightYellow
tcs.BrightBlue
tcs.BrightMagenta
tcs.BrightCyan
tcs.BrightWhiteSets the text color.
tcs.SetTextColor(tcs.BrightGreen)
fmt.Println("Green text")Sets the background color.
tcs.SetBackgroundColor(tcs.Red)
fmt.Println("Red background")Sets both text and background colors.
tcs.SetColors(tcs.White, tcs.Black)
fmt.Println("White on black")Fills the entire terminal with a background color.
tcs.SetFullBackground(tcs.Blue)
fmt.Println("Entire terminal is now blue")Fills the entire terminal with text and background colors.
tcs.SetFullColors(tcs.BrightCyan, tcs.Blue)
fmt.Println("Commodore 64 style!")Clears the terminal screen.
tcs.ClearScreen()Resets colors to terminal defaults.
tcs.Reset()Prints formatted colored text and automatically resets colors.
tcs.Printf(tcs.BrightGreen, tcs.Black, "Hello %s!\n", "World")Prints a colored line and automatically resets colors.
tcs.Println(tcs.BrightCyan, tcs.Black, "Colored line")package main
import (
"fmt"
"github.com/ams-tech-fin/tcs"
)
func main() {
tcs.SetFullColors(tcs.BrightCyan, tcs.Blue)
fmt.Println("\n **** COMEDORME 64 GOLANG V1 ****")
fmt.Println("\n 64K RAM SYSTEM 38911 BASIC BYTES FREE")
fmt.Println("\n READY.")
fmt.Println(" █")
fmt.Println()
}package main
import (
"fmt"
"github.com/ams-tech-fin/tcs"
)
func main() {
tcs.SetFullColors(tcs.BrightGreen, tcs.Black)
fmt.Println("\n RETRO TERMINAL v1.0")
fmt.Println(" > System initialized")
fmt.Println(" > Ready for commands")
}package main
import (
"fmt"
"github.com/ams-tech-fin/tcs"
)
func LogInfo(msg string) {
tcs.Printf(tcs.BrightCyan, tcs.Black, "[INFO] %s\n", msg)
}
func LogError(msg string) {
tcs.Printf(tcs.BrightRed, tcs.Black, "[ERROR] %s\n", msg)
}
func LogSuccess(msg string) {
tcs.Printf(tcs.BrightGreen, tcs.Black, "[OK] %s\n", msg)
}
func main() {
LogInfo("Starting application...")
LogSuccess("Connected to database")
LogError("Failed to load config")
}package main
import (
"fmt"
"github.com/ams-tech-fin/tcs"
)
func main() {
colors := []struct {
color tcs.Color
name string
}{
{tcs.Black, "Black"},
{tcs.Red, "Red"},
{tcs.Green, "Green"},
{tcs.Yellow, "Yellow"},
{tcs.Blue, "Blue"},
{tcs.Magenta, "Magenta"},
{tcs.Cyan, "Cyan"},
{tcs.White, "White"},
{tcs.BrightRed, "BrightRed"},
{tcs.BrightGreen, "BrightGreen"},
{tcs.BrightYellow, "BrightYellow"},
{tcs.BrightBlue, "BrightBlue"},
{tcs.BrightMagenta, "BrightMagenta"},
{tcs.BrightCyan, "BrightCyan"},
{tcs.BrightWhite, "BrightWhite"},
}
fmt.Println("Available colors:")
for _, c := range colors {
tcs.SetTextColor(c.color)
fmt.Printf("█ %-20s", c.name)
tcs.SetBackgroundColor(c.color)
fmt.Print(" ")
tcs.Reset()
fmt.Println()
}
}- ✅ Linux
- ✅ macOS
- ✅ Unix-like systems
MIT License - feel free to use in your projects!
Contributions are welcome! Please feel free to submit a Pull Request.
Created with ❤️ for André "Dex" Mendonça e Silva