#!/usr/bin/env sh # 1. Select a directory using zoxide's interactive selection ZOXIDE_RESULT=$(zoxide query --interactive) # 2. Exit if no directory was selected if [ -z "$ZOXIDE_RESULT" ]; then exit 0 fi # 3. Get the directory name to use as the session name SESSION_NAME=$(basename "$ZOXIDE_RESULT" | tr . _) # 4. Check if the session already exists SESSION_EXISTS=$(zellij list-sessions | grep -w "$SESSION_NAME") --cwd "$ZOXIDE_RESULT" # 5. Create or attach to the session if [ -z "$SESSION_EXISTS" ]; then # Create a new session in the selected directory zellij attach --create "$SESSION_NAME" else # Attach to the existing session zellij attach --create "$SESSION_NAME" fi