summaryrefslogtreecommitdiffstats
path: root/README.md
blob: 5c44041729954c09987c18f96b5ab36358b06d45 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
<h1 align="center">
  A'tuin
</h1>
<blockquote align="center">
  Through the fathomless deeps of space swims the star turtle Great Aโ€™Tuin, bearing on its back the four giant elephants who carry on their shoulders the mass of the Discworld.
 </blockquote>

<p align="center">
  <a href="https://github.com/ellie/atuin/actions?query=workflow%3ARust"><img src="https://img.shields.io/github/workflow/status/ellie/atuin/Rust?style=flat-square" /></a>
  <a href="https://crates.io/crates/atuin"><img src="https://img.shields.io/crates/v/atuin.svg?style=flat-square" /></a>
  <a href="https://crates.io/crates/atuin"><img src="https://img.shields.io/crates/d/atuin.svg?style=flat-square" /></a>
  <a href="https://github.com/ellie/atuin/blob/main/LICENSE"><img src="https://img.shields.io/crates/l/atuin.svg?style=flat-square" /></a>
</p>
 
A'tuin manages and synchronizes your shell history! Instead of storing
everything in a text file (such as ~/.history), A'tuin uses a sqlite database.
While being a little more complex, this allows for more functionality.

As well as the expected command, A'tuin stores

- duration
- exit code
- working directory
- hostname
- time
- a unique session ID

## Supported Shells

- zsh

## Requirements

- [fzf](https://github.com/junegunn/fzf)

## Install

### AUR

A'tuin is available on the [AUR](https://aur.archlinux.org/packages/atuin/)

```
yay -S atuin # or your AUR helper of choice
```

### With cargo

`atuin` needs a nightly version of Rust + Cargo! It's best to use
[rustup](https://rustup.rs/) for getting set up there.

```
rustup default nightly

cargo install atuin
```

### From source

```
rustup default nightly
git clone https://github.com/ellie/atuin.git
cd atuin
cargo install --path .
```

### Shell plugin

Once the binary is installed, the shell plugin requires installing. Add

```
eval "$(atuin init)"
```

to your `.zshrc`/`.bashrc`/whatever your shell uses.

## Usage

### History search

By default A'tuin will rebind ctrl-r to use fzf to fuzzy search your history.
It will also rebind the up arrow to use fzf, just without sorting. You can
prevent this by putting

```
export ATUIN_BINDKEYS="false"
```

into your shell config.

You may also change the default history selection. The default behaviour will search your entire history, however

```
export ATUIN_HISTORY="atuin history list --cwd"
```

will switch to only searching history for the current directory.

Similarly,

```
export ATUIN_HISTORY="atuin history list --session"
```

will search for the current session only, and

```
export ATUIN_HISTORY="atuin history list --session --cwd"
```

will do both!

### Import history

```
atuin import auto # detect shell, then import

or

atuin import zsh  # specify shell
```

### List history

List all history

```
atuin history list
```

List history for the current directory

```
atuin history list --cwd

atuin h l -c # alternative, shorter version
```

List history for the current session

```
atuin history list --session

atuin h l -s # similarly short
```

### Stats

A'tuin can calculate statistics for a single day, and accepts "natural language" style date input, as well as absolute dates:

```
$ atuin stats day last friday

+---------------------+------------+
| Statistic           | Value      |
+---------------------+------------+
| Most used command   | git status |
+---------------------+------------+
| Commands ran        |        450 |
+---------------------+------------+
| Unique commands ran |        213 |
+---------------------+------------+

$ atuin stats day 01/01/21 # also accepts absolute dates
```

It can also calculate statistics for all of known history:

```
$ atuin stats all

+---------------------+-------+
| Statistic           | Value |
+---------------------+-------+
| Most used command   |    ls |
+---------------------+-------+
| Commands ran        |  8190 |
+---------------------+-------+
| Unique commands ran |  2996 |
+---------------------+-------+
```

## ...what's with the name?

A'tuin is named after "The Great A'tuin", a giant turtle from Terry Pratchett's
Discworld series of books.