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