Jump to content

Atuin: Difference between revisions

From NixOS Wiki
Klinger (talk | contribs)
Xiutik (talk | contribs)
No edit summary
 
(4 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{note|This page is a WIP}}
{{wip|date=11 March 2025}}


[https://atuin.sh/ Atuin] replaces your existing shell history with a SQLite database, and records additional context for your commands. Additionally, Atuin (optionally) syncs your shell history between all of your machines.
[https://atuin.sh/ Atuin] replaces your existing shell history with a SQLite database, and records additional context for your commands. Additionally, Atuin (optionally) syncs your shell history between all of your machines.
Line 25: Line 25:
==== Imperatively ====
==== Imperatively ====


To synchronize your history with atuin.sh you first need to register an account or login with the cli utility. Doint that will create a key and an session token in <code>~/.local/share/atuin</code>
To synchronize your history with atuin.sh you first need to register an account or login with the cli utility. Doing that will create a key and a session token in <code>~/.local/share/atuin</code>


<syntaxHighlight lang="bash">
<syntaxHighlight lang="bash">
Line 42: Line 42:
You can manage your atuin session declaratively by setting the <code>session_path</code> and <code>key_path</code> options to files containing a session token and a key. You can obtain these two files by registering as described above and copying them from <code>~/.local/share/key</code> and <code>~/.local/share/session</code>. The example below uses agenix
You can manage your atuin session declaratively by setting the <code>session_path</code> and <code>key_path</code> options to files containing a session token and a key. You can obtain these two files by registering as described above and copying them from <code>~/.local/share/key</code> and <code>~/.local/share/session</code>. The example below uses agenix


{{note|Both the session and key file must not have a trailing newline.}}
{{note|Both the session and key file must not have a trailing newline or you get <code>Error: failed to parse header value</code>. Several common editors (e.g. Vim) will automatically add a newline on save.}}


{{file|~/.config/home-manager/home.nix|nix|<nowiki>
{{file|~/.config/home-manager/home.nix|nix|<nowiki>
Line 66: Line 66:
   programs.zsh = {
   programs.zsh = {
     enable = true;
     enable = true;
     autosuggestions.enable = true; # Enable autosuggestions
     autosuggestion.enable = true; # Enable autosuggestions
   };
   };
   programs.atuin = {
   programs.atuin = {

Latest revision as of 13:23, 12 August 2025

🏗︎
This article or section is a work in progress. The work on this article started on 11 March 2025 The information on this page may not be reliable, and the formatting may not follow the Manual of Style yet. Please remove this notice as soon as the work is in a presentable shape.

Atuin replaces your existing shell history with a SQLite database, and records additional context for your commands. Additionally, Atuin (optionally) syncs your shell history between all of your machines.

Enable in your terminal

Atuin can be enabled using home-manager. Documentation for all settings can be found at https://docs.atuin.sh/configuration/config/ .

❄︎ ~/.config/home-manager/home.nix
{ pkgs, ... }: {
  programs.atuin = {
    enable = true;
    settings = {
      auto_sync = true;
      sync_frequency = "5m";
      sync_address = "https://api.atuin.sh";
      search_mode = "fuzzy";
    };
  };
};

Enable synchronization with atuin.sh

Imperatively

To synchronize your history with atuin.sh you first need to register an account or login with the cli utility. Doing that will create a key and a session token in ~/.local/share/atuin

atuin register -u <YOUR_USERNAME> -e <YOUR EMAIL>

To backfill your existing shell history run

atuin import auto
atuin sync # Optionally sync your history to the server

Declaratively

You can manage your atuin session declaratively by setting the session_path and key_path options to files containing a session token and a key. You can obtain these two files by registering as described above and copying them from ~/.local/share/key and ~/.local/share/session. The example below uses agenix

Note: Both the session and key file must not have a trailing newline or you get Error: failed to parse header value. Several common editors (e.g. Vim) will automatically add a newline on save.
❄︎ ~/.config/home-manager/home.nix
{ pkgs, ... }: {
  programs.atuin = {
    enable = true;
    settings = {
      # ... other settings
      
      session_path = config.age.secrets."atuin_session".path;
      key_path = config.age.secrets."atuin_key".path;
    };
  };
};

zsh autosuggestions

If zsh autosuggestions is enabled, atuin automatically adds itself as the first autosuggestion strategy; See atuin docs

❄︎ ~/.config/home-manager/home.nix
{ pkgs, ... }: {
  programs.zsh = {
    enable = true;
    autosuggestion.enable = true; # Enable autosuggestions
  };
  programs.atuin = {
    enable = true;
  };
};