Skip to content

Instantly share code, notes, and snippets.

@agonzalezro
Created March 15, 2014 20:32
Show Gist options
  • Save agonzalezro/9573541 to your computer and use it in GitHub Desktop.
Save agonzalezro/9573541 to your computer and use it in GitHub Desktop.
Tail several logs with tmux
#!/bin/bash
if [ "$#" -ne 1 ]; then
echo "I need the log base name"
exit
fi
SESSION=`echo $1|cut -d. -f1`
tmux new-session -s $SESSION -n $SESSION -d
tmux send-keys -t $SESSION:0.0 "tail -f $1" C-m
# 10 should be enough
i=0
while [ 1 ]; do
i=`expr $i + 1`
if [ -e "$1.$i" ]; then
tmux split-window -v -t $SESSION
tmux send-keys -t $SESSION:0.$i "tail -f $1.$i" C-m
tmux select-layout -t $SESSION even-vertical
continue
fi
break
done
tmux attach -t $SESSION
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment