Created
March 15, 2014 20:32
-
-
Save agonzalezro/9573541 to your computer and use it in GitHub Desktop.
Tail several logs with tmux
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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