-
Notifications
You must be signed in to change notification settings - Fork 495
Description
Summary
Add a new option to the common-utils
feature to automatically persist shell history (bash/zsh) across container rebuilds, eliminating the need for manual mounts in devcontainer.json
.
Problem Statement
Currently, shell command history is lost when dev containers are rebuilt. Users must manually configure mounts in their devcontainer.json
to persist history, which requires:
- Creating a local directory structure (e.g.,
.devcontainer/data/
) - Adding manual mounts like:
"mounts": [
"source=${localWorkspaceFolder}/.devcontainer/data/zsh_history,target=/home/vscode/.zsh_history,type=bind,consistency=cached"
]
This is a common need but requires manual setup that could be automated.
Proposed Solution
Add a new boolean option persistHistory
(or similar) to the common-utils
feature that would:
- When enabled: Automatically configure the container to persist shell history files
- Implementation approach:
- Create a standard directory structure for history persistence
- Configure appropriate symbolic links or mount points
- Handle both bash (
.bash_history
) and zsh (.zsh_history
) histories - Work with different user configurations (vscode, root, custom users)
Example Usage
{
"features": {
"ghcr.io/devcontainers/features/common-utils:2": {
"installZsh": true,
"installOhMyZsh": true,
"persistHistory": true
}
}
}
Benefits
- Improved Developer Experience: History persistence works out-of-the-box
- Consistency: Standardized approach across different dev containers
- Reduced Configuration: No need for manual mounts configuration
- Best Practices: Automated implementation of a common pattern
Current Workaround
Users currently need to manually add mounts like:
"mounts": [
"source=${localWorkspaceFolder}/.devcontainer/data/zsh_history,target=/home/vscode/.zsh_history,type=bind,consistency=cached"
]
Additional Context
This feature would complement the existing shell-related options (installZsh
, installOhMyZsh
, etc.) by completing the shell experience with history persistence.
The feature should be:
- Optional: Disabled by default to maintain backward compatibility
- Cross-platform: Work with different base images and distributions
- Multi-user: Support different username configurations
- Shell-agnostic: Work with both bash and zsh