navi/shell/navi.plugin.elv

30 lines
704 B
Text
Raw Normal View History

2021-09-08 21:51:44 +00:00
use str
fn call-navi {
2021-09-08 21:51:44 +00:00
if (eq $edit:current-command '') {
var answer = (navi --print)
2021-09-08 21:51:44 +00:00
edit:replace-input $answer
} elif (not (str:contains-any $edit:current-command '|')) {
var answer = (navi --print --query $edit:current-command)
2021-09-08 21:51:44 +00:00
if (not-eq $answer '') {
edit:replace-input $answer
}
} else {
var @cmds query = (str:split '|' $edit:current-command)
var answer = (
if (eq $query '') {
navi --print
} else {
navi --print --query $query
}
)
2021-09-08 21:51:44 +00:00
if (not-eq $answer '') {
set cmds = [$@cmds $answer]
2021-09-08 21:51:44 +00:00
edit:replace-input (str:join '| ' $cmds)
}
}
}
set edit:insert:binding[Alt-h] = { call-navi >/dev/tty 2>&1 }