#!/usr/bin/env bash

# Description: A script to list and start tmuxinator projects using fzf.

# Set the directory where your tmuxinator configuration files are located
TMUXINATOR_CONFIG_DIR="${HOME}/.config/tmuxinator/"

# Find all tmuxinator `.yml` files in the specified directory, remove path and extensions
# project=$(find "$TMUXINATOR_CONFIG_DIR" -type f -name "*.yml" | sed 's|.*/||;s|\.yml$||' | \
# 	fzf --prompt="Session: " --preview-label="pyTui Tmuxinator Picker" --preview-label-pos=bottom \
# 	--preview="bat --style=full --color=always" --preview-window=up \
# )

# project=$(find "$TMUXINATOR_CONFIG_DIR" -type f -name "*.yml" | sed 's|.*/||;s|\.yml$||' | fzf --prompt="Session: " --tmux bottom,5%)
project=$(find "$TMUXINATOR_CONFIG_DIR" -type f -name "*.yml" | sed 's|.*/||;s|\.yml$||' | fzf --prompt="Session 󰓾 " --tmux left,25 --reverse)

# Check if a project was selected
if [[ -n "$project" ]]; then
  # Start the selected tmuxinator project
  tmuxinator start "$project"
# else
#   echo "No project selected. Exiting..."
#   exit 1
fi
