This seems create a bunch of rows with a single column. I am trying to create 2 columns, and then all the rows needed.
#!/usr/bin/env bash
(
unset TMUX
export session_uuid="$(uuidgen)"
remove_tmux_session() {
tmux kill-session -t "$session_uuid"
}
export -f remove_tmux_session
trap remove_tmux_session TERM INT SIGINT SIGTERM
echo "TMUX session id: $session_uuid"
tmux new -d -s "$session_uuid"
tmux set-option -g update-environment "remove_tmux_session session_uuid"
Run kubectl get pods and skip the header line
kubectl get pods | tail -n +2 | while read -r line; do
# Extract the first column (pod name)
pod_name=$(echo "$line" | awk '{print $1}')
# Run kubectl logs for each pod in a new tmux pane
tmux split-window -v -t "$session_uuid" "kubectl logs '$pod_name' -f"
tmux select-layout even-vertical
# Create a new horizontal split for the second column
tmux split-window -h -t "$session_uuid" "echo 'Second Column'"
# Move to the next vertical pane in the new column
tmux select-pane -t :.+
# Create a new vertical split for the next row
tmux split-window -v -t "$session_uuid" "echo 'Next Row'"
# Move to the next horizontal pane in the new row
tmux select-pane -t :.+
# Repeat the process for additional rows/columns as needed
done
Attach to the tmux session
tmux attach-session -d -t "$session_uuid"
)
anyone know how to create 2 columns and then put each process inside a different row in the 2 column grid?
I am on Macos, Tmux version 3.3a
tmux split-window ...
,tmux select-layout even-vertical ....
andtmux select-pane ...
etc, it sounds self-describing. Do these cmds work from the basic cmd-line (without thekubectl get pods ... | while ...
wrapper? One of the few times a graphic image could help with question? Or at least an ascii-art drawing? Is there another term? I think of columns being inside of terminal's border. Good luck. – shellter Feb 06 '24 at 01:05tmux split-window -h -t "$session_uuid" "echo 'Second Column'"
– A pane that only executesecho
will exit immediately and be destroyed, unlessremain-on-exit
tmux option ison
for it. Please confirm you set this option toon
and the behavior I described is not a part of the problem. – Kamil Maciorowski Feb 06 '24 at 18:24