aboutsummaryrefslogtreecommitdiff
path: root/toys/other/reset.c
blob: aa9b74eabb5c996307f95a7d6956a5d16e763d74 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/* reset.c - reset the terminal.
 *
 * Copyright 2015 Rob Landley <rob@landley.net>
 *
 * No standard.

USE_RESET(NEWTOY(reset, 0, TOYFLAG_USR|TOYFLAG_BIN))

config RESET
  bool "reset"
  default y
  help
    usage: reset

    reset the terminal
*/
#include "toys.h"

void reset_main(void)
{
  int fd = tty_fd();

  // man 4 console_codes: reset terminal is ESC (no left bracket) c
  xwrite(fd<0 ? 1 : fd, "\033c", 2);
}