Environment Isolation¶
sbsh provides control over environment variable inheritance and isolation, enabling reproducible environments.
Environment Inheritance¶
inheritEnv: true (Default)¶
When inheritEnv is true, the terminal inherits all environment variables from the parent process:
Use when:
- You need access to system PATH
- SSH_AUTH_SOCK and other system variables are required
- Full environment access is needed
inheritEnv: false¶
When inheritEnv is false, the terminal starts with a minimal environment. Only variables specified in env are available:
Use when:
- You want reproducible, isolated environments
- CI/CD environments that should be clean
- Testing with controlled environments
Environment Variable Configuration¶
Basic Variables¶
spec:
shell:
env:
KEY: value
NUMBER: "5000" # Numbers must be quoted
PATH: "$HOME/bin:$PATH" # Can reference other variables
Variable Expansion¶
Variables can reference other variables:
Special Variables¶
sbsh provides special variables:
$SBSH_TERM_ID: Current terminal ID$SBSH_TERM_PROFILE: Current profile name
Working Directory¶
Set the working directory with cwd:
spec:
shell:
cwd: "~" # Home directory
# cwd: "$HOME/projects" # Expanded path
# cwd: "/absolute/path" # Absolute path
Isolation Levels¶
Minimal Isolation¶
Full Isolation¶
spec:
shell:
inheritEnv: false
env:
LANG: en_US.UTF-8
PATH: /usr/bin:/bin
HOME: /home/user
USER: user
SHELL: /bin/bash
Selective Inheritance¶
spec:
shell:
inheritEnv: true
env:
NODE_ENV: "production" # Override inherited value
CUSTOM_VAR: "value" # Add new variable
Best Practices¶
- Use
inheritEnv: falsefor CI/CD: Ensures reproducible environments - Use
inheritEnv: truefor development: Convenient access to system tools - Quote numbers:
HISTSIZE: "5000"notHISTSIZE: 5000 - Use
$HOMEnot~: In env values, use$HOMEfor expansion - Document required variables: List dependencies in profile comments
Related Concepts¶
- Profiles - Profile configuration
- Terminals - Terminal lifecycle
- Profiles Guide - Complete profile reference