atuinsh/atuin · error
No commands found in history
Error message
No commands found in history
What it means
`handle_new_script` builds a script from recently fetched history commands. If the collected history yields an empty command list, there is nothing to turn into a script, so it bails. This guards against creating empty scripts.
Solutions
- Record some commands first (use the shell normally) and retry.
- Run `atuin sync` if history lives on another machine.
- Check the history query/filters (session, cwd) that select which commands feed the script; widen them.
Defensive patterns
Strategy: validation
Validate before calling
# ensure there is history before deriving a script:
atuin history list --limit 1 >/dev/null 2>&1 \
|| { echo "history is empty; use atuin normally or run 'atuin sync' first"; exit 1; } Try / catch
match new_script_from_history().await {
Err(e) if e.to_string().contains("No commands found in history") => {
eprintln!("no history in scope: run commands or widen the session/time filter");
}
other => other,
} Prevention
- Run `atuin sync` before creating scripts on a new machine.
- Check session/cwd filters that scope the history query.
- Confirm the history DB is non-empty before script creation.
When it happens
Trigger: Running `atuin scripts new` (history-derived flow) when the history query/selection returned no entries — e.g. no commands in the selected session or time range.
Common situations: Fresh install with empty history DB; history filtered out by session/directory; history not yet synced; running the command from a context with no recorded commands.
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
- A script named ' ' already exists
- Config key must be non-empty and must not contain whitespace
- please provide a new password
- please provide a password
- please provide the current password
AI-assisted analysis of atuinsh/atuin@900007c480 (2026-09-19).
Data as JSON: /api/errors/9499dc7b97e35f9f.
Report an issue: GitHub.
Appendix: 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 900007c480)