#!/usr/bin/env sh

# Description: cd to any dir in the z database using an fzf pane

. "$(dirname "$0")"/.nnn-plugin-helper

if type fzf >/dev/null 2>&1; then
    fuzzy="fzf --no-multi"
else
    exit 1
fi

if command -v zoxide >/dev/null; then
    sel=$(zoxide query --list | $fuzzy)
else
    exit 1
fi

printf "%s" "0c$sel" > "$NNN_PIPE"
