#!/usr/bin/env bash

session=Backend
# PROJECT_PATH=/home/t0xa/Documents/Backend/
# SCRIPTS_PATH=/home/t0xa/Documents/Scripts/

PROJECT_PATH="/home/pro100ton/Documents/Development/Python/python_asyncio_course/"
SCRIPTS_PATH=/home/pro100ton/Documents/Development/configs_collection/

# Kill session if existst
tmux kill-ses -t "${session}"

# Create detached sesssion with default IDE window
tmux new-session -d -s ${session} -n IDE
# Go to project path
tmux send-keys "cd ${PROJECT_PATH} && poetry run nvim" C-m # C-m means "hit enter"
# Split IDE window in half
tmux split-window -v
# Some resizing
tmux resize-pane -D 15
# Go to project directory
tmux send-keys "cd ${PROJECT_PATH}" C-m # C-m means "hit enter"
tmux send-keys "poetry shell" C-m # C-m means "hit enter"
tmux send-keys "clear" C-m # C-m means "hit enter"

# Create additional windows
#
# Runners window
tmux new-window -n Runners -t ${session}
# Go to project directory and acivate env
tmux send-keys "cd ${PROJECT_PATH} && poetry shell" C-m # C-m means "hit enter"
tmux split-window -v
# Go to project directory and acivate env
tmux send-keys "cd ${PROJECT_PATH} && poetry shell" C-m # C-m means "hit enter"

# Git manipulation window
tmux new-window -n Git -t ${session}
# Go to project directory and acivate env
tmux send-keys "cd ${PROJECT_PATH}" C-m # C-m means "hit enter"
tmux send-keys "lazygit" C-m # C-m means "hit enter"

# Scripts manipulation window
tmux new-window -n Scripts -t ${session}
# Go to scripts directory
tmux send-keys "cd ${SCRIPTS_PATH} && clear" C-m # C-m means "hit enter"

# Bash manipulation window
tmux new-window -n Bash -t ${session}

# Attach to created workspace
tmux attach -t ${session}:IDE
