Tracking command history across multiple computers

Normal Search

If you pass in additional arguments to Atuin when you call it, you can filter for exit codes, among other things, which limits the results to commands that completed successfully. In addition, you can control the output by specifying the directories in which the commands were entered. The search can also be restricted to specific time periods (Figure 7). Table 1 shows some Atuin query examples. For more parameters, see the search function documentation on GitHub [9].

Table 1

Atuin Query Examples

atuin -e (--exit) 1

Shows which entered commands were not allowed, typically because of missing permissions (see Table 2).

atuin search --exclude-exit 1

Does the opposite of the above command.

atuin search --exit 1 --after 01/07/2022

Displays commands that were entered after July 1, 2022, and were not executable. You can use the --before parameter in a similar way.

atuin search --exit 0 --before 01/07/2022 --cwd .

Displays commands that were successfully executed from the current directory (--cwd .) before July 1, 2022.

atuin gen-completions --shell bash --out-dir ~/.config/atuin

Creates a command completion (bash-completion) in the specified directory.

curl https://api.atuin.sh/enable -d $(cat ~/.local/share/atuin/session)

Creates an activity graph similar to the one for GitHub activities.

Table 2

Exit Codes

Exit Code

Meaning

0

Success

1

Operation not allowed

2

No such directory

3

No such process

Figure 7: You can refine your search results in several ways. Here, the output is restricted to commands that were entered after July 1, 2022, and ended with an exit code of 1.

While it's a bit of a gimmick, the command

atuin stats all

prints an overall statistic and can be restricted to a specific day, for example, by typing

atuin stats day last friday

or by specifying a date (Figure 8). The last row in Table 1 shows how to create a GitHub-style activity graph. However, creating this graph requires registering with the public sync server or running your own server.

Figure 8: The stats command shows how many commands you entered and which you used most often. Here, too, the results can be restricted to a specific time period.

Conclusions

There are many tools that extend the basic history function in different ways. First released in April 2021, Atuin focuses on synchronizing command sequences on different computers. You can use the results globally across all synchronized computers. However, you can also filter your results by computer, the current session, or the directory in which the commands were originally accessed.

Atuin's documentation is still a little sparse, but otherwise it does exactly what it should. Direct support for the tool is available from the Atuin channel on Discord [10], if needed. If you're interested in the way projects like this come about, you can discover more in an interview with Ellie Huxtable, the developer behind Atuin [11].

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Bash History on Steroids

    You can always browse the Bash history using your arrow keys, but Bash's search capabilities are very limited. Enter the clever Bash History Suggest Box.

  • Astrology Hotline

    Because shell command sequences tend to reoccur, smart predictions can save you time typing. We first let the shell keep notes on what gets typed, before a Go program guesses the next command and runs it for you.

  • Don't Know Much About History

    The versatile Bash history command can save you time and effort at the command line.

  • Effectively using Bash history

    You can do more with the Bash history command than just using the arrow keys. We show you how to use this command-line tool more efficiently.

  • McFly

    When it comes to working at the command line, using Bash history effectively can save you time. McFly extends the Bash history's features and helps you find past commands more quickly.

comments powered by Disqus
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters

Support Our Work

Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.

Learn More

News