npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

git-env-manager

v1.2.13

Published

Multi-git-profile manager with SSH key integration

Readme

Language: English | 한국어

git-env-manager

CI npm version License

A CLI tool for managing multiple Git profiles and SSH keys.

Stop manually switching git config and ssh-add between your personal and work accounts. git-env-manager centralizes profile management with automatic directory-based switching via Git's native includeIf.


Quick Start

Install

npm install -g git-env-manager

Initialize

ghem init

This creates ~/.git-env-manager/ with an empty configuration. Default language is English.

To initialize with Korean:

ghem init --lang ko

Add a Profile

ghem add personal

Interactive prompts will ask for:

  • Git user.name
  • Git user.email
  • SSH key setup: Generate new key (recommended) or use an existing key
  • Auto-switch directories (optional, comma-separated)

When you choose "Generate new key", ghem automatically runs ssh-keygen and displays the public key so you can add it to GitHub/GitLab.

Switch Profile (Manual)

ghem switch work

Sets the global git config and loads the SSH key into the agent.

List Profiles

ghem list

Displays all registered profiles with their emails and mapped directories.


How It Works

Directory-Based Auto-Switching

When you add a profile with directories (e.g., ~/work/), git-env-manager injects includeIf entries into your ~/.gitconfig:

[includeIf "gitdir:~/work/"]
    path = ~/.git-env-manager/gitconfig-work

Any Git repository under ~/work/ automatically uses the work profile's name, email, and SSH key. No shell hooks, no manual switching.

SSH Key Management

SSH keys are copied to ~/.git-env-manager/keys/{profile}/ with proper permissions (0600). Each profile's gitconfig uses core.sshCommand with -o IdentitiesOnly=yes to ensure the correct key is used.

Configuration

All configuration is stored in ~/.git-env-manager/:

~/.git-env-manager/
├── config.json              # Profile definitions
├── keys/
│   ├── personal/
│   │   ├── id_ghem_personal
│   │   └── id_ghem_personal.pub
│   └── work/
│       ├── id_ghem_work
│       └── id_ghem_work.pub
├── gitconfig-personal       # Generated per-profile gitconfig
└── gitconfig-work

Commands

| Command | Description | |---------|-------------| | ghem init [--lang <locale>] | Create ~/.git-env-manager/ directory and initial config | | ghem add <profile> | Add a new profile via interactive prompts | | ghem switch <profile> | Switch global Git profile and SSH key | | ghem delete <profile> | Delete a profile and its associated keys | | ghem list | Show all registered profiles | | ghem config set-lang <locale> | Set display language (en, ko) | | ghem config set-prompt <on\|off> | Enable or disable shell prompt indicator | | ghem completion | Output shell completion script | | ghem prompt [--shell <shell>] | Output shell prompt indicator script | | ghem status [--short] | Show current profile context for the working directory | | ghem edit <profile> | Edit an existing profile interactively | | ghem test <profile> [--host <hostname>] | Test SSH connection for a profile |

Both ghem and git-env-manager work as CLI commands.


SSH Key Setup

When running ghem add, you'll be prompted to choose how to set up the SSH key:

  1. Generate new key (recommended) — automatically creates a key pair at ~/.ssh/id_ghem_{profile} and displays the public key for you to register on GitHub/GitLab.
  2. Use existing key — enter the path to an existing private key (e.g., ~/.ssh/id_rsa).

If you prefer to generate keys manually before running ghem add:

ssh-keygen -C "[email protected]" -f ~/.ssh/id_ghem_personal

Then choose "Use existing key" during ghem add and enter the path.


Commit Signing (SSH)

git-env-manager can automatically configure SSH-based commit signing for each profile. This uses the same SSH key that's already managed by the tool — no separate GPG key needed.

Enable During Setup

When running ghem add, you'll be prompted:

? Enable SSH commit signing? (requires Git >= 2.34) (y/N)

Enable for Existing Profile

ghem edit personal

Toggle the commit signing option when prompted.

What It Configures

When enabled, the per-profile gitconfig includes:

[user]
    signingkey = ~/.git-env-manager/keys/{profile}/{key}.pub
[commit]
    gpgsign = true
[gpg]
    format = ssh

All commits in directories mapped to that profile will be signed automatically.

Verify on GitHub

  1. Go to Settings > SSH and GPG keys > New SSH key
  2. Set Key type to Signing Key
  3. Paste the same public key used for authentication

GitHub will show a "Verified" badge on signed commits.

Note: SSH commit signing requires Git >= 2.34. The profile's SSH key is reused for signing, so no additional key management is needed.


Language

git-env-manager supports English (en) and Korean (ko). Default is English.

Set language during initialization:

ghem init --lang ko

Or change it later:

ghem config set-lang ko

All prompts, messages, and errors will be displayed in the selected language. Command descriptions in --help remain in English.


Shell Prompt Indicator

Show the current Git profile in your terminal prompt. The indicator updates automatically as you navigate between directories.

~/work/project [work] $
~/personal/blog [personal] $

Setup

Add one line to your shell config:

Bash (~/.bashrc)

eval "$(ghem prompt --shell bash)"
PS1='\w $(__ghem_prompt)\$ '

Zsh (~/.zshrc)

eval "$(ghem prompt --shell zsh)"
RPROMPT='$(__ghem_prompt)'

Fish (~/.config/fish/config.fish)

ghem prompt --shell fish | source
# Then use (__ghem_prompt) in your fish_prompt function

Starship (~/.config/starship.toml)

[custom.ghem]
command = "ghem status --short"
when = "test -f ~/.git-env-manager/config.json"
format = "[$output]($style) "
style = "bold cyan"

The prompt function uses awk to parse config.json directly — no Node.js process is spawned, so there is no noticeable delay.

Toggle

The prompt indicator is enabled by default. To disable:

ghem config set-prompt off

Shell Completion

Bash

echo 'eval "$(ghem completion --shell bash)"' >> ~/.bashrc

Zsh

echo 'eval "$(ghem completion --shell zsh)"' >> ~/.zshrc

Tab completion supports command names, profile names for switch/delete/edit/test, and language options for config set-lang.


Safety

  • Atomic writes: ~/.gitconfig is written to a temp file first, then renamed (POSIX-atomic)
  • Backup: Modifying ~/.gitconfig creates a timestamped backup in ~/.git-env-manager/
  • Append-only: Existing gitconfig entries (LFS, difftool, mergetool, etc.) are never removed
  • Key permissions: Private keys are set to 0600 on copy

Requirements

  • Node.js >= 20
  • Git >= 2.13 (for includeIf support)
  • macOS or Linux

License

MIT