fix: ollie-session-here uses default session, agent named by directory

This commit is contained in:
Levi Neely 2026-08-12 16:21:05 +02:00
parent 08cd2b6eac
commit 739fba2462
1 changed files with 10 additions and 9 deletions

View File

@ -2,26 +2,27 @@
# ollie-session-here: start a session in the given directory
# Works from both Dolphin (passes %f) and terminal (uses $PWD).
#
# Session name is the base directory name (not full path).
# Session creation is idempotent — always write to session/new.
# Session is always "default". Agent name is the base directory name.
# Session/agent creation is idempotent.
TARGET="$1"
[ -f "$TARGET" ] && TARGET="$(dirname "$TARGET")"
[ -z "$TARGET" ] && TARGET="$PWD"
TARGET="$(cd "$TARGET" 2>/dev/null && pwd)" || TARGET="$PWD"
# Extract base directory name for session name
SESSION_NAME="$(basename "$TARGET")"
# Agent name is base directory name
AGENT_NAME="$(basename "$TARGET")"
# Create session (idempotent) and agent via 9P
printf 'name=%s\ncwd=%s\n' "$SESSION_NAME" "$TARGET" | ollie-9p write session/new
printf 'cwd=%s\n' "$TARGET" | ollie-9p write "session/$SESSION_NAME/agent/new"
# Create default session (idempotent) and named agent
printf 'name=default\ncwd=%s\n' "$TARGET" | ollie-9p write session/new
printf 'name=%s\ncwd=%s\n' "$AGENT_NAME" "$TARGET" | ollie-9p write session/default/agent/new
if [ -t 1 ]; then
# Terminal: print session info
echo "Session: $SESSION_NAME"
echo "Session: default"
echo "Agent: $AGENT_NAME"
echo "CWD: $TARGET"
else
# Dolphin/non-interactive: desktop notification
notify-send -t 3000 "Ollie" "Session '$SESSION_NAME' started in $TARGET"
notify-send -t 3000 "Ollie" "Agent '$AGENT_NAME' started in $TARGET"
fi