Changing Font Colour and making text bold in TCL

Is it possible to change colour of text and make it bold from TCL script and output it in console/terminal?

I found this on example on the forum but I get following error:

ERROR: couldn't execute "tput": no such file or directory procedure "color" line 4:

Wondered if someone can advise.

Thanks in advance,

Example from reference post (see link above), example provided by Donal Fellows

proc color {foreground text} {
    # tput is a little Unix utility that lets you use the termcap database
    # *much* more easily...
    return [exec tput setaf $foreground]$text[exec tput sgr0]

puts "Why not [color 4 G][color 1 o][color 3 o][color 4 g][color 2 l][color 1 e] first?"
# Hmm, that's clearer than using those escapes directly too!


tput is a linux command which is part of the ncurses package. if you are not using any linux flavours OR ncurses package is not installed properly- you will get this error. So if you are using

linux- check ncurses library is installed or not.


Its better use twapi package.

Install twapi.

teacup install twapi

Try below in tclsh.

# Import package twapi
package require twapi

# Get handler of console
set hndl [twapi::get_console_handle stdout]

# Set console foreground color to red
twapi::_set_console_default_attr $hndl fgred 1

Refer this link1link2

Need Your Help

Is it possible to NOT embed fonts in a PDF generated with PDFKit?

cocoa pdf embedded-fonts pdfkit

I'm generating PDF documents with PDFKit and I'd like to have it not embed the standard PDF fonts (Times, Helvetica, Courier) if possible.

IPhone SDK removal of NSLog causes NSArray to be undeclared !

iphone sdk nsarray

I have a working application I'm about to distribute and am tidying up NSLog statements in it. When I remove NSLog from from a "case" statement, the NSArray declared within the "case" statement err...