From 25a3b97b14525b990cc170b68a2ed923cc4f3010 Mon Sep 17 00:00:00 2001 From: Fabio Scotto di Santolo Date: Wed, 11 Nov 2026 19:04:19 +0100 Subject: [PATCH] Persist Bash history in WSL devcontainers Mount a per-devcontainer history directory from the WSL host and point HISTFILE at it so shell history survives container rebuilds. Co-Authored-By: Claude Code --- .../tasks/cdp_devcontainer.yml | 8 ++++++++ .../tasks/ecaas_devcontainer.yml | 8 ++++++++ .../templates/cdp-devcontainer.json.j2 | 4 +++- .../templates/ecaas-devcontainer.json.j2 | 4 +++- 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/ansible/roles/profile_workstation_dev_wsl/tasks/cdp_devcontainer.yml b/ansible/roles/profile_workstation_dev_wsl/tasks/cdp_devcontainer.yml index 18c79fb..452c51a 100644 --- a/ansible/roles/profile_workstation_dev_wsl/tasks/cdp_devcontainer.yml +++ b/ansible/roles/profile_workstation_dev_wsl/tasks/cdp_devcontainer.yml @@ -40,6 +40,14 @@ group: "{{ user_group }}" mode: "0700" + - name: Ensure the persistent Bash history directory mounted into the container exists + ansible.builtin.file: + path: "{{ user_home }}/.local/state/devcontainer-bash-history/cdp" + state: directory + owner: "{{ username }}" + group: "{{ user_group }}" + mode: "0700" + - name: Ensure the private ecaas Git state directory exists ansible.builtin.file: path: "{{ ecaas_agent_state }}" diff --git a/ansible/roles/profile_workstation_dev_wsl/tasks/ecaas_devcontainer.yml b/ansible/roles/profile_workstation_dev_wsl/tasks/ecaas_devcontainer.yml index 6dc20b4..d4a49ce 100644 --- a/ansible/roles/profile_workstation_dev_wsl/tasks/ecaas_devcontainer.yml +++ b/ansible/roles/profile_workstation_dev_wsl/tasks/ecaas_devcontainer.yml @@ -32,6 +32,14 @@ group: "{{ user_group }}" mode: "0755" + - name: Ensure the persistent Bash history directory mounted into the container exists + ansible.builtin.file: + path: "{{ user_home }}/.local/state/devcontainer-bash-history/ecaas" + state: directory + owner: "{{ username }}" + group: "{{ user_group }}" + mode: "0700" + - name: Ensure the private ecaas Git state directory exists ansible.builtin.file: path: "{{ ecaas_agent_state }}" diff --git a/ansible/roles/profile_workstation_dev_wsl/templates/cdp-devcontainer.json.j2 b/ansible/roles/profile_workstation_dev_wsl/templates/cdp-devcontainer.json.j2 index 7bdf614..f966e45 100644 --- a/ansible/roles/profile_workstation_dev_wsl/templates/cdp-devcontainer.json.j2 +++ b/ansible/roles/profile_workstation_dev_wsl/templates/cdp-devcontainer.json.j2 @@ -10,7 +10,8 @@ "remoteUser": "vscode", "updateRemoteUserUID": true, "containerEnv": { - "CLAUDE_CONFIG_DIR": "/home/vscode/.claude" + "CLAUDE_CONFIG_DIR": "/home/vscode/.claude", + "HISTFILE": "/home/vscode/.bash_history.d/history" }, "remoteEnv": { "ANTHROPIC_AUTH_TOKEN": "${localEnv:ANTHROPIC_AUTH_TOKEN}" @@ -26,6 +27,7 @@ {{ ('type=bind,source=' ~ user_home ~ '/.local/share/certs/' ~ ca.certificate ~ ',target=/run/ecaas-git-ca/' ~ ca.certificate ~ ',readonly') | to_json }}, {% endfor %} {{ ('type=bind,source=' ~ user_home ~ '/.config/ai,target=/home/vscode/.config/ai,readonly') | to_json }}, + {{ ('type=bind,source=' ~ user_home ~ '/.local/state/devcontainer-bash-history/cdp,target=/home/vscode/.bash_history.d') | to_json }}, {{ ('type=bind,source=' ~ user_home ~ '/.claude,target=/home/vscode/.claude') | to_json }}, {{ ('type=bind,source=' ~ user_home ~ '/.cline,target=/home/vscode/.cline') | to_json }}, {{ ('type=bind,source=' ~ user_home ~ '/.m2,target=/home/vscode/.m2') | to_json }}, diff --git a/ansible/roles/profile_workstation_dev_wsl/templates/ecaas-devcontainer.json.j2 b/ansible/roles/profile_workstation_dev_wsl/templates/ecaas-devcontainer.json.j2 index 24e7aae..e0f3024 100644 --- a/ansible/roles/profile_workstation_dev_wsl/templates/ecaas-devcontainer.json.j2 +++ b/ansible/roles/profile_workstation_dev_wsl/templates/ecaas-devcontainer.json.j2 @@ -9,7 +9,8 @@ "remoteUser": "vscode", "updateRemoteUserUID": true, "containerEnv": { - "CLAUDE_CONFIG_DIR": "/home/vscode/.claude" + "CLAUDE_CONFIG_DIR": "/home/vscode/.claude", + "HISTFILE": "/home/vscode/.bash_history.d/history" }, "remoteEnv": { "ANTHROPIC_AUTH_TOKEN": "${localEnv:ANTHROPIC_AUTH_TOKEN}" @@ -25,6 +26,7 @@ {{ ('type=bind,source=' ~ user_home ~ '/.local/share/certs/' ~ ca.certificate ~ ',target=/run/ecaas-git-ca/' ~ ca.certificate ~ ',readonly') | to_json }}, {% endfor %} {{ ('type=bind,source=' ~ user_home ~ '/.config/ai,target=/home/vscode/.config/ai,readonly') | to_json }}, + {{ ('type=bind,source=' ~ user_home ~ '/.local/state/devcontainer-bash-history/ecaas,target=/home/vscode/.bash_history.d') | to_json }}, {{ ('type=bind,source=' ~ user_home ~ '/.claude,target=/home/vscode/.claude') | to_json }}, {{ ('type=bind,source=' ~ user_home ~ '/.cline,target=/home/vscode/.cline') | to_json }}, {{ ('type=bind,source=' ~ user_home ~ '/.m2,target=/home/vscode/.m2') | to_json }},