tput - macOS


tput is a versatile terminal control program that manipulates the appearance and attributes of characters on a terminal screen. It is a powerful tool for customizing terminal environments and controlling text output in various scenarios.


tput [options] [capability]


  • -T TERM: Specify the terminal type.
  • -a: ANSI color escape sequences.
  • -d: Enable cursor and screen manipulation delays.
  • -f FILE: Read capabilities from a file instead of terminfo.
  • -n: Disable auto-padding for strings.
  • -r: Reverse argument order for auto_left_margin and auto_right_margin.
  • -S: Disable printing of trailing newline characters.
  • -s: Silent mode; only returns status codes.


  • Set the cursor position to line 5, column 10:

    tput cup 5 10
  • Enable bold text:

    tput bold
  • Disable cursor visibility:

    tput civis
  • Get the number of rows in the terminal window:

    tput lines

Common Issues

  • Incorrect Terminal: The command may not work as expected if the specified terminal type (TERM) is incorrect or not supported.
  • Unsupported Capability: If a requested capability is not supported by the terminal, it will return an error code.
  • Invalid Syntax: Ensure you enter the command with the correct syntax, including spaces and quotes when necessary.


tput can be combined with other commands and tools to enhance terminal functionality:

  • Set a custom terminal prompt:

    PS1=$(tput setaf 2)\[\u@\]\$(tput setaf 4)\[\w\]\$\[\$/tput sgr0\]
  • Create a fading ASCII art animation:

    for i in {0..100}; do tput rev; ttywrite <<< "Hello World"; tput rev; sleep 0.1; done
  • stty: Configure terminal settings.
  • reset: Reset terminal settings to default.
  • clear: Clear the terminal screen.