I've written a simple function to search the current folder when I press ctrl+f with exa and peco, after I choose a directory I want to cd into it.
(ll is modified version of ls)
pecofunc() {
ll | peco --layout=bottom-up | read foo
foo="${foo##* }"
if [ -n "$foo" ]
then
builtin cd "$foo"
fi
# refresh terminal and end execution
}
zle -N pecofunc pecofunc
bindkey '^f' pecofunc
This part works well but after executing it my directory doesn't visually change until I press enter or use other command.
Picture 1 Terminal before doing anything
Picture 2 After pressing ctrl+f
Picture 3 Choosing test2 and pressing enter
Picture 4 Pressing enter again
Pressing enter again refreshes the folder which I'm in but creates another newline which is unacceptable.
How can I avoid this issue?
reset
command ?builtin echo ""
OR to add to the shortcut&& echo ""
after executing the script ?