# "tput sgr0" giving an empty string



## bolt (Jan 29, 2012)

I installed FreeBSD 9 in a virtual machine to try it out. I installed bash, and attempted to use tput to provide colors for my scripts. However, I have a slight problem with it.


```
[[ -n "$(TERM=rxvt tput sgr0)" ]] || echo fail
fail
[[ -n "$(TERM=xterm tput sgr0)" ]] || echo fail
fail
[[ -n "$(TERM=xterm-color tput sgr0)" ]] || echo fail
fail
```
I asked around a bit and was told to check infocmp. I googled, found it was part of ncurses, so I did *pkg_add -r ncurses*.

Now I have infocmp, which lists a whole lot of information about my default terminal, rxvt. tput still provides nothing but empty strings however.

How do I make tput output something useful? I'd rather not use hardcoded colors, as the scripts I'm trying to port from Linux use tput for their colors already and I want to change them as little as possible.

I am connecting to the machine through SSH, by the way.


----------



## itcotbtoemik (Jan 29, 2012)

*tput sgr0*

The tput in FreeBSD's base uses termcap mnemonics. It is not part of ncurses. The ncurses tput recognizes either termcap or terminfo mnemonics if it is configured to support termcap parsing (barring one special case which is ambiguous).

The termcap mnemonic corresponding to sgr0 is "md".


----------



## itcotbtoemik (Jan 29, 2012)

If you have installed the ncurses port, then its tput is in /usr/local/bin (which I have ahead of /usr/bin in my non-root path).


----------



## bolt (Jan 30, 2012)

Using /usr/local/bin/tput (if available) when my script runs on FreeBSD solved the color problem.
Thanks a bunch!


----------



## itcotbtoemik (Jan 31, 2012)

no problem (report bugs)


----------

