Many Things at Once

Several terminals in one window, waiting for things, and running work in parallel.

Updated

Several Terminals

  1. tmux: Panes, Windows and Sessions (Journeyman): tmux runs several terminals inside one window, split into panes and windows, and keeps them in a session that goes on running when you detach, close the window or lose the connection to a server, so you can attach again and carry on.

Waiting and Watching

  1. Waiting for Things: watch, until and timeout (Journeyman): watch reruns a command every few seconds and shows its latest result, an until loop waits until a server answers, and timeout stops a command that takes too long, with exit code 124, so a script never waits forever.
  2. Running Work in Parallel: &, wait and xargs -P (Freelancer): Commands that each take a while can run side by side: & starts each one in the background and wait holds the script until all of them have finished, while xargs -P runs a set number at a time, so 12 one-second photo resizes take 3 seconds instead of 12.

Exercise: Three Things at Once

  1. Exercise: Three Things at Once (Freelancer): Write three tools for a day's work on Bluebird Bakery's website: three-panes.sh sets up the server, the tests rerunning in watch and a free terminal in one tmux session, wait-for-site.sh waits for the site and gives up at a time limit, and resize-all.sh resizes photos four at a time, while a check script tells you what's done.