diff --git a/default/bash/fns/tmux b/default/bash/fns/tmux index 338d1853..0144f2eb 100644 --- a/default/bash/fns/tmux +++ b/default/bash/fns/tmux @@ -1,12 +1,13 @@ # Create a Tmux Dev Layout with editor, ai, and terminal -# Usage: tdl +# Usage: tdl [] tdl() { - [[ -z $1 ]] && { echo "Usage: tdl "; return 1; } + [[ -z $1 ]] && { echo "Usage: tdl []"; return 1; } [[ -z $TMUX ]] && { echo "You must start tmux to use tdl."; return 1; } local current_dir="${PWD}" - local editor_pane ai_pane + local editor_pane ai_pane ai2_pane local ai="$1" + local ai2="$2" # Use TMUX_PANE for the pane we're running in (stable even if active window changes) editor_pane="$TMUX_PANE" @@ -20,6 +21,12 @@ tdl() { # Split editor pane horizontally - AI on right 30% (capture new pane ID directly) ai_pane=$(tmux split-window -h -p 30 -t "$editor_pane" -c "$current_dir" -P -F '#{pane_id}') + # If second AI provided, split the AI pane vertically + if [[ -n $ai2 ]]; then + ai2_pane=$(tmux split-window -v -t "$ai_pane" -c "$current_dir" -P -F '#{pane_id}') + tmux send-keys -t "$ai2_pane" "$ai2" C-m + fi + # Run ai in the right pane tmux send-keys -t "$ai_pane" "$ai" C-m @@ -31,12 +38,13 @@ tdl() { } # Create multiple tdl windows with one per subdirectory in the current directory -# Usage: tdlm +# Usage: tdlm [] tdlm() { - [[ -z $1 ]] && { echo "Usage: tdlm "; return 1; } + [[ -z $1 ]] && { echo "Usage: tdlm []"; return 1; } [[ -z $TMUX ]] && { echo "You must start tmux to use tdlm."; return 1; } local ai="$1" + local ai2="$2" local base_dir="$PWD" local first=true @@ -49,11 +57,11 @@ tdlm() { if $first; then # Reuse the current window for the first project - tmux send-keys -t "$TMUX_PANE" "cd '$dirpath' && tdl $ai" C-m + tmux send-keys -t "$TMUX_PANE" "cd '$dirpath' && tdl $ai $ai2" C-m first=false else local pane_id=$(tmux new-window -c "$dirpath" -P -F '#{pane_id}') - tmux send-keys -t "$pane_id" "tdl $ai" C-m + tmux send-keys -t "$pane_id" "tdl $ai $ai2" C-m fi done }