Add the following to devcontainer.json:
"features": { "ghcr.io/devcontainer-community/devcontainer-features/atuin.sh:1": {} },
"mounts": ["source=${localEnv:HOME}${localEnv:USERPROFILE}/.local/share/atuin,target=/home/vscode/.local/share/atuin,type=bind,consistency=cached"],
"postCreateCommand": "sh .devcontainer/atuin-setup.sh"
Also create the file atuin-setup.sh in the .devcontainer folder and paste the following:
#!/bin/sh
# for bash
curl https://raw.githubusercontent.com/rcaloras/bash-preexec/master/bash-preexec.sh -o ~/.bash-preexec.sh
echo '[[ -f ~/.bash-preexec.sh ]] && source ~/.bash-preexec.sh' >> ~/.bashrc
echo 'eval "$(atuin init bash)"' >> ~/.bashrc
# for zsh
echo 'eval "$(atuin init zsh)"' >> ~/.zshrc
What does this do:
Atuin stores shell history in the folder /home/$user/.local/share/atuin, so this will need to be mounted to the container.
the atuin devcontainer-features installs atuin in the devcontainer and the postCreateCommand initializes atuin (only needs to be run once).
Note: the atuin folder is mounted to the assumed home directory /home/vscode/.. as default. However, if you set up a custom user for the container you will need to change this.