forked from lix-project/lix
79674c6cdb
Installed site-functions need to be run directly, not via compdef.
24 lines
529 B
Bash
24 lines
529 B
Bash
#compdef nix
|
|
|
|
function _nix() {
|
|
local ifs_bk="$IFS"
|
|
local input=("${(Q)words[@]}")
|
|
IFS=$'\n'
|
|
local res=($(NIX_GET_COMPLETIONS=$((CURRENT - 1)) "$input[@]"))
|
|
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
|
|
}
|
|
|
|
_nix "$@"
|