Skip to content

Commit 1f11f0f

Browse files
committed
dx: 🌟 new tmux function to spin up a session
1 parent 0ccf016 commit 1f11f0f

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

zsh/.zshrc

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,33 @@ alias tn="tmux new-session -s \$(pwd | sed 's/.*\///g')"
200200
alias td="tmux detach"
201201
alias mat='osascript -e "tell application \"System Events\" to key code 126 using {command down}" && tmux neww "cmatrix"'
202202

203+
# Create a tmux layout for dev with editor, ai, and terminal
204+
tml() {
205+
local current_dir="${PWD}"
206+
local session_name="${current_dir##*/}"
207+
local editor_pane ai_pane
208+
local ai="opencode"
209+
# If not inside tmux, create a session and run tml inside it
210+
if [[ -z "$TMUX" ]]; then
211+
tmux new-session -d -s "$session_name" -c "$current_dir"
212+
tmux send-keys -t "$session_name" "tml $ai" C-m
213+
tmux attach -t "$session_name"
214+
return
215+
fi
216+
217+
# Already inside tmux — set up the layout
218+
editor_pane=$(tmux display-message -p '#{pane_id}')
219+
tmux split-window -v -p 15 -c "$current_dir"
220+
221+
tmux select-pane -t "$editor_pane"
222+
tmux split-window -h -p 30 -c "$current_dir"
223+
ai_pane=$(tmux display-message -p '#{pane_id}')
224+
tmux send-keys -t "$ai_pane" "$ai" C-m
225+
tmux send-keys -t "$editor_pane" "$EDITOR ." C-m
226+
227+
tmux select-pane -t "$editor_pane"
228+
}
229+
203230
# Password generation
204231
pg() {
205232
local password

0 commit comments

Comments
 (0)