atuinsh/atuin · error
No commands found in history
Error message
No commands found in history
What it means
When creating a script from history (`atuin scripts new`), atuin collects the selected history entries' commands and refuses to build an empty script. If the filtered history list contains no commands, it bails with "No commands found in history" instead of opening the editor with an empty file.
Source
Thrown at crates/atuin/src/command/client/scripts.rs:248
// Get the last N+1 commands, filtering by the default mode
let filters = [settings.default_filter_mode(context.git_root.is_some())];
let mut history =
history_db.list(filters, &context, Some(count), false, false, None).await?;
// Reverse to get chronological order
history.reverse();
// Skip the most recent command (which would be the atuin scripts new command itself)
if !history.is_empty() {
history.pop(); // Remove the most recent command
}
// Format the commands into a script
let commands: Vec<String> = history.iter().map(|h| h.command.clone()).collect();
if commands.is_empty() {
bail!("No commands found in history");
}
let script_text = commands.join("\n");
// Only open editor if --no-edit is not specified
if new_script.no_edit {
Some(script_text)
} else {
// Open the editor with the commands pre-loaded
Some(Self::open_editor(Some(&script_text))?)
}
} else if let Some(script_path) = new_script.script {
let script_content = std::fs::read_to_string(script_path)?;
Some(script_content)
} else if !stdin.is_terminal() {
let mut buffer = String::new();
stdin.read_to_string(&mut buffer)?;
Some(buffer)View on GitHub (pinned to c0c717ab04)
Solutions
- Broaden or correct the search query/filter so it matches history entries.
- Run `atuin import auto` (or your shell's import) to populate history, then retry.
- Check that history exists: run `atuin history list` and confirm the commands you expect are present.
- Verify the correct `--cwd`/`--host`/time-range filters are being passed.
Example fix
// before atuin scripts new "npm tes" # typo matches nothing // after atuin scripts new "npm test" # or run `atuin history list` to find the right text
Defensive patterns
Strategy: validation
Validate before calling
# shell if [ -z "$(atuin history list 2>/dev/null | head -n1)" ]; then echo "history empty; run 'atuin import auto' first" >&2 exit 1 fi
Try / catch
if ! out=$(atuin scripts new "$query" 2>&1); then
case "$out" in
*"No commands found in history"*) atuin import auto && atuin scripts new "$query" ;;
esac
fi Prevention
- Verify your query matches history via `atuin history list` before piping into scripts new.
- Import history on fresh machines (`atuin import auto`).
- Avoid over-narrow cwd/host/time filters when selecting commands.
When it happens
Trigger: Running `atuin scripts new` with filters/query that match zero history entries, so `commands.is_empty()` is true after collecting from the history iterator.
Common situations: Typing a search query that matches nothing, an empty local history database (fresh install, history not yet imported), or too-narrow time/directory/host filters.
Understand the failure class
Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.
Related errors
- Failed to read from input
- authentication canceled
- You are not logged in
- please provide the current password
- please provide a new password
AI-assisted analysis of atuinsh/atuin@c0c717ab04 (2026-09-12).
Data as JSON: /api/errors/9499dc7b97e35f9f.
Report an issue: GitHub.