I am trying to create a keybind that maps to a function. whenever I call the function from the terminal it works perfectly but whenever I use my keybind it doesn't and I get this error: No such widget `fzf-cd'. this is my code
function fzf-cd() {
local dir=$(find . -type d -print | fzf)
if [[ -n "$dir" ]]; then
cd "$dir"
echo "Switched to: $dir"
else
echo "No directory chosen."
fi
}
bindkey "\ef" fzf-cd
I've trying to change the keybind to something else but that doesn't really help at all.
Never tried it myself, but I'm pretty certain that you need to register your function as widget before you can use it in zle:
However, the content of your function
fcf-cdfunction looks a bit strange to me for the use as a zle widget. The purpose of widgets is to act as kind of "programmable macros", and I would expect your function to at least simulate other key presses.