Shellingham

Tiny Python library that detects which shell (bash, zsh, fish, PowerShell, cmd) is running the current process

Library
PyPI
v1.5.4
320 stars
ISC

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
42 /100 Fair
Development Activity 4
Maintenance 20
Community 64
Maturity 60
Momentum 20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
55 /100 Fair
Architecture 55
Code Quality 58
Innovation 45
Learning Curve 60

Shellingham is a small, dependency-free Python library that inspects the process tree to figure out which shell launched the current Python interpreter. It returns a simple tuple of the shell’s name and the command used to invoke it, working across POSIX systems (via /proc or the ps command) and Windows (via the parent process name).

The library is best known as the shell-detection engine behind pip and Typer/Click-based CLIs that offer shell-completion installation, letting a tool automatically figure out whether to write a bash, zsh, fish, or PowerShell completion script without asking the user.

What You Get

  • A single detect_shell() function returning a (name, command) tuple
  • POSIX detection via /proc process trees with a ps-based fallback when /proc is unavailable
  • Windows detection via parent process executable name
  • A dedicated ShellDetectionFailure exception for graceful fallback handling
  • Zero runtime dependencies and a tiny (~450 line) codebase

Common Use Cases

  • Auto-installing shell completion scripts in CLI tools built with Click or Typer
  • Selecting the correct shell syntax when a tool needs to print an eval-able activation command (similar to how pipenv and pyenv wrappers behave)
  • Any command-line application that needs to branch behavior based on the user’s interactive shell
  • Falling back gracefully to a POSIX $SHELL or Windows %COMSPEC% default when detection fails

Under The Hood

Architecture The package splits detection into an internal _core.py dispatcher that picks between posix and nt (Windows) implementations at import time based on os.name; the POSIX path (posix/__init__.py, proc.py, ps.py) walks /proc/<pid>/stat parent links when available and falls back to shelling out to ps for BSD/macOS-style systems without /proc, while nt.py walks the Windows process tree via ctypes calls to find the parent executable name.

Tech Stack Pure Python (100%), zero runtime dependencies, packaged via classic setup.py/setup.cfg with a src/ layout; uses Pipenv for development and towncrier for changelog generation, targeting Python 3.7+.

Code Quality The codebase is intentionally minimal (roughly 450 lines total) and readable, with a single POSIX test module (tests/test_posix.py) covering the process-walking logic; there is no Windows-specific test coverage in the repository, and comments are sparse but the code’s small surface area keeps it easy to audit.

API Design The public API is deliberately tiny — one function (detect_shell) and one exception class — making adoption a one-line integration; the try/except pattern recommended in the README for handling ShellDetectionFailure is idiomatic and low-friction for CLI authors.

Used by 5 apps in this directory

Python
100%
Apache 2.0

Agno

AI Development · Automation · Devops

42,358

Build, run, and manage agent platforms with a full production stack — SDK, runtime, and control plane included.

View details
93
Repo Health
87
Technical
66
Dependency
Built with
Python 100%
Updated 4 days ago
TypeScript
95%
Other

OpenHands

AI Code Assistants · AI Development

89,328

The self-hosted developer control center for running AI coding agents — locally, in Docker, on VMs, or across cloud backends — with automation workflows for GitHub, Slack, and more.

View details
91
Repo Health
82
Technical
67
Dependency
Built with
TypeScript 95%
Updated 5 days ago
Go
67%
Apache 2.0

OSV.dev

Security

2,948

Google's open-source vulnerability database that maps CVEs to exact package versions across 50+ ecosystems with a public API and data dumps.

View details
87
Repo Health
82
Technical
66
Dependency
Built with
Go 67%
Python 22%
Updated 4 days ago
Python
94%
Apache 2.0

SWIRL

Data Engineering · Databases · Search

3,047

Federated AI search and RAG across 100+ enterprise sources—no data extraction, no vector database required.

View details
62
Repo Health
83
Technical
65
Dependency
Built with
Python 94%
Updated 6 days ago
Python
73%
Apache 2.0

timesfm

AI Development · Analytics

33,870

A pretrained decoder-only foundation model by Google Research that delivers zero-shot time series forecasting with calibrated quantile prediction intervals — no training required.

View details
78
Repo Health
81
Technical
71
Dependency
Built with
Python 73%
HTML 14%
Jupyter Notebook 12%
Updated 2 weeks ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers