#!/usr/bin/env zsh

function lunardev ()
{
    nolunardev

    tmux new-window -n lunardev

    tmux send-keys -t lunardev "shuttle run local_up" C-m
    
    # allow for user input
    tmux split-window -h

    shuttle run generate_dotenv


    tmux send-keys -t lunardev 'export $(cat local.env | xargs)' C-m
    tmux send-keys -t lunardev "air -c ~/.config/air/.air.toml" C-m
    tmux split-window -v

    export $(cat local.env | xargs)
    tmux send-keys -t lunardev "PGPASSWORD=$DBPASSWORD psql -h $DBHOST -U $DBUSER -d $DBDATABASE" C-m
    
    # set user input to first 
    tmux select-pane -t 0
    
    
    tmux attach-session -t lunardev
}

function nolunardev() {
  tmux kill-window -t lunardev || true
}
