This repository was archived by the owner on Jan 8, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathatuin.elv
More file actions
69 lines (60 loc) · 1.55 KB
/
atuin.elv
File metadata and controls
69 lines (60 loc) · 1.55 KB
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
use math
use os
use file
use str
set-env ATUIN_SESSION (atuin uuid)
unset-env ATUIN_HISTORY_ID
set edit:after-readline = [$@edit:after-readline {|line|
try {
if (not-eq (str:trim-space $line) '') {
set-env ATUIN_HISTORY_ID (atuin history start -- $line)
}
} catch e {
unset-env ATUIN_HISTORY_ID
}
}]
set edit:after-command = [$@edit:after-command {|m|
if (has-env ATUIN_HISTORY_ID) {
var exit-status = 0
if (not-eq $m[error] $nil) {
if (has-key $m[error][reason] exit-status) {
set exit-status = $m[error][reason][exit-status]
} else {
set exit-status = 127
}
}
var duration = (exact-num (math:round (* $m[duration] 1000000000)))
var history-end = {
tmp E:ATUIN_LOG = 'error'
atuin history end --exit $exit-status --duration $duration -- $E:ATUIN_HISTORY_ID >$os:dev-null 2>&1
unset-env ATUIN_HISTORY_ID
}
if $notify-bg-job-success {
$history-end
} else {
$history-end &
}
}
}]
fn search {|@argv|
var accept-prefix = '__atuin_accept__:'
var p = (file:pipe)
# TODO: Will need an elvish flag in Atuin binary
with [E:ATUIN_LOG = 'error'] [E:ATUIN_SHELL_BASH = t] [E:ATUIN_QUERY = $edit:current-command] {
atuin search $@argv -i >$os:dev-tty 2>$p; edit:redraw &full=$true
}
file:close $p[w]
var command = (str:trim-space (slurp < $p))
file:close $p[r]
if (not-eq $command '') {
if (str:has-prefix $command $accept-prefix) {
edit:replace-input (str:trim-prefix $command $accept-prefix)
edit:return-line
} else {
edit:replace-input $command
}
}
}
fn search-up {
search --shell-up-key-binding
}