mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-23 14:36:16 +02:00
9d840758a8
This fixes weird issues where e.g. nix build -L .#<tab> deletes the current line from the prompt.
23 lines
541 B
Bash
23 lines
541 B
Bash
#compdef nix
|
|
|
|
function _nix() {
|
|
local ifs_bk="$IFS"
|
|
local input=("${(Q)words[@]}")
|
|
IFS=$'\n'
|
|
local res=($(NIX_GET_COMPLETIONS=$((CURRENT - 1)) "$input[@]" 2>/dev/null))
|
|
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 "$@"
|