Morning Tmux Session with Multiple AI Agents
Starting your day with multiple AI agents running in different tmux panes can be handy, or at least it is for me. Here’s a simple script that sets up a four‑pane tmux session, each running kimi in a different directory.
The Script
#!/usr/bin/env bash
CMD1="kimi"
CMD2="kimi"
CMD3="kimi"
CMD4="kimi"
set -euo pipefail
SESSION="morning - or whatever you want"
DEFAULT_DIR="whatever you want"
DIR1="${1:-$DEFAULT_DIR}"
DIR2="${2:-$DEFAULT_DIR}"
DIR3="${3:-$DEFAULT_DIR}"
DIR4="${4:-$DEFAULT_DIR}"
for dir in "$DIR1" "$DIR2" "$DIR3" "$DIR4"; do
if [[ ! -d "$dir" ]]; then
echo "Error: Not a directory: $dir"
exit 1
fi
done
tmux kill-session -t "$SESSION" 2>/dev/null || true
tmux new-session -d -s "$SESSION" -c "$DIR1"
tmux split-window -h -t "$SESSION:0.0" -c "$DIR2"
tmux split-window -v -t "$SESSION:0.0" -c "$DIR3"
tmux split-window -v -t "$SESSION:0.1" -c "$DIR4"
tmux select-layout -t "$SESSION" tiled
send_cmd() {
local pane="$1"
local cmd="$2"
if [[ -n "$cmd" ]]; then
tmux send-keys -t "$pane" "$cmd" Enter
fi
}
send_cmd "$SESSION:0.0" "$CMD1"
send_cmd "$SESSION:0.2" "$CMD2"
send_cmd "$SESSION:0.3" "$CMD3"
send_cmd "$SESSION:0.1" "$CMD4"
tmux select-pane -t "$SESSION:0.0"
tmux attach-session -t "$SESSION"
How It Works
The script creates a tmux session called morning with four equal panes:
┌──────────┬──────────┐
│ Pane 1 │ Pane 2 │
├──────────┼──────────┤
│ Pane 3 │ Pane 4 │
└──────────┴──────────┘
Each pane runs kimi and opens in its own directory. You can specify up to four directories as arguments:
./morning.sh ~/project1 ~/project2 ~/project3 ~/project4
If you don’t specify directories, they all default to the same place (because laziness is a feature). Or you can change the DEFAULT_DIR above to each one of the DIR1, DIR2 etc
Key Features
- send_cmd function: Sends commands to specific panes using tmux send-keys
- Pane targeting: Uses the correct pane indices after splits (0.0, 0.2, 0.3, 0.1)
Usage
Make the script executable and run it:
chmod +x morning.sh
./morning.sh
You’ll get 4 `kimi` agents running in different panes, ready for your morning workflow. Use Ctrl-b + arrow keys to navigate between panes, or Ctrl-b d to detach and tmux attach -t morning to reattach later.
One bone‑headed point: set up your tmux config to
# Enable mouse support
set -g mouse on
# Reload config with Prefix + r
bind r source-file ~/.tmux.conf \; display "Reloaded!"
Result should look like below :)
