Skip to content

Commit

Permalink
Merge pull request #670 from cherryblossom000/patch-1
Browse files Browse the repository at this point in the history
Update legacy syntax from Elvish widget
  • Loading branch information
denisidoro committed Jan 15, 2022
2 parents 35b544f + c082c09 commit 153d081
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions shell/navi.plugin.elv
Original file line number Diff line number Diff line change
@@ -1,31 +1,29 @@
use str

fn call-navi []{
fn call-navi {
if (eq $edit:current-command '') {
answer = (navi --print)
var answer = (navi --print)
edit:replace-input $answer
} elif (not (str:contains-any $edit:current-command '|')) {
answer = (navi --print --query $edit:current-command)
var answer = (navi --print --query $edit:current-command)
if (not-eq $answer '') {
edit:replace-input $answer
}
} else {
cmds = [(str:split '|' $edit:current-command)]
qty = (- (count $cmds) 1)
query = (all $cmds | drop $qty)
cmds = [(all $cmds | take $qty)]
answer = ''
if (eq $query '') {
answer = (navi --print)
} else {
answer = (navi --print --query $query)
}
var @cmds query = (str:split '|' $edit:current-command)
var answer = (
if (eq $query '') {
navi --print
} else {
navi --print --query $query
}
)

if (not-eq $answer '') {
cmds = [$@cmds $answer]
set cmds = [$@cmds $answer]
edit:replace-input (str:join '| ' $cmds)
}
}
}

edit:insert:binding[Alt-h] = []{ call-navi >/dev/tty 2>&1 }
set edit:insert:binding[Alt-h] = { call-navi >/dev/tty 2>&1 }

0 comments on commit 153d081

Please sign in to comment.