aboutsummaryrefslogtreecommitdiffstats
path: root/examples/custom-sessions.sh
blob: da5987b9d89814e0275d2e8032f1a4d12199af05 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/bash
# Example CTASK_SESSIONS script
#
# Usage:
#   export CTASK_SESSIONS=/path/to/this/script
#   ctask select

SESSIONS_DIR="${HOME}/.claude/tasks"

# Start JSON array
echo '['

first=true
for session_dir in "$SESSIONS_DIR"/*; do
  if [ -d "$session_dir" ] && [ -n "$(ls -A "$session_dir"/*.json 2>/dev/null)" ]; then
    name=$(basename "$session_dir")

    # Add comma separator for all but first entry
    if [ "$first" = true ]; then
      first=false
    else
      echo ','
    fi

    # Output session entry
    cat <<EOF
  {
    "name": "$name",
    "path": "$session_dir",
    "description": "Custom session: $name"
  }
EOF
  fi
done

# Close JSON array
echo
echo ']'