Avoid using completions on older Bash versions

This commit is contained in:
Ajeet D'Souza 2021-12-20 21:29:11 +05:30
parent bd54ea3ea9
commit 339a789261
16 changed files with 120 additions and 194 deletions

View File

@ -26,6 +26,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fzf: handle early selection.
- PowerShell: correctly handle escape characters in paths.
- Parse error on Cygwin/MSYS due to CRLF line endings.
- Fzf: handle spaces correctly in preview window.
- Bash: avoid initializing completions on older versions.
## [0.7.9] - 2021-11-02

174
Cargo.lock generated
View File

@ -13,21 +13,15 @@ dependencies = [
[[package]]
name = "anyhow"
version = "1.0.51"
version = "1.0.52"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b26702f315f53b6071259e15dd9d64528213b44d61de1ec926eca7715d62203"
[[package]]
name = "arrayvec"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b"
checksum = "84450d0b4a8bd1ba4144ce8ce718fbc5d071358b1e5384bace6536b3d1f2d5b3"
[[package]]
name = "askama"
version = "0.10.5"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d298738b6e47e1034e560e5afe63aa488fea34e25ec11b855a76f0d7b8e73134"
checksum = "4d8f355701c672c2ba3d718acbd213f740beea577cc4eae66accdffe15be1882"
dependencies = [
"askama_derive",
"askama_escape",
@ -36,9 +30,9 @@ dependencies = [
[[package]]
name = "askama_derive"
version = "0.10.5"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca2925c4c290382f9d2fa3d1c1b6a63fa1427099721ecca4749b154cc9c25522"
checksum = "84704cab5b7ae0fd3a9f78ee5eb7b27f3749df445f04623db6633459ae283267"
dependencies = [
"askama_shared",
"proc-macro2",
@ -47,15 +41,15 @@ dependencies = [
[[package]]
name = "askama_escape"
version = "0.10.1"
version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "90c108c1a94380c89d2215d0ac54ce09796823cca0fd91b299cfff3b33e346fb"
checksum = "9a1bb320f97e6edf9f756bf015900038e43c7700e059688e5724a928c8f3b8d5"
[[package]]
name = "askama_shared"
version = "0.11.1"
version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2582b77e0f3c506ec4838a25fa8a5f97b9bed72bb6d3d272ea1c031d8bd373bc"
checksum = "dae03eebba55a2697a376e58b573a29fe36893157173ac8df312ad85f3c0e012"
dependencies = [
"askama_escape",
"nom",
@ -110,18 +104,6 @@ version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
name = "bitvec"
version = "0.19.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "55f93d0ef3363c364d5976646a38f04cf67cfe1d4c8d160cdea02cab2c116b33"
dependencies = [
"funty",
"radium",
"tap",
"wyz",
]
[[package]]
name = "bstr"
version = "0.2.17"
@ -141,9 +123,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "clap"
version = "3.0.0-beta.5"
version = "3.0.0-rc.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "feff3878564edb93745d58cf63e17b63f24142506e7a20c87a5521ed7bfb1d63"
checksum = "484f17839417b695a6f4a75c20e49820ba0a1d00aa41ebd8ba0e5dfe0fbc3b74"
dependencies = [
"atty",
"bitflags",
@ -154,14 +136,13 @@ dependencies = [
"strsim",
"termcolor",
"textwrap",
"unicase",
]
[[package]]
name = "clap_derive"
version = "3.0.0-beta.5"
version = "3.0.0-rc.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b15c6b4f786ffb6192ffe65a36855bc1fc2444bcd0945ae16748dcd6ed7d0d3"
checksum = "a86d4ec799f94ddc4a4a4edf652f89b360219905f86edcb8abe5974dfef135b8"
dependencies = [
"heck",
"proc-macro-error",
@ -172,18 +153,18 @@ dependencies = [
[[package]]
name = "clap_generate"
version = "3.0.0-beta.5"
version = "3.0.0-rc.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "097ab5db1c3417442270cd57c8dd39f6c3114d3ce09d595f9efddbb1fcfaa799"
checksum = "46edf9e899ef90f3cefafb75dfae4c52746911cb905408bdf147a4bfe6fd72aa"
dependencies = [
"clap",
]
[[package]]
name = "clap_generate_fig"
version = "3.0.0-beta.5"
version = "3.0.0-rc.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b3482836f06a77604c543ffbf86b0b9b814e5413cec432d75fea9db7eb9bf26d"
checksum = "dbb18e26b66468ccfcbd787003403c1307dfe913c08c157c8d0f3b6e270015e2"
dependencies = [
"clap",
"clap_generate",
@ -249,12 +230,6 @@ version = "1.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
[[package]]
name = "funty"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fed34cd105917e91daa4da6b3728c47b068749d6a62c59811f06ed2ac71d9da7"
[[package]]
name = "getrandom"
version = "0.2.3"
@ -339,9 +314,9 @@ dependencies = [
[[package]]
name = "itertools"
version = "0.10.1"
version = "0.10.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "69ddb889f9d0d08a67338271fa9b62996bc788c7796a5c18cf057420aaed5eaf"
checksum = "a9a9d19fa1e79b6215ff29b9d6880b706147f16e9b1dbb1e4e5947b5b02bc5e3"
dependencies = [
"either",
]
@ -352,24 +327,11 @@ version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "lexical-core"
version = "0.7.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6607c62aa161d23d17a9072cc5da0be67cdfc89d3afb1e8d9c842bebc2525ffe"
dependencies = [
"arrayvec",
"bitflags",
"cfg-if",
"ryu",
"static_assertions",
]
[[package]]
name = "libc"
version = "0.2.108"
version = "0.2.112"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8521a1b57e76b1ec69af7599e75e38e7b7fad6610f037db8c79b127201b5d119"
checksum = "1b03d17f364a3a042d5e5d46b053bbbf82c92c9430c592dd4c064dc6ee997125"
[[package]]
name = "log"
@ -387,15 +349,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a"
[[package]]
name = "nom"
version = "6.1.2"
name = "minimal-lexical"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e7413f999671bd4745a7b624bd370a569fb6bc574b23c83a3c5ed2e453f3d5e2"
checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
[[package]]
name = "nom"
version = "7.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b1d11e1ef389c76fe5b81bcaf2ea32cf88b62bc494e19f493d0b30e7a930109"
dependencies = [
"bitvec",
"funty",
"lexical-core",
"memchr",
"minimal-lexical",
"version_check",
]
@ -410,9 +376,9 @@ dependencies = [
[[package]]
name = "once_cell"
version = "1.8.0"
version = "1.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "692fcb63b64b1758029e0a96ee63e049ce8c5948587f2f7208df04625e5f6b56"
checksum = "da32515d9f6e6e489d7bc9d84c71b060db7247dc035bbe44eac88cf87486d8d5"
[[package]]
name = "ordered-float"
@ -425,9 +391,9 @@ dependencies = [
[[package]]
name = "os_str_bytes"
version = "4.2.0"
version = "6.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "addaa943333a514159c80c97ff4a93306530d965d27e139188283cd13e06a799"
checksum = "8e22443d1643a904602595ba1cd8f7d896afe56d26712531c5ff73a15b2fbf64"
dependencies = [
"memchr",
]
@ -491,9 +457,9 @@ dependencies = [
[[package]]
name = "proc-macro2"
version = "1.0.32"
version = "1.0.34"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ba508cc11742c0dc5c1659771673afbab7a0efab23aa17e854cbab0837ed0b43"
checksum = "2f84e92c0f7c9d58328b85a78557813e4bd845130db68d7184635344399423b1"
dependencies = [
"unicode-xid",
]
@ -507,12 +473,6 @@ dependencies = [
"proc-macro2",
]
[[package]]
name = "radium"
version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "941ba9d78d8e2f7ce474c015eea4d9c6d25b6a3327f9832ee29a4de27f91bbb8"
[[package]]
name = "rand"
version = "0.8.4"
@ -606,9 +566,9 @@ dependencies = [
[[package]]
name = "rstest"
version = "0.11.0"
version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2288c66aeafe3b2ed227c981f364f9968fa952ef0b30e84ada4486e7ee24d00a"
checksum = "d912f35156a3f99a66ee3e11ac2e0b3f34ac85a07e05263d05a7e2c8810d616f"
dependencies = [
"cfg-if",
"proc-macro2",
@ -626,12 +586,6 @@ dependencies = [
"semver",
]
[[package]]
name = "ryu"
version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3c9613b5a66ab9ba26415184cfc41156594925a9cf3a2057e57f31ff145f6568"
[[package]]
name = "same-file"
version = "1.0.6"
@ -649,18 +603,18 @@ checksum = "568a8e6258aa33c13358f81fd834adb854c6f7c9468520910a9b1e8fac068012"
[[package]]
name = "serde"
version = "1.0.130"
version = "1.0.132"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f12d06de37cf59146fbdecab66aa99f9fe4f78722e3607577a5375d66bd0c913"
checksum = "8b9875c23cf305cd1fd7eb77234cbb705f21ea6a72c637a5c6db5fe4b8e7f008"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.130"
version = "1.0.132"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d7bc1a1ab1961464eae040d96713baa5a724a8152c1222492465b54322ec508b"
checksum = "ecc0db5cb2556c0e558887d9bbdcf6ac4471e83ff66cf696e5419024d1606276"
dependencies = [
"proc-macro2",
"quote",
@ -673,12 +627,6 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6fa3938c99da4914afedd13bf3d79bcb6c277d1b2c398d23257a304d9e1b074"
[[package]]
name = "static_assertions"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
[[package]]
name = "strsim"
version = "0.10.0"
@ -687,21 +635,15 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
[[package]]
name = "syn"
version = "1.0.82"
version = "1.0.83"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8daf5dd0bb60cbd4137b1b587d2fc0ae729bc07cf01cd70b36a1ed5ade3b9d59"
checksum = "23a1dfb999630e338648c83e91c59a4e9fb7620f520c3194b6b89e276f2f1959"
dependencies = [
"proc-macro2",
"quote",
"unicode-xid",
]
[[package]]
name = "tap"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369"
[[package]]
name = "tempfile"
version = "3.2.0"
@ -736,9 +678,6 @@ name = "textwrap"
version = "0.14.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0066c8d12af8b5acd21e00547c3797fde4e8677254a7ee429176ccebbe93dd80"
dependencies = [
"unicode-width",
]
[[package]]
name = "thread_local"
@ -749,27 +688,12 @@ dependencies = [
"once_cell",
]
[[package]]
name = "unicase"
version = "2.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6"
dependencies = [
"version_check",
]
[[package]]
name = "unicode-segmentation"
version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8895849a949e7845e06bd6dc1aa51731a103c42707010a5b591c0038fb73385b"
[[package]]
name = "unicode-width"
version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973"
[[package]]
name = "unicode-xid"
version = "0.2.2"
@ -839,12 +763,6 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "wyz"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "85e60b0d1b5f99db2556934e21937020776a5d31520bf169e851ac44e6420214"
[[package]]
name = "xtask"
version = "0.1.0"

View File

@ -18,9 +18,9 @@ members = ["xtask/"]
[dependencies]
anyhow = "1.0.32"
askama = { version = "0.10.3", default-features = false }
askama = { version = "0.11.0", default-features = false }
bincode = "1.3.1"
clap = "=3.0.0-beta.5"
clap = { version = "=3.0.0-rc.8", features = ["derive"] }
dirs = "4.0.0"
dunce = "1.0.1"
glob = "0.3.0"
@ -35,13 +35,13 @@ rand = { version = "0.8.4", features = [
], default-features = false }
[build-dependencies]
clap = "=3.0.0-beta.5"
clap_generate = "=3.0.0-beta.5"
clap_generate_fig = "=3.0.0-beta.5"
clap = { version = "=3.0.0-rc.8", features = ["derive"] }
clap_generate = "=3.0.0-rc.8"
clap_generate_fig = "=3.0.0-rc.8"
[dev-dependencies]
assert_cmd = "2.0.0"
rstest = "0.11.0"
rstest = "0.12.0"
[features]
default = []

View File

@ -43,7 +43,7 @@ z - # cd into previous directory
zi foo # cd with interactive selection (using fzf)
z foo<SPACE><TAB> # show interactive completions (zoxide v0.7.10+, bash/fish/zsh only)
z foo<SPACE><TAB> # show interactive completions (zoxide v0.8.0+, bash/fish/zsh only)
```
Read more about the matching algorithm [here][algorithm-matching].

View File

@ -79,8 +79,8 @@ _arguments "${_arguments_options[@]}" \
;;
(remove)
_arguments "${_arguments_options[@]}" \
'()-i+[]:keywords: ' \
'()--interactive=[]:keywords: ' \
'()*-i+[]:keywords: ' \
'()*--interactive=[]:keywords: ' \
'-h[Print help information]' \
'--help[Print help information]' \
'-V[Print version information]' \

View File

@ -9,7 +9,7 @@ _zoxide() {
for i in ${COMP_WORDS[@]}
do
case "${i}" in
zoxide)
"$1")
cmd="zoxide"
;;
add)

View File

@ -172,7 +172,6 @@ const completion: Fig.Spec = {
],
args: {
name: "keywords",
isVariadic: true,
isOptional: true,
},
},
@ -184,7 +183,6 @@ const completion: Fig.Spec = {
name: ["-i", "--interactive"],
args: {
name: "interactive",
isVariadic: true,
isOptional: true,
},
},
@ -199,7 +197,6 @@ const completion: Fig.Spec = {
],
args: {
name: "paths",
isVariadic: true,
isOptional: true,
template: "folders",
},

View File

@ -18,7 +18,7 @@ Exclude a path from query results.
Print help information.
.TP
.B -i, --interactive
Use interactive selection. This option requires fzf.
Use interactive selection. This option requires \fBfzf\fR(1).
.TP
.B -l, --list
List all results, rather than just the one with the highest frecency.

View File

@ -12,7 +12,7 @@ If you'd like to permanently exclude a directory from the database, see the
Print help information.
.TP
.B -i, --interactive [KEYWORDS]
Use interactive selection. This option requires fzf.
Use interactive selection. This option requires \fBfzf\fR(1).
.SH REPORTING BUGS
For any issues, feature requests, or questions, please visit:
.sp

View File

@ -86,8 +86,8 @@ By default, this is set to \fB$HOME\fR. After setting this up, you might need
to use \fBzoxide-remove\fR(1) to remove any existing entries from the database.
.TP
.B _ZO_FZF_OPTS
Custom options to pass to fzf during interactive selection. See \fBfzf\fR(1) for
the list of options.
Custom options to pass to \fBfzf\fR(1) during interactive selection. See the
manpage for the full list of options.
.TP
.B _ZO_MAXAGE
Configures the aging algorithm, which limits the maximum number of entries in

View File

@ -1,8 +1,8 @@
let
rust = import (builtins.fetchTarball
"https://github.com/oxalica/rust-overlay/archive/bb5adbd2a830e00aa783d9189f1f4183182663fd.tar.gz");
"https://github.com/oxalica/rust-overlay/archive/203dc4fc3fe2a5df1aa481a3fc8a1bb27074d677.tar.gz");
pkgs = import (builtins.fetchTarball
"https://github.com/NixOS/nixpkgs/archive/58f87c20e1abbbe835f1f3106ecea10fd93c4a90.tar.gz") {
"https://github.com/NixOS/nixpkgs/archive/eac07edbd20ed4908b98790ba299250b5527ecdf.tar.gz") {
overlays = [ rust ];
};
in pkgs.mkShell {

View File

@ -31,7 +31,7 @@ impl Fzf {
"--select-1",
]);
if cfg!(unix) {
command.arg("--preview=ls -p {2}");
command.arg("--preview=ls -p {2..}");
}
}

View File

@ -66,15 +66,17 @@ __zoxide_z_prefix='z#'
# Jump to a directory using only keywords.
function __zoxide_z() {
# shellcheck disable=SC2199
if [[ $# -eq 0 ]]; then
__zoxide_cd ~
elif [[ $# -eq 1 && $1 == '-' ]]; then
__zoxide_cd "${OLDPWD}"
elif [[ $# -eq 1 && -d $1 ]]; then
__zoxide_cd "$1"
elif [[ ${*: -1} == "${__zoxide_z_prefix}"* ]]; then
\builtin local result="${*: -1}"
__zoxide_cd "${result:2}"
elif [[ ${@: -1} == "${__zoxide_z_prefix}"* ]]; then
# shellcheck disable=SC2124
\builtin local result="${@: -1}"
__zoxide_cd "{{ "${result:${#__zoxide_z_prefix}}" }}"
else
\builtin local result
result="$(\command zoxide query --exclude "$(__zoxide_pwd || \builtin true)" -- "$@")" &&
@ -113,15 +115,17 @@ function {{cmd}}i() {
}
# Load completions.
# Completions require line editing. Since Bash supports only two modes of line
# editing (`vim` and `emacs`), we check if one of them is enabled.
if [[ :"${SHELLOPTS}": =~ :(vi|emacs): && ${TERM} != 'dumb' ]]; then
# - Bash 4.0+ is needed to use `mapfile`.
# - Completions require line editing. Since Bash supports only two modes of
# line editing (`vim` and `emacs`), we check if either them is enabled.
# - Completions don't work on `dumb` terminals.
if [[ ${BASH_VERSINFO:-0} -ge 4 && :"${SHELLOPTS}": =~ :(vi|emacs): && ${TERM} != 'dumb' ]]; then
# Use `printf '\e[5n'` to redraw line after fzf closes.
\builtin bind '"\e[0n": redraw-current-line' &>/dev/null
function _{{cmd}}() {
# Only show completions when the cursor is at the end of the line.
[[ {{ "${#COMP_LINE}" }} -eq ${COMP_POINT} ]] || return
[[ {{ "${#COMP_WORDS[@]}" }} -eq $((COMP_CWORD + 1)) ]] || return
# If there is only one argument, use `cd` completions.
if [[ {{ "${#COMP_WORDS[@]}" }} -eq 2 ]]; then
@ -131,7 +135,7 @@ if [[ :"${SHELLOPTS}": =~ :(vi|emacs): && ${TERM} != 'dumb' ]]; then
elif [[ -z ${COMP_WORDS[-1]} ]]; then
\builtin local result
result="$(\command zoxide query -i -- "{{ "${COMP_WORDS[@]:1:${#COMP_WORDS[@]}-2}" }}")" &&
COMPREPLY=("${__zoxide_z_prefix}${result}")
COMPREPLY=("${__zoxide_z_prefix}${result@Q}")
\builtin printf '\e[5n'
fi
}

View File

@ -105,9 +105,7 @@ if "__zoxide_hook" not in globals():
check=False,
env=__zoxide_env(),
)
{% endif -%}
{% endif %}
{{ section }}
# When using zoxide with --no-aliases, alias these internal functions as

View File

@ -50,8 +50,11 @@ fi
# desired.
#
__zoxide_z_prefix='z#'
# Jump to a directory using only keywords.
function __zoxide_z() {
# shellcheck disable=SC2199
if [[ "$#" -eq 0 ]]; then
__zoxide_cd ~
elif [[ "$#" -eq 1 ]] && [[ "$1" = '-' ]]; then
@ -64,6 +67,10 @@ function __zoxide_z() {
fi
elif [[ "$#" -eq 1 ]] && [[ -d "$1" ]]; then
__zoxide_cd "$1"
elif [[ "$@[-1]" == "${__zoxide_z_prefix}"* ]]; then
# shellcheck disable=SC2124
\builtin local result="${@[-1]}"
__zoxide_cd "{{ "${result:${#__zoxide_z_prefix}}" }}"
else
\builtin local result
result="$(\command zoxide query --exclude "$(__zoxide_pwd || \builtin true)" -- "$@")" &&
@ -91,51 +98,51 @@ function __zoxide_unset() {
\builtin unset "$@" &>/dev/null
}
__zoxide_unset '{{cmd}}'
__zoxide_unset {{cmd}}
function {{cmd}}() {
__zoxide_z "$@"
}
__zoxide_unset '{{cmd}}i'
__zoxide_unset {{cmd}}i
function {{cmd}}i() {
__zoxide_zi "$@"
}
if [[ -o zle ]]; then
function _{{cmd}}() {
\builtin local buffer tokens
# shellcheck disable=SC2034,SC2153,SC2154
buffer="${BUFFER}."
# shellcheck disable=SC2206,SC2296
tokens=(${(Q)${(z)buffer}})
__zoxide_unset _{{cmd}}
function _{{cmd}}() {
# Only show completions when the cursor is at the end of the line.
# shellcheck disable=SC2154
[[ "{{ "${#words[@]}" }}" -eq "${CURRENT}" ]] || return
if [[ "{{ "${#tokens[@]}" }}" -eq 2 ]]; then
_files -/
elif [[ "${tokens[-1]}" == '.' ]]; then
\builtin printf '\e[5n'
if [[ "{{ "${#words[@]}" }}" -eq 2 ]]; then
_files -/
elif [[ "${words[-1]}" == '' ]]; then
\builtin local result
# shellcheck disable=SC2086
if result="$(\command zoxide query -i -- ${words[2,-1]})"; then
__zoxide_result="${result}"
else
__zoxide_result=''
fi
\builtin printf '\e[5n'
fi
}
__zoxide_unset _{{cmd}}_helper
function _{{cmd}}_helper() {
\builtin local result="${__zoxide_z_prefix}${__zoxide_result}"
# shellcheck disable=SC2296
[[ -n "${__zoxide_result}" ]] && LBUFFER="${LBUFFER}${(q-)result}"
\builtin zle reset-prompt
}
\builtin zle -N _{{cmd}}_helper
\builtin bindkey "\e[0n" _{{cmd}}_helper
if [[ "${+functions[compdef]}" -ne 0 ]]; then
\compdef -d {{cmd}}
\compdef _{{cmd}} {{cmd}}
fi
}
function _{{cmd}}_helper() {
\builtin local tokens result
# shellcheck disable=SC2154,SC2206,SC2296
tokens=(${(Q)${(z)BUFFER}})
# shellcheck disable=SC2086
if result="$(\command zoxide query -i -- ${tokens[2,-1]})"; then
# shellcheck disable=SC2034
RBUFFER=''
# shellcheck disable=SC2034,SC2296
LBUFFER="${tokens[1]} ${(q-)result}"
fi
\builtin zle reset-prompt
}
\builtin zle -N _{{cmd}}_helper
\builtin bindkey "\e[0n" _{{cmd}}_helper
if [[ "${+functions[compdef]}" -ne 0 ]]; then
\compdef -d {{cmd}}
\compdef _{{cmd}} {{cmd}}
fi
fi
{%- when None %}

View File

@ -6,6 +6,6 @@ publish = false
[dependencies]
anyhow = "1.0.32"
clap = "=3.0.0-beta.5"
clap = { version = "=3.0.0-rc.8", features = ["derive"] }
ignore = "0.4.18"
shell-words = "1.0.0"