From 6197f5e0908f2c513a8924918b756e61c0193400 Mon Sep 17 00:00:00 2001 From: Ajeet D'Souza <98ajeet@gmail.com> Date: Fri, 3 Sep 2021 15:36:19 +0530 Subject: [PATCH] Add elvish completions for z --- templates/elvish.txt | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/templates/elvish.txt b/templates/elvish.txt index c40e469..7929b24 100644 --- a/templates/elvish.txt +++ b/templates/elvish.txt @@ -80,8 +80,25 @@ edit:add-var __zoxide_zi~ $__zoxide_zi~ {%- match cmd %} {%- when Some with (cmd) %} -edit:add-var z~ $__zoxide_z~ -edit:add-var zi~ $__zoxide_zi~ +edit:add-var {{cmd}}~ $__zoxide_z~ +edit:add-var {{cmd}}i~ $__zoxide_zi~ + +# Load completions. +{# zoxide-based completions are currently not possible, because Elvish only + # prints a completion if the current token is a prefix of it. -#} +fn __zoxide_z_complete [@args]{ + if (!= (count $args) 2) { + return + } + edit:complete-filename $args[1] | + each [c]{ + dir = $c[stem] + if (path:is-dir $dir) { + put $dir + } + } +} +edit:completion:arg-completer[{{cmd}}] = $__zoxide_z_complete~ {%- when None %}