Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

ps_tty_size

Query the size of the current terminal


Description

If the standard output of the current R process is not a terminal, e.g. because it is redirected to a file, or the R process is running in a GUI, then it will throw an error. You need to handle this error if you want to use this function in a package.

Usage

ps_tty_size()

Details

If an error happens, the error message is different depending on what type of device the standard output is. Some common error messages are:

  • "Inappropriate ioctl for device."

  • "Operation not supported on socket."

  • "Operation not supported by device."

Whatever the error message, ps_tty_size always fails with an error of class ps_unknown_tty_size, which you can catch.

Examples

# An example that falls back to the 'width' option
tryCatch(
  ps_tty_size(),
  ps_unknown_tty_size = function(err) {
    c(width = getOption("width"), height = NA_integer_)
  }
)

ps

List, Query, Manipulate System Processes

v1.6.0
MIT + file LICENSE
Authors
Jay Loden [aut], Dave Daeschler [aut], Giampaolo Rodola' [aut], Gábor Csárdi [aut, cre], RStudio [cph]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.