Tput: Difference between revisions

From wikinotes
No edit summary
No edit summary
Line 11: Line 11:
</blockquote><!-- Documentation -->
</blockquote><!-- Documentation -->


= Size =
= Console Info =
<blockquote>
<blockquote>
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
Line 17: Line 17:
tput cols  # width of terminal in chars
tput cols  # width of terminal in chars
</syntaxhighlight>
</syntaxhighlight>
</blockquote><!-- Size -->
</blockquote><!-- Console Info -->
 
= Text Formatting =
<blockquote>
<syntaxhighlight lang="bash">
# colour
tput setaf 1  # set foreground colour to 1/255 (red)
tput setab 1  # set foreground colour to 1/255 (red)
 
# weight
tput bold  # bold
tput smul  # underline
 
# reset
tput sgr0    # reset formatting
</syntaxhighlight>
</blockquote><!-- Text Formatting -->

Revision as of 17:10, 18 July 2021

The Termcap DB is a library/db that abstracts control codes to manipulate a terminal.
The tput command can interact with it from shellscript.

Documentation

man tput https://man.archlinux.org/man/core/ncurses/tput.1.en

Console Info

tput lines  # height of terminal in chars
tput cols   # width of terminal in chars

Text Formatting

# colour
tput setaf 1  # set foreground colour to 1/255 (red)
tput setab 1  # set foreground colour to 1/255 (red)

# weight
tput bold  # bold
tput smul  # underline

# reset
tput sgr0     # reset formatting