summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorSean Kurtz <seankurtz75@gmail.com>2026-11-25 21:51:00 -0600
committerGitHub <noreply@github.com>2026-11-25 21:51:00 -0600
commit3cec5cdebb48973b58e9131b53d4fdbb08cf98b6 (patch)
tree6929c120151cd3d6c69f925b7c28a3220734dc51
parent1724a442e6f984278923dd56b3ee68e743eebee4 (diff)
parentcf9ba0191735a811b64d05f163ba275dd1d327d1 (diff)
downloadztop-3cec5cdebb48973b58e9131b53d4fdbb08cf98b6.tar.gz
Merge pull request #3 from skurtz97/fix/default-tui
Bare ztop on a terminal starts the TUI
-rw-r--r--README.md9
-rw-r--r--src/ztop.c8
2 files changed, 13 insertions, 4 deletions
diff --git a/README.md b/README.md
index 4fec439..3f57e76 100644
--- a/README.md
+++ b/README.md
@@ -54,7 +54,8 @@ make demo TESTCC=cc # the library on its own
## Use
```text
-ztop one-shot CSA
+ztop full-screen view when stdout is a terminal,
+ else one-shot CSA
ztop -a sqa SQA, -a lsqa, -a pvt
ztop -a csa,pvt several areas
ztop -s system name, host, release, address-space count
@@ -63,8 +64,10 @@ ztop -x dump the raw VSMLIST work and data areas
ztop -d [seconds] interactive, 2 s refresh (1..60)
```
-Without `-d` the bytes go to standard output, suitable for `grep` and for a
-shell prompt. With `-d` there are three views, selected with `TAB`:
+With a terminal and no report option, `ztop` starts the full-screen view.
+Anything that selects a report (`-a`, `-s`, `-j`, `-x`) or pipes the output
+gets the one-shot text instead, suitable for `grep` and for a shell
+prompt. There are three views, selected with `TAB`:
| view | |
| --- | --- |
diff --git a/src/ztop.c b/src/ztop.c
index 1d32e6d..9078739 100644
--- a/src/ztop.c
+++ b/src/ztop.c
@@ -573,7 +573,7 @@ static void usage(FILE *f) {
" -s system name, host, release and address-space count\n"
" -j one line per address space\n"
" -x dump the VSMLIST work and data areas (one-shot only)\n"
- " -d interactive view, refreshed every 2 seconds by default\n"
+ " -d force the interactive view (the default on a terminal)\n"
" -h this text\n");
}
@@ -775,6 +775,12 @@ int main(int argc, char **argv) {
}
}
+ /* A bare `ztop` on a terminal is the full-screen view; anything that
+ * selects a report, or a pipe, keeps the one-shot output. */
+ if (!interactive && !dump && !want_sys && !want_jobs && mask == 0 &&
+ isatty(STDOUT_FILENO))
+ interactive = true;
+
if (interactive) {
if (dump)
(void)fprintf(stderr, "ztop: -x is ignored with -d\n");