Skip to main content

Module shell

Module shell 

Source
Expand description

Shell integration — generates dodot-init.sh.

Unlike the Go implementation which ships a ~400-line shell script that re-discovers the datastore layout at runtime, we generate a flat, declarative script from the actual datastore state. This means:

  • Zero logic duplication between Rust and shell
  • The script is just source and PATH= lines — trivially fast
  • Changes to the datastore layout only need to happen in Rust

The generated script is written to data_dir/shell/dodot-init.sh. Users source it from their shell profile:

[ -f ~/.local/share/dodot/shell/dodot-init.sh ] && . ~/.local/share/dodot/shell/dodot-init.sh

In the future, this can also be exposed as dodot init-sh or a minimal standalone binary for even faster shell startup.

§Profiling wrapper (Phase 2 of profiling.lex)

When the caller passes profiling_enabled = true, the generator wraps every source and PATH line with an inline EPOCHREALTIME capture and writes one profile-*.tsv per shell start under <data_dir>/probes/shell-init/. The wrapper is gated on a runtime check (bash 5+ / zsh with EPOCHREALTIME available); shells without the variable fall through to the unchanged source/PATH path with a single [ "$_dodot_prof" = "1" ] test of overhead. When profiling_enabled = false, the generated script is byte-identical to the pre-Phase-2 form.

Sources are not wrapped in a shell function: in zsh, source inside a function changes scoping for plain variable assignments in the sourced file, which is a behavioural surprise nobody asked for. We pay the price of a slightly longer script in exchange for semantic equivalence with the un-instrumented form.

Re-exports§

pub use validate::error_sidecar_path;
pub use validate::validate_shell_sources;
pub use validate::NoopSyntaxChecker;
pub use validate::ShellValidationFailure;
pub use validate::ShellValidationReport;
pub use validate::SyntaxCheckResult;
pub use validate::SyntaxChecker;
pub use validate::SystemSyntaxChecker;
pub use validate::ERRORS_SUBDIR;

Modules§

validate
Pre-flight syntax check for shell-sourced files.

Functions§

generate_init_script
Generate the shell init script content from the current datastore state.
write_init_script
Generate and write the init script to data_dir/shell/dodot-init.sh.