summaryrefslogtreecommitdiffstats
path: root/README.md
blob: b70820ad94a751fe35025003cca5ee5a7f19650b (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
<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>
 
`atuin` manages and synchronizes your shell history! Instead of storing 
everything in a text file (such as ~/.history), `atuin` uses a sqlite database.
This lets us do all kinds of analysis on it!

As well as the expected command, this stores

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

## Install

`atuin` needs a recent version of Rust + Cargo! It's best to use rustup for.

```
cargo install atuin
```

and then add this to your ~/.zshrc

```
export ATUIN_SESSION=$(atuin uuid)

_atuin_preexec(){
	id=$(atuin history start $1)
	export ATUIN_HISTORY_ID="$id"
}

_atuin_precmd(){
	local EXIT="$?"

	[[ -z "${ATUIN_HISTORY_ID}" ]] && return

	atuin history end $ATUIN_HISTORY_ID --exit $EXIT
}

add-zsh-hook preexec _atuin_preexec
add-zsh-hook precmd _atuin_precmd
```

We're not replacing anything here, so your default shell history file will still
be written to!

## Usage

### Import history

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

### List history

```
atuin history list
```