spacehub

surshar / claude-code

Claude Code is an agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster by executing routine tasks, explaining complex code, and handling git workflows - all through natural language commands.

Built by Anthropic · github.com/anthropics

claude-code / mods / telemetry / hooks / context / shell-of / shell-of.ts
24 lines · 663 BRaw
1import { KNOWN_SHELLS } from './known-shells'
2
3/**
4 * The row's `shell`: the login shell's basename when the CLI's list knows
5 * it, `other` when it does not, `none` when no shell is set.
6 *
7 * The path itself, which can name a person, never reaches a row.
8 *
9 * @param shellPath SHELL (or COMSPEC on Windows) as read
10 * @returns the shell's name from the closed list
11 */
12export function shellOf(shellPath: string | undefined) {
13 const base = (shellPath ?? '')
14 .split(/[/\\]/)
15 .at(-1)
16 ?.toLowerCase()
17 .replace(/\.exe$/, '')
18
19 if (!shellPath) {
20 return 'none'
21 }
22
23 return base !== undefined && KNOWN_SHELLS.includes(base) ? base : 'other'
24}