#!/usr/bin/env bash SESSION="circolog" DAEMON="d" WINDOW="${SESSION}:${DAEMON}" send_command() { tmux send-keys -t "${WINDOW}.${1}" "${2}" Enter } digit_command() { local input=$2 for (( i=0; i<${#input}; i++ )) do sleep 0.1 tmux send-keys -t "${WINDOW}.${1}" "${input:$i:1}" done sleep 2 tmux send-keys -t "${WINDOW}.${1}" Enter } digit_comment() { local input=$2 for (( i=0; i<${#input}; i++ )) do sleep 0.1 tmux send-keys -t "${WINDOW}.${1}" "${input:$i:1}" done sleep 2 for (( i=0; i<${#input}; i++ )) do tmux send-keys -t "${WINDOW}.${1}" "C-h" done } config() { tmux new -s $SESSION -n $DAEMON -d tmux set-option -t $SESSION status off tmux split-window -v -t $WINDOW send_command 0 "bash" send_command 1 "bash" send_command 0 "PS1='my-server ~ '" send_command 1 "PS1='my-server ~ '" send_command 0 "clear" send_command 1 "clear" } start_circologd() { sleep 3; digit_comment 0 "Let's start circologd in foreground. It can be put in background as an ordinary unix process and will keep on listening." digit_command 0 "circologd" } start_ctl() { sleep 20; digit_comment 1 "Let's also play with the control utility for circologd, circologctl." sleep 1 digit_command 1 "circologctl status" sleep 3 digit_comment 1 "circologd can be paused..." digit_command 1 "circologctl pause" sleep 3; digit_comment 1 "...and unpaused" digit_command 1 "circologctl pause" sleep 3 digit_comment 1 "A filter can be applied, so that circologd record only some messages." digit_command 1 "circologctl filter 'msg LIKE \"%interested%\"'" sleep 1 digit_command 1 "circologctl status" } attach_session() { tmux attach -t $SESSION } cleanup() { send_command 0 "C-c" tmux kill-session -t $SESSION } trap cleanup 2 15 config start_circologd & start_ctl & attach_session