docs / cli

$ CLI Reference

Complete reference for the gh-env command line tool.

_installation

The CLI is automatically installed when you run the activation command. For manual installation:

# Standard installation (to ~/.ghostenv/)
curl -sL gh-env.sh | sh
# Install only (skip activation)
curl -sL gh-env.sh/install | sh

Installation Paths

ModeCLI PathToken Path
Normal~/.ghostenv/bin/gh-env~/.ghostenv/.token
Zero-Trace/tmp/ghostenv.xxx/bin/gh-env/tmp/ghostenv.xxx/.token
Read-Only(inline)$GHOST_TOKEN (env var)

_command_reference

gh-env activate [profile]

Activate a profile in the current shell. Downloads scripts, verifies signatures, and sources them.

# Activate default profile
gh-env activate
# Activate specific profile
gh-env activate work
gh-env deactivate

Deactivate the current profile. Runs cleanup scripts and restores the previous shell state.

gh-env deactivate
# Or just exit the shell / press Ctrl+D
gh-env status

Show current status including active profile, mode, and token validity.

$ gh-env status
Ghost-Env Status
━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Mode: normal
User: hunter42
Profile: default
Token: valid (14m remaining)
gh-env profiles

List all available profiles for your account.

$ gh-env profiles
* default (active)
work
personal
server-admin
gh-env refresh

Refresh the access token using the stored refresh token. Usually happens automatically.

gh-env refresh
gh-env logout

Log out from this device. Removes stored tokens and deactivates the session.

gh-env logout
gh-env version

Show the installed CLI version.

$ gh-env version
gh-env v0.5.1-beta

_activation_modes

ModeCommandDisk WritesUse Case
Normalcurl -sL gh-env.sh | shYes (~/.ghostenv/)Personal machines, persistent servers
Zero-Tracecurl -sL gh-env.sh/0 | shYes (/tmp/)Shared computers, temporary access
Read-Onlycurl -sL gh-env.sh/r | shNoImmutable systems, containers

Mode Details

Normal Mode

  • + CLI and scripts installed to ~/.ghostenv/
  • + Tokens stored persistently for auto-login
  • + Add to shell rc for auto-activation on new terminals
  • + Device registered and visible in dashboard

Zero-Trace Mode

  • + All files in /tmp/ghostenv.RANDOM/
  • + Automatic cleanup on exit (even on Ctrl+C)
  • + Device unregistered from server on exit
  • + Sensitive files securely shredded

Read-Only Mode

  • + Zero disk writes - everything in memory
  • + Scripts evaluated inline via eval
  • + Tokens stored in shell environment variables
  • + Works on read-only filesystems and containers

_environment_variables

These environment variables can be used to configure Ghost-Env behavior:

VariableDefaultDescription
GHOST_API_URLgh-env.sh/api/v1API endpoint URL
GHOST_HOME~/.ghostenvInstallation directory
GHOST_TOKEN(from file)Override access token (read-only mode)
GHOST_PROFILEdefaultDefault profile to activate
GHOST_MODE(auto)Current mode (normal/zero-trace/read-only)
GHOST_DEBUG0Enable debug logging (set to 1)

_troubleshooting

"Command not found: gh-env"

The CLI isn't in your PATH. Add it:

# Add to ~/.bashrc or ~/.zshrc
export PATH="$HOME/.ghostenv/bin:$PATH"

"Token expired"

Your access token has expired and couldn't be refreshed. Re-authenticate:

gh-env logout && curl -sL gh-env.sh | sh

"Signature verification failed"

The script signature doesn't match. This could indicate tampering. Try refreshing:

gh-env deactivate && gh-env activate

If this persists, contact support - your profile may need to be re-signed.

"Permission denied"

Can't write to the installation directory. Check permissions or use read-only mode:

# Use read-only mode instead
curl -sL gh-env.sh/r | sh

"Device code expired"

You took too long to authorize. Device codes expire after 10 minutes. Run the command again:

curl -sL gh-env.sh | sh

_shell_integration

To automatically activate Ghost-Env when opening a new terminal, add to your shell config:

# ~/.bashrc or ~/.zshrc
export PATH="$HOME/.ghostenv/bin:$PATH"
# Auto-activate if logged in
if [ -f "$HOME/.ghostenv/.token" ]; then
gh-env activate 2>/dev/null
fi
!
Note: Only add auto-activation for normal mode installations. Zero-trace and read-only modes should be activated manually.