2021-09-08 21:51:44 +00:00
|
|
|
use str
|
|
|
|
|
2022-01-13 10:34:55 +00:00
|
|
|
fn call-navi {
|
2021-09-08 21:51:44 +00:00
|
|
|
if (eq $edit:current-command '') {
|
2022-01-13 10:34:55 +00:00
|
|
|
var answer = (navi --print)
|
2021-09-08 21:51:44 +00:00
|
|
|
edit:replace-input $answer
|
|
|
|
} elif (not (str:contains-any $edit:current-command '|')) {
|
2022-01-13 10:34:55 +00:00
|
|
|
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 {
|
2022-01-13 10:34:55 +00:00
|
|
|
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 '') {
|
2022-01-13 10:34:55 +00:00
|
|
|
set cmds = [$@cmds $answer]
|
2021-09-08 21:51:44 +00:00
|
|
|
edit:replace-input (str:join '| ' $cmds)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-13 10:34:55 +00:00
|
|
|
set edit:insert:binding[Alt-h] = { call-navi >/dev/tty 2>&1 }
|