Skip to content

The agent that grows with you

docs(terminal): profile functions and aliases last one command with persistence on

Tekniumf4ec3ba50aa7
diff --git a/tests/tools/test_local_persistent_shell.py b/tests/tools/test_local_persistent_shell.py
index de2a7dece23..838fb1794fa 100644
--- a/tests/tools/test_local_persistent_shell.py
+++ b/tests/tools/test_local_persistent_shell.py
@@ -45,3 +45,30 @@ def test_local_persistent_defaults_on_and_reaches_the_environment(monkeypatch, t
assert env._persist_env is False
finally:
env.cleanup()
+
+
[email protected]("linux", "macos")
[email protected]("setting, later", [("true", "fn:no"), ("false", "fn:yes")])
+def test_profile_functions_survive_only_with_persistence_off(monkeypatch, tmp_path, setting, later):
+ """The login snapshot holds profile functions; with persistence on the first command's
+ ``export -p`` re-dump replaces it, so they are gone from the second command on. The docs'
+ "Profile functions / aliases" row states exactly this."""
+ home = tmp_path / "home"
+ home.mkdir()
+ for rc in (".bashrc", ".bash_profile"):
+ (home / rc).write_text("hermes_lp_fn(){ echo FN; }\n", encoding="utf-8")
+ monkeypatch.setenv("HOME", str(home))
+ monkeypatch.setenv("TERMINAL_ENV", "local")
+ monkeypatch.setenv("TERMINAL_CWD", str(tmp_path))
+ monkeypatch.setenv("TERMINAL_LOCAL_PERSISTENT", setting)
+ task_id = f"local-persist-fn-{setting}"
+ probe = "type hermes_lp_fn >/dev/null 2>&1 && echo fn:yes || echo fn:no"
+
+ def run(cmd):
+ return json.loads(terminal_tool(cmd, task_id=task_id))["output"].strip()
+
+ try:
+ assert run(probe) == "fn:yes"
+ assert run(probe) == later
+ finally:
+ cleanup_vm(_resolve_container_task_id(task_id))
diff --git a/website/docs/user-guide/configuration.md b/website/docs/user-guide/configuration.md
index a7bbbf01f88..1f16eacb2b5 100644
--- a/website/docs/user-guide/configuration.md
+++ b/website/docs/user-guide/configuration.md
@@ -742,7 +742,7 @@ A host path in `terminal.cwd` (for example `C:\Users\me\project` on Windows, or
### Persistent Shell
-Every terminal command on the **local** and **SSH** backends runs in a fresh `bash` process. Hermes captures your login shell's environment once (PATH, exports from your profile, functions, aliases) and every command starts from that snapshot. The persistence setting decides whether **exported environment variables** set by one command reach the next.
+Every terminal command on the **local** and **SSH** backends runs in a fresh `bash` process. Hermes captures your login shell's environment once (PATH, exports from your profile, functions, aliases) and starts the first command from that snapshot. With the setting off, every command starts from it. With the setting on, each command saves its exported variables for the next one, and that saved copy holds exported variables only, so profile functions and aliases are gone after the first command.
| What | Setting on (default) | Setting off |
|------|----------------------|-------------|
@@ -751,6 +751,7 @@ Every terminal command on the **local** and **SSH** backends runs in a fresh `ba
| Plain shell vars (`MY_VAR=hello`) | do **not** carry over | do not carry over |
| Functions / aliases defined mid-session | do **not** carry over | do not carry over |
| Login environment (PATH, profile exports) | always present | always present |
+| Profile functions / aliases | first command only | always present |
The working directory always carries over because the file tools resolve relative paths against it. To make a variable stick in either mode, `export` it (setting on) or put it in your shell profile or `terminal.env_passthrough`.