contree run produces a new image, and the session records
the chain. Sessions also support branching and rollback for
experimentation.
Session key
Every session is identified by a session key – an arbitrary string. The CLI computes one automatically so that each terminal window gets its own session without any extra setup. The auto-generated key is a deterministic UUID5 derived from three values:| Component | Source | Purpose |
|---|---|---|
profile | Active config profile name | Isolates sessions per profile |
ppid | Parent process ID (os.getppid()) | The shell that launched the CLI |
tty | TTY device of stdin (os.ttyname()) | Distinguishes terminal windows |
- Open a new terminal tab – new
ppid+tty– new session. - Run
contreecommands in the same terminal – sameppid+tty– same session (resumes where you left off). - Switch profiles – different
profile– new session.
Viewing session state
Branching
Create a branch to experiment without affecting the main line:* marks the active one):
Rollback
Move the branch pointer in the history chain. The argument distinguishes absolute jumps from relative navigation:| Argument | Meaning |
|---|---|
| (none) | Back one entry (default) |
-- -N | Back N entries (the -- stops argparse from parsing -N as a flag) |
+N | Forward N entries |
N (bare positive) | Absolute jump to history id N |
Starting a fresh session
Because the auto-generated key is deterministic, the same terminal always resumes the same session. Use--new (-N) to start a fresh session:
- CLI
- Shell
eval, the new session is not active until you export the
printed variable into your shell. You can also copy-paste the export
(or set -gx) line that contree use prints.CONTREE_SESSION to any string:
Sharing a session across terminals
contree use prints the session key. Export it in another terminal to
attach to the same session:
This pattern is CLI-only. The interactive shell manages sessions internally
and does not require manual session key export.
Storage
Session data is stored in a per-profile SQLite database at~/.config/contree/sessions-{profile}.db. Override the data
directory with CONTREE_HOME:
You can experiment freely with branches. Next: Working with Files.