Claude
Index¶
- claude::config_dir
- claude::projects_dir
- claude::profile_dirs
- claude::encode_path
- claude::session_cwd
- claude::session_branch
- claude::session_first_prompt
- claude::session_last_prompt
- claude::session_recent_prompts
- claude::session_preview
claude::config_dir¶
Print the effective Claude Code config dir. An already-set (non-empty) CLAUDE_CONFIG_DIR is an explicit user override and is honored verbatim. Otherwise the value is derived from PWD: at or under ${WORK_PROJECTS_DIR} -> ${XDG_CONFIG_HOME}/claude/work, anywhere else -> ${XDG_CONFIG_HOME}/claude/personal. shellcheck disable=SC2120 # called with no args by callers, shellcheck can't see all call sites
Function has no arguments.
Output on stdout¶
- the config dir path
claude::projects_dir¶
Print the Claude Code projects directory:
$(claude::config_dir)/projects.
Function has no arguments.
Output on stdout¶
- the projects directory path
claude::profile_dirs¶
Print the absolute path of each Claude Code profile config dir --
${XDG_CONFIG_HOME}/claude/personal and ${XDG_CONFIG_HOME}/claude/work --
one per line, personal first. Only dirs that already exist are printed, so a
machine carrying a single profile yields a single line. Unlike
claude::config_dir this enumerates the fixed profile set rather than
selecting one, and deliberately ignores both CLAUDE_CONFIG_DIR and PWD.
Function has no arguments.
Output on stdout¶
- one existing profile config dir path per line; no output if none exist
claude::encode_path¶
Encode an absolute path into a Claude Code project-dir name by replacing
every / and . with - (e.g. /home/x/.config/y -> -home-x--config-y).
Arguments¶
- $1 (path): absolute path to encode
Output on stdout¶
- the encoded path
claude::session_cwd¶
Print the first cwd value recorded in a session jsonl file; empty if none.
Arguments¶
- $1 (jsonl): path to a session jsonl file
Output on stdout¶
- the first cwd value, or empty string
claude::session_branch¶
Print the first gitBranch value recorded in a session jsonl file; empty if none.
Arguments¶
- $1 (jsonl): path to a session jsonl file
Output on stdout¶
- the first gitBranch value, or empty string
claude::session_first_prompt¶
Print the lastPrompt of the FIRST last-prompt line in a session jsonl file;
empty string if there are no such lines.
Arguments¶
- $1 (jsonl): path to a session jsonl file
Output on stdout¶
- the first prompt, or empty string
claude::session_last_prompt¶
Print the lastPrompt of the LAST last-prompt line in a session jsonl file;
empty string if there are no such lines.
Arguments¶
- $1 (jsonl): path to a session jsonl file
Output on stdout¶
- the last prompt, or empty string
claude::session_recent_prompts¶
Print the lastPrompt values of the last last-prompt lines in a session
jsonl file, in chronological order (oldest of the n first); fewer lines if the session has
fewer prompts, empty output if it has none. Each prompt is collapsed to a single line.
Arguments¶
- $1 (jsonl): path to a session jsonl file
- $2 (n): number of recent prompts to print (positive integer)
Exit codes¶
- 1: if n is not a positive integer
Output on stdout¶
- up to n recent prompts, one per line
claude::session_preview¶
Render a human-readable preview of a session for fzf: its first message and its
last fzf --preview command target.
Arguments¶
- $1 (jsonl): path to a session jsonl file
- $2 (n): number of recent prompts to show (positive integer)
Exit codes¶
- 1: if n is not a positive integer
Output on stdout¶
- a formatted multi-line preview block