Skip to content

z1-0/ah.sh

Repository files navigation

ah.sh

Ad-hoc development shell manager powered by Nix

CI Release License

FeaturesInstallationQuick StartUsageConfiguration

Per-project development shells in one command. ah generates a Nix flake on the fly, manages sessions for quick restore, and supports 60+ languages. No flake.nix authoring required.

# Need Rust and Go? Done.
ah rust go

Features

  • Fast: type ah rust and you're in a shell with the Rust toolchain ready
  • Multi language: combine multiple languages in one shell
  • Language aliases: short names for languages, e.g. py for Python, ts for TypeScript
  • Community-powered: templates from devenv or dev-templates, no setup boilerplate required
  • Session management: no rebuild, quick restore, full visibility with GC pinning
  • Shell completions: Bash, Zsh, Fish, Elvish, and PowerShell

Installation

Tip

Configure the Binary cache before installing to avoid compiling the project from source.

Prerequisites

Nix with Flakes enabled is required. If you don't have it installed, we recommend using the Determinate Nix Installer.

Run without installing

nix run github:z1-0/ah.sh -- rust go

Imperative (Nix Profile)

nix profile install github:z1-0/ah.sh

Declarative (Nix Flake)

Add to your flake.nix inputs:

inputs.ah.url = "github:z1-0/ah.sh";

Then add it to your system or home packages:

environment.systemPackages = [
  inputs.ah.packages.${system}.default
];

Binary Cache

Pre-built binaries are available via Cachix. Choose one of the following options:

Option A: Imperative (CLI)

If you use profile/CLI packages, run:

cachix use z1-0

Option B: Declarative (NixOS / Home Manager)

If you configure NixOS or Home Manager via code, add this to your settings:

nix.settings = {
  substituters = [ "https://z1-0.cachix.org" ];
  trusted-public-keys = [ "z1-0.cachix.org-1:FS7lPgL0StRBOPrlu0RgdCL7LafUI23+U6Iivdw5QK8=" ];
};

Quick Start

# Create a Python dev shell
ah python

# Combine multiple languages
ah rust go nodejs

# You're in a Nix develop shell with all tools available

Usage

Creating dev shells

# Shorthand: languages as positional args
ah rust go

# Explicit subcommand
ah use rust go

# Specify a provider
ah use python --provider devenv

Session management

# List all sessions
ah session list

# Restore a session by index or ID
ah session restore 1
ah session restore a3f8c2d1

# Restore from directory history (interactive)
ah restore

# Update session dependencies (re-runs nix flake update)
ah session update
ah update 1

# Remove sessions
ah session remove 1 2
ah session remove a3f8c2d1

# Clear all sessions
ah session clear

Providers

# List available providers
ah provider list

# Show supported languages for a provider
ah provider show devenv
ah provider show dev-templates

Shell completions

# Generate completions for your shell
ah completion bash
ah completion zsh
ah completion fish

Tip

Add source <(ah completion bash) (or equivalent for your shell) to your shell profile for persistent completions. Language names and session IDs are completed dynamically.

Command aliases

Alias Equivalent
ah <languages> ah use <languages>
ah restore ah session restore
ah update ah session update

Configuration

ah creates a config file at ~/.config/ah/config.toml on first run:

# Provider type: devenv or dev-templates
provider = "dev-templates"

# Leave empty to use the $SHELL environment variable
# shell = "zsh"

All settings can be overridden via environment variables with the AH_ prefix:

AH_PROVIDER=devenv ah rust

Note

The config schema is available at src/assets/config.schema.json.

Supported Languages

You can find the full list of supported languages and tools for each provider directly in the source files:

How It Works

  1. You run ah rust go. ah resolves language and selects the provider
  2. If a matching session already exists, it restores the cached Nix profile immediately
  3. Otherwise, ah generates a flake.nix for your languages, builds it, and drops you into a nix develop shell
  4. Session metadata is saved so you can list, restore, update, or remove it later
  5. Directory history tracks which sessions you used where, so you can quickly ah restore

Session reuse and Limitations

Sessions in ah are identified by the provider and languages requested (e.g., devenv + [rust, go]), not the directory path.

If you request a language combination that you've used before, ah reuses the cached Nix profile directly. This means near-zero startup time for repeated sessions.

The trade-off is that you cannot run multiple versions of the same language at the same time (e.g., Python 3.9 and Python 3.11). This is intentional. ah is built for quick startup and ad-hoc use, not for managing multiple long-term project configurations.

Releases

Packages

Used by

Contributors

Languages