The d command
Run make or other commands in the background, with output to a file.

If you use the command line very much at all...

Usage: d [ -f file ] c[n][a][x][+][f|p] cmd [ arg ... ]
or:    d [ -f file ] m[n][a][x][+][f|p] [ make-arg ... ]
or:    d [ -f file ] s[n][a][x][+][f|p] [ additional-arg ... ]
or:    d [ -f file ] h
or:    d   -f file

Run a command in the background, with its stdout and stderr redirected to a file called 'out' or to file. The last form above changes this name persistently in the $yostD_OUTFILE shell variable, which defaults to 'out'.

The d command does
   mv ,out out
before creating a new 'out' file unless told to append instead.

The first argument to the d command, the task argument, must consist of exactly one of these:
c Run the following command. If escaped, you can use ; | > etc.
m Run 'make'.
s Run the same command again (extract the last command from 'out', and run it again (without 'nice' unless you ask for 'nice' again).
h Print a history of what happened 'out'.
You can add one of these:
p Just print the command that would be executed; don't run it.
f Waitt for it, and tail -f 'out'.
w Waitt for it.
and any of these:
n Do it 'nice'ly.
a Append to 'out'.
x Clear the screen.
r Do it as root (easier if sudo is warmed up, as with 'sudo true'.
+ Filter the command through the program 'c++filt'.
! Disown the process, so it will continue if you log out.

The d command comes along with several helper shell functions:

q tail -f out
qq cat out
qt tail -20 out
cq clear ; q
cqq clear ; qq
wq wait "$@" ; printf "\b" ; qq
wqt wait "$@" ; printf "\b" ; qt

The output from d into the file 'out' consists of
   prologue
   output from the command
   epilogue
as shown in the example below, which does this:

223 Z% d c 'sleep 5 ; echo Hello Folks'
[3] 3937
224 Z% 
[3]  + 3937 done       yostD_runCmd
224 Z% d sna
[ sleep 5 ; echo Hello Folks ]
[3] 3965
225 Z% 
[3]  + 3965 done       yostD_runCmd
225 Z% qq
=d= tbegin 2012-02-07T03:03:54 EST Tue
=d= see    http://yost.com/computers/d/
=d= host   ip2
=d= uname  Darwin ip2 11.3.0 Darwin Kernel Version 11.3.0: Thu Jan 12 18:47:41 PST 2012; root:xnu-1699.24.23~1/RELEASE_X86_64 x86_64
=d= wd     /Users/yost/web/yost/yost.com/computers/d
=d= cmd    sleep 5 ; echo Hello Folks
=d= -begin / - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \
Hello Folks
  0.00s user 0.01s system 0% cpu 5.016 total
=d= -end   \ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /
=d= stat   0
=d= tend   2012-02-07T03:03:59 EST Tue
========== =====================================================================
=d= tbegin 2012-02-07T03:04:09 EST Tue
=d= see    http://yost.com/computers/d/
=d= host   ip2
=d= uname  Darwin ip2 11.3.0 Darwin Kernel Version 11.3.0: Thu Jan 12 18:47:41 PST 2012; root:xnu-1699.24.23~1/RELEASE_X86_64 x86_64
=d= wd     /Users/yost/web/yost/yost.com/computers/d
=d= cmd    nice sleep 5 ; echo Hello Folks
=d= -begin / - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \
Hello Folks
  0.00s user 0.01s system 0% cpu 5.016 total
=d= -end   \ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /
=d= stat   0
=d= tend   2012-02-07T03:04:14 EST Tue
========== =====================================================================
226 Z% d sp
sleep 5 ; echo Hello Folks     
227 Z% d h
tbegin 2012-02-07T03:03:54 EST Tue
cmd    sleep 5 ; echo Hello Folks
stat   0
tend   2012-02-07T03:03:59 EST Tue
====== =====================================================================
tbegin 2012-02-07T03:04:09 EST Tue
cmd    nice sleep 5 ; echo Hello Folks
stat   0
tend   2012-02-07T03:04:14 EST Tue
====== =====================================================================
228 Z% 

Download d.sh.

To use the d command and its helpers, you need to source d.sh from your zsh, bash, ksh, or sh. If your system does not have the tac command, you will need to install it for the s command to work.

I have tested this only with zsh 4.3.11 and bash 43.2.48(1)-release. Please feel free to send bug fixes.


http://Yost.com/computers/d/ - this page
1991-04-xx 2.0 Separate, sourceable file for zsh
2004-12-19 4.0
2006-07-09 5.0 Published on the web
2006-07-09 5.1 License fixed
2006-07-14 5.2 'd s' now echoes the command it will execute.
2006-12-14 5.3 fix "d s" bug when 'out' file doesn't exist
2006-12-27 5.4 make it work with bash, ksh, and sh
2006-12-28 6.0 New options: f tail -f, x clear, + c++filt
2010-08-07 6.1 Cleaned up the --help
2012-02-08 7.0 Help improvements, new =d= line beginning, lots of cleanup
2013-01-13 8.0 Added space after =d= line beginning, -begin and -end