#!/bin/bash
PROJECTS="$(ls -t $HOME/.local/share/nvim/sessions)"

NAME="$(echo "$PROJECTS" | sed 's/.*\%//' | sed 's/\.vim//g' | wofi --show dmenu -i)"

PROJECT="$(echo "$PROJECTS" | grep "$NAME.vim" | sed 's/\%/\//g' | sed 's/\.vim$//')"

VIM="$HOME/.asdf/shims/nvim ; zsh";

if [ "$PROJECT" != "" ]; then
  if [ "$(pgrep kitty)" == "" ]; then 
    kitty -d $PROJECT $VIM
    exit
  else
    cd $PROJECT
    tmux new-window "$VIM"
    exit
  fi
fi
