summary refs log tree commit diff
diff options
context:
space:
mode:
authorChristian Neukirchen <chneukirchen@gmail.com>2015-08-10 14:01:22 +0200
committerChristian Neukirchen <chneukirchen@gmail.com>2015-08-10 14:01:22 +0200
commit83932d1c5d3e538eb543b73bbdf6dfa339530da3 (patch)
treef5d5e505d600512c07e3b9e4d872059273c8b2fd
parent62bf9cc5a08d524c2acaff22c34ff5c6943e2454 (diff)
downloadnq-83932d1c5d3e538eb543b73bbdf6dfa339530da3.tar.gz
nq-83932d1c5d3e538eb543b73bbdf6dfa339530da3.tar.xz
nq-83932d1c5d3e538eb543b73bbdf6dfa339530da3.zip
tq: add screen(1) support
-rw-r--r--README.md6
-rwxr-xr-xtq22
2 files changed, 18 insertions, 10 deletions
diff --git a/README.md b/README.md
index 4a3e324..cc5fa41 100644
--- a/README.md
+++ b/README.md
@@ -68,10 +68,10 @@ Two helper programs are provided:
 jobs are done.  If no job is running, the output of the last job is
 shown.  `fq -a` shows the output of all jobs, `fq -q` only shows one
 line per job.  `fq` uses `inotify` on Linux and falls back to polling
-for size change else.  `fq.sh` is a similar tool, not quite as robust,
-implemented as shell-script calling `tail`.
+for size change else.  (`fq.sh` is a similar tool, not quite as robust,
+implemented as shell-script calling `tail`.)
 
-`tq` wraps `nq` and displays the `fq` output in a new tmux window.
+`tq` wraps `nq` and displays the `fq` output in a new tmux or screen window.
 
 (A pure shell implementation of `nq` is provided as `nq.sh`.  It needs
 `flock` from util-linux, and only has a timer resolution of 1s.
diff --git a/tq b/tq
index 882a8b8..b3449c4 100755
--- a/tq
+++ b/tq
@@ -1,5 +1,5 @@
 #!/bin/sh
-# tq CMD... - tmux wrapper for nq to display output in new window
+# tq CMD... - tmux/screen wrapper for nq to display output in new window
 
 set -e
 
@@ -8,10 +8,18 @@ p=${s##*.}
 
 printf '%s\n' "$s"
 
-if [ -n "$p" ] && [ -n "$TMUX" ]; then
-	tmux new-window -a -d -n '<' -c '#{pane_current_path}' \
-		"trap true INT QUIT TERM EXIT;
-		 fq $s || kill $p;
-		 printf '[%d exited, ^D to exit.]\n' $p;
-		 cat >/dev/null"
+if [ -n "$p" ]; then
+       	if [ -n "$TMUX" ]; then
+		tmux new-window -a -d -n '<' -c '#{pane_current_path}' \
+			"trap true INT QUIT TERM EXIT;
+			fq $s || kill $p;
+			printf '[%d exited, ^D to exit.]\n' $p;
+			cat >/dev/null"
+	elif [ -n "$STY" ]; then
+		screen -t '<' sh -c "trap true INT QUIT TERM EXIT;
+			fq $s || kill $p
+			printf '[%d exited, ^D to exit.]\n' $p;
+			cat >/dev/null"
+		screen -X other
+	fi
 fi