aboutsummaryrefslogtreecommitdiffstats
path: root/src/shell/atuin.fish
blob: 5d59d01d88fae1972b4a117bb53c142c37896055 (plain) (blame)
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
set -gx ATUIN_SESSION (atuin uuid)
set -gx ATUIN_HISTORY (atuin history list)

function _atuin_preexec --on-event fish_preexec
    set -gx ATUIN_HISTORY_ID (atuin history start "$argv[1]")
end

function _atuin_postexec --on-event fish_postexec
    set s $status
    if test -n "$ATUIN_HISTORY_ID"
        RUST_LOG=error atuin history end $ATUIN_HISTORY_ID --exit $s &; disown
    end
end

function _atuin_search
    set h (RUST_LOG=error atuin search -i (commandline -b) 3>&1 1>&2 2>&3)
    commandline -f repaint
    if test -n "$h"
        commandline -r $h
    end
end

if test -z $ATUIN_NOBIND
    bind -k up '_atuin_search'
    bind \eOA '_atuin_search'
    bind \e\[A '_atuin_search'
end