chalk.ahk - An AutoHotkey library for colorizing terminal output

Post your working scripts, libraries and tools for AHK v1.1 and older
joshuacc
Posts: 3
Joined: 28 Oct 2022, 20:50
Contact:

chalk.ahk - An AutoHotkey library for colorizing terminal output

Post by joshuacc » 19 Nov 2022, 13:27

Hi folks! First time posting here, and wanted to share my new library chalk.ahk, which is inspired by the JavaScript chalk library.

https://github.com/joshuacc/chalk.ahk

Usage

Chalk builds colorized strings using property and method chaining, which is easy both to read and to write.

Example

Code: Select all

 ; Include chalk.ahk. The path may be different on your system.
#Include, %A_ScriptDir%\ahkpm-modules\github.com\joshuacc\chalk.ahk\chalk.ahk

; Make a terminal styled and colored string
loudWarning := chalk.bold.red.underline("This is not a drill!")

; Output the string to stdOut
FileAppend, %loudWarning%, *

; Make another string
quietCorrection := chalk.cyan("`r`nManagement sincerely apologizes. This is actually a drill.`r`n")

; Output the string to stdOut
FileAppend, %quietCorrection%, *
This will produce the following output. (Exact colors vary depending on your terminal settings.)

43DDBECD-9876-4AE4-B4E9-67635D5F1C78.png
43DDBECD-9876-4AE4-B4E9-67635D5F1C78.png (7.38 KiB) Viewed 673 times

For more details, see the GitHub link above.




Post Reply

Return to “Scripts and Functions (v1)”