watch
with shell scripting on OpenBSDI use a command line task manager, called TaskWarrior, to organise the stuff I need to do. While I can access it from any shell on my sever, I keep a special tmux
session open where I usually go to organise my tasks. The main window of the session is split in two sections: on the right just a normal shell, but on the left I want a continuously updated list of tasks which are ready for me to do them.
The command to see a list of ready tasks is just task ready
, but comming from Linux I would have expected the following to work:
gandalf$ watch 'task ready'
ksh: watch: not found
watch
is a Linux command which runs a command in a loop with a 2 sec delay between each iteration. Unfortunately, this command is not part of the default OpenBSD installataion. There is a package called gnuwatch
, but I decided just to go with a shell loop:
gandalf$ while() { clear ; task ready ; sleep 3 ; }
⋯
Success‽ Not really. Technically this works, but there is an annoying flicker after the screen is cleared, while task ready computes the list, before any text appears.
The standard solution to this problem is to buffer the output of the command and only clear the screen after the command has run. TaskWarrior – being a fancy, modern CLI program – uses colours to make the list more readable. And, if you redirect the output to something else than a terminal, TaskWarrior will detect this and not output any colors. So, it seems that if we buffer to a file, we loose the colours.
Here I learned something new: There is a command for recording the output of a terminal – colours and all! script(1)
takes a file argument where it will store everything which is output in a session. So, the nice colourful watch
replacement is now:
tmpfile=$(mktemp) ;
while () {
script -c "task ready" $tmpfile > /dev/null ;
clear ;
cat $tmpfile ;
sleep 3 ;
}
Perfect! ☺
IPC mechanisms are on my mind these days – could there be a dependently typed IPC mechanism? And also desentralised network protocols. And capability based security. The questions I have about the former two are still to vague to be stated aloud.
Recovering from a cold. Got through “Soldiers live”, the final book in Glen Cook’s series on The Black Company. I have enjoyed the series, but from the very beginning I was worried that the end was not going to be satisfactory. But I was positively surprised!
My article on non-wellfounded sets in HoTT has found its way to arXiv.
The last few months have been hectic, but today I took time to start swimming again. At work I am making exam exercises for the re-take exam for my course. The lecture slides from my course are now available online.
Expecting a comment section? Feel free to e-mail me your comments, or otherwise contact me to discuss the content of this site. See my contact info. You can also write your opinion on your own website, and link back here! ☺