diff --git a/src/chezmoi/devcontainer-feature.json b/src/chezmoi/devcontainer-feature.json index 197d6e1..da2beb7 100644 --- a/src/chezmoi/devcontainer-feature.json +++ b/src/chezmoi/devcontainer-feature.json @@ -1,7 +1,7 @@ { "name": "chezmoi", "id": "chezmoi", - "version": "1.2.1", + "version": "1.3.0", "description": "Install chezmoi", "documentationURL": "https://github.com/ckagerer/devcontainer-features/tree/main/src/chezmoi", "options": { @@ -24,13 +24,9 @@ "type": "string", "default": "", "description": "The key to use for Atuin. Leave empty if you don't want to use Atuin." - }, - "atuin_import_history": { - "type": "boolean", - "default": false, - "description": "Import existing history from bash and zsh." } }, + "postCreateCommand": "/usr/local/share/chezmoi-atuin-init.sh", "installsAfter": [ "ghcr.io/devcontainers/features/common-utils", "ghcr.io/devcontainers/features/python" diff --git a/src/chezmoi/install.sh b/src/chezmoi/install.sh index 3559c30..3d3ba43 100644 --- a/src/chezmoi/install.sh +++ b/src/chezmoi/install.sh @@ -47,19 +47,27 @@ CMD="chezmoi ${CHEZMOI_ARGS[*]} ${DOTFILES_REPO}" sudo --user "${CHEZMOI_USER}" bash -c "cd ${CHEZMOI_USER_HOME} && REMOTE_CONTAINERS=1 ${CMD}" # Atuin login and sync +# --- Generate a 'pull-git-lfs-artifacts.sh' script to be executed by the 'postCreateCommand' lifecycle hook +INIT_ATUIN_SCRIPT_PATH="/usr/local/share/chezmoi-atuin-init.sh" + +tee "$INIT_ATUIN_SCRIPT_PATH" >/dev/null \ + </dev/null; then - sudo --user "${CHEZMOI_USER}" atuin import bash || true - fi - if command -v zsh &>/dev/null; then - sudo --user "${CHEZMOI_USER}" atuin import zsh || true - fi + # If /.persist-shell-history exists, we assume that the user wants to persist also the atuin history + if [ -d "/.persist-shell-history" ]; then + mkdir -p ~/.local/share/atuin + ln -s /.persist-shell-history/atuin ~/.local/share/atuin fi + + atuin login --username "${ATUIN_USER}" --password "${ATUIN_PASSWORD}" --key "${ATUIN_KEY}" + atuin sync fi +EOF + +chmod 755 "$INIT_ATUIN_SCRIPT_PATH" echo "Done"