Skip to content

Command Reference

sysid edited this page Oct 20, 2025 · 1 revision

Command Reference

Complete reference for all rs-env commands and options.

Global Options

These options work with all commands:

Option Description
-d, --debug Enable debug logging (use multiple times for more verbosity)
--generate <shell> Generate shell completion script (bash, zsh, fish, powershell)
--info Display version and configuration information
-h, --help Print help information
-V, --version Print version information

Examples

# Show version
rsenv --version

# Enable debug output
rsenv -d build production.env

# Very verbose debug
rsenv -ddd build production.env

# Generate bash completion
rsenv --generate bash > ~/.bash_completion.d/rsenv

# Show info
rsenv --info

Core Commands

build

Build complete environment from hierarchy.

Syntax:

rsenv build <file>

Arguments:

  • <file> - Environment file to build (required)

Output: Export statements ready for sourcing

Examples:

# Build environment
rsenv build production.env

# Load into shell
source <(rsenv build production.env)

# Save to file
rsenv build production.env > .env

See: Building Environments


leaves

List all leaf environment files (files with no children).

Syntax:

rsenv leaves <directory>

Arguments:

  • <directory> - Directory to search (required)

Output: List of leaf file paths

Examples:

# Find all leaves
rsenv leaves .

# Find leaves in subdirectory
rsenv leaves environments/

# Build all leaves
for env in $(rsenv leaves .); do
  rsenv build "$env"
done

See: Viewing Hierarchies


tree

Display hierarchical structure of environment files.

Syntax:

rsenv tree <directory>

Arguments:

  • <directory> - Directory to visualize (required)

Output: Tree structure showing parent-child relationships

Examples:

# View tree
rsenv tree .

# View specific directory
rsenv tree environments/

# Save tree to file
rsenv tree . > hierarchy.txt

See: Viewing Hierarchies


branches

Show all environment chains as linear paths.

Syntax:

rsenv branches <directory>

Arguments:

  • <directory> - Directory to search (required)

Output: Linear representation of all chains (root β†’ leaf)

Examples:

# View all branches
rsenv branches .

# View branches in subdirectory
rsenv branches environments/

See: Viewing Hierarchies


Interactive Commands

select

Interactive environment selection with fuzzy finder + direnv update.

Syntax:

rsenv select <directory>

Arguments:

  • <directory> - Directory to search (required)

Behavior:

  1. Opens fuzzy finder with all .env files
  2. User selects file interactively
  3. Builds selected environment
  4. Updates .envrc (if using direnv)
  5. Reloads direnv

Examples:

# Select from current directory
rsenv select .

# Select from subdirectory
rsenv select environments/

Requirements: Terminal with TTY support

See: Interactive Selection


edit

Interactive selection and editing of environment files.

Syntax:

rsenv edit <directory>

Arguments:

  • <directory> - Directory to search (required)

Behavior:

  1. Opens fuzzy finder with all .env files
  2. User selects file
  3. Opens file in $EDITOR

Environment Variables:

  • EDITOR - Editor to use (default: vim)

Examples:

# Edit file in current directory
rsenv edit .

# Edit with specific editor
EDITOR=code rsenv edit .

# Edit in subdirectory
rsenv edit environments/

Requirements: Terminal with TTY support, $EDITOR set

See: Interactive Selection


tree-edit

Edit entire hierarchy side-by-side.

Syntax:

rsenv tree-edit <directory>

Arguments:

  • <directory> - Directory containing hierarchy (required)

Behavior:

  1. Discovers all .env files in directory
  2. Opens all files in $EDITOR simultaneously
  3. Files arranged hierarchically (parent β†’ child)

Environment Variables:

  • EDITOR - Editor to use (default: vim)

Examples:

# Edit hierarchy
rsenv tree-edit .

# Edit with vim
EDITOR=vim rsenv tree-edit environments/

# Edit with VS Code
EDITOR=code rsenv tree-edit .

Requirements: Terminal with TTY support, $EDITOR set

See: Tree Editing


Management Commands

envrc

Update .envrc file for direnv integration.

Syntax:

rsenv envrc <file> [output]

Arguments:

  • <file> - Environment file to build (required)
  • [output] - Output file path (default: ./.envrc)

Behavior:

  1. Builds environment from file
  2. Writes export statements to output file

Examples:

# Generate .envrc
rsenv envrc production.env

# Generate to custom location
rsenv envrc production.env .envrc

# Generate to specific path
rsenv envrc production.env ~/project/.envrc

See: direnv Integration


files

List all files in hierarchy (parent chain).

Syntax:

rsenv files <file>

Arguments:

  • <file> - Environment file (required)

Output: List of files in resolution order (parent β†’ child)

Examples:

# List files
rsenv files production.env

# Edit all files in hierarchy
vim $(rsenv files production.env)

# Count files
rsenv files production.env | wc -l

See: Building Environments


link

Create parent-child relationships programmatically.

Syntax:

rsenv link <parent> <child1> [child2 ...]

Arguments:

  • <parent> - Parent file (required)
  • <child1> - First child file (required)
  • [child2 ...] - Additional child files (optional)

Behavior: Adds # rsenv: <parent> comment to each child file

Examples:

# Link single child
rsenv link base.env production.env

# Link multiple children
rsenv link base.env staging.env production.env

# Link with paths
rsenv link ../base.env production.env

See: Managing Links


Command Aliases

Command Alias
build b
select s
edit e
tree t
leaves l

Examples:

rsenv b production.env     # Same as rsenv build
rsenv t .                  # Same as rsenv tree
rsenv s .                  # Same as rsenv select

Exit Codes

Code Meaning
0 Success
1 General error (file not found, parse error, etc.)
2 Command-line parsing error

Environment Variables

Variable Purpose Example
EDITOR Default editor for edit and tree-edit export EDITOR=vim
RUST_LOG Logging level for development export RUST_LOG=debug

File Patterns

Commands that accept directory arguments will search for:

  • Files matching *.env
  • Recursive search through subdirectories
  • Hidden files are excluded

Output Formats

Build Output

Export statements ready for shell sourcing:

export VAR1=value1
export VAR2=value2

Tree Output

Hierarchical tree structure:

base.env
  └── cloud.env
       └── production.env

Branches Output

Linear chains (root β†’ leaf):

base.env β†’ cloud.env β†’ production.env

Files Output

Simple list (parent β†’ child order):

base.env
cloud.env
production.env

Leaves Output

Simple list of leaf files:

production.env
dev.env

Next Steps

Clone this wiki locally