cmux/docs-site/content/docs/environment-variables.mdx
Lawrence Chen 51a67e31fd
Socket access control: process ancestry check (#58)
* Socket access control: process ancestry check + file permissions

Redesign socket control modes from (off, notifications, full) to
(off, cmuxOnly, allowAll):

- cmuxOnly (default): uses LOCAL_PEERPID + sysctl process tree walk to
  verify the connecting process is a descendant of cmux. External
  processes (SSH, other terminals) are rejected.
- allowAll: hidden mode accessible only via CMUX_SOCKET_MODE=allowAll
  env var, skips ancestry check. Legacy "full"/"notifications" env
  values map here for backward compat.
- off: disables socket entirely.

Security hardening:
- Server: chmod 0600 on socket after bind (owner-only access)
- CLI: stat() ownership check before connect (reject fake sockets)

Removes per-command allow-list (isCommandAllowed) — once a process
passes the ancestry check, all commands are available.

Includes migration for persisted UserDefaults values and env var
aliases (cmux_only, cmux-only, allow_all, allow-all).

* Add /sync-branch skill for submodule + main sync
2026-02-18 01:09:24 -08:00

179 lines
3.2 KiB
Text

---
title: Environment Variables
description: Environment variables for configuring cmux
---
# Environment Variables
cmux uses environment variables for configuration and integration.
## Socket Control
### CMUX_SOCKET_PATH
Override the default socket path.
```bash
export CMUX_SOCKET_PATH=/custom/path/cmux.sock
```
Default: `/tmp/cmux.sock` (release) or `/tmp/cmux-debug.sock` (debug)
### CMUX_SOCKET_ENABLE
Enable or disable the control socket.
```bash
export CMUX_SOCKET_ENABLE=1 # Enable
export CMUX_SOCKET_ENABLE=0 # Disable
```
Values: `1`, `0`, `true`, `false`, `yes`, `no`
### CMUX_SOCKET_MODE
Override the socket access mode.
```bash
export CMUX_SOCKET_MODE=cmuxOnly # cmux processes only (default)
export CMUX_SOCKET_MODE=allowAll # Allow any local process (no ancestry check)
export CMUX_SOCKET_MODE=off # Disabled
```
## CLI Context
### CMUX_TAB_ID
Default tab ID for CLI commands.
```bash
export CMUX_TAB_ID=abc123
cmux send "hello" # Sends to tab abc123
```
cmux automatically sets this in each terminal session.
### CMUX_PANEL_ID
Default panel ID for CLI commands.
```bash
export CMUX_PANEL_ID=xyz789
cmux send-panel "hello" # Sends to panel xyz789
```
cmux automatically sets this for each split pane.
## Terminal Environment
cmux sets these variables in terminal sessions:
### TERM
Terminal type for compatibility.
```bash
TERM=xterm-ghostty
```
### TERM_PROGRAM
Identifies the terminal application.
```bash
TERM_PROGRAM=ghostty
```
<Callout type="info">
cmux sets this to `ghostty` since it's built on Ghostty. Use the socket check to distinguish from regular Ghostty.
</Callout>
### GHOSTTY_RESOURCES_DIR
Path to Ghostty resources.
```bash
GHOSTTY_RESOURCES_DIR=/path/to/resources
```
## Testing & Debug
### CMUX_UI_TEST_SHOW_SETTINGS
Show the settings window on app launch (for UI testing).
```bash
export CMUX_UI_TEST_SHOW_SETTINGS=1
```
### CMUX_UI_TEST_TRIGGER_UPDATE_CHECK
Trigger an update check on app launch (for testing).
```bash
export CMUX_UI_TEST_TRIGGER_UPDATE_CHECK=1
```
### CMUX_COMMIT
Override the commit hash displayed in the About window.
```bash
export CMUX_COMMIT=abc1234
```
## Detection Script
Check if running inside cmux:
```bash
#!/bin/bash
is_cmux() {
# Check for cmux socket
if [ -S "${CMUX_SOCKET_PATH:-/tmp/cmux.sock}" ]; then
return 0
fi
return 1
}
if is_cmux; then
echo "Running in cmux"
echo "Tab ID: ${CMUX_TAB_ID:-unknown}"
echo "Panel ID: ${CMUX_PANEL_ID:-unknown}"
else
echo "Not in cmux"
fi
```
## Shell Configuration
Add to your `~/.bashrc` or `~/.zshrc`:
```bash
# cmux integration
if [ -S "${CMUX_SOCKET_PATH:-/tmp/cmux.sock}" ]; then
# We're in cmux
# Function to notify on long commands
notify_done() {
"$@"
local exit_code=$?
cmux notify --title "Command Complete" --body "$1"
return $exit_code
}
# Alias for builds
alias build='notify_done npm run build'
fi
```
## Precedence
Environment variables override app settings:
1. Environment variable (if set)
2. App settings (Settings window)
3. Default value
For example, if `CMUX_SOCKET_MODE=cmuxOnly` is set, it overrides the app's Automation Mode setting.