2021-06-13 04:50:26 +00:00
|
|
|
#compdef nix
|
|
|
|
|
2020-10-09 07:41:55 +00:00
|
|
|
function _nix() {
|
|
|
|
local ifs_bk="$IFS"
|
|
|
|
local input=("${(Q)words[@]}")
|
|
|
|
IFS=$'\n'
|
2022-02-04 21:43:16 +00:00
|
|
|
local res=($(NIX_GET_COMPLETIONS=$((CURRENT - 1)) "$input[@]" 2>/dev/null))
|
2020-10-09 07:41:55 +00:00
|
|
|
IFS="$ifs_bk"
|
|
|
|
local tpe="${${res[1]}%%> *}"
|
|
|
|
local -a suggestions
|
|
|
|
declare -a suggestions
|
|
|
|
for suggestion in ${res:1}; do
|
|
|
|
# FIXME: This doesn't work properly if the suggestion word contains a `:`
|
|
|
|
# itself
|
|
|
|
suggestions+="${suggestion/ /:}"
|
|
|
|
done
|
|
|
|
if [[ "$tpe" == filenames ]]; then
|
|
|
|
compadd -f
|
|
|
|
fi
|
|
|
|
_describe 'nix' suggestions
|
|
|
|
}
|
|
|
|
|
2021-06-13 04:50:26 +00:00
|
|
|
_nix "$@"
|