Files
profile/.rc.d/zoxide.sh

37 lines
1022 B
Bash
Executable File

# Setup zoxide (smarter cd command) for interactive shells (bash and zsh)
_setup_zoxide() {
# Only run in interactive shells
case $- in
*i*) ;;
*) return 0 ;;
esac
# Ensure zoxide binary is accessible if installed in common locations
if ! command -v zoxide >/dev/null 2>&1; then
for _zoxide_bin_dir in \
"/opt/homebrew/bin" \
"/usr/local/bin" \
"$HOME/.local/bin" \
"$HOME/bin"
do
if [ -x "$_zoxide_bin_dir/zoxide" ]; then
case ":$PATH:" in
*":$_zoxide_bin_dir:"*) ;;
*) PATH="$_zoxide_bin_dir:$PATH"; export PATH ;;
esac
break
fi
done
fi
command -v zoxide >/dev/null 2>&1 || return 0
if [ -n "$ZSH_VERSION" ]; then
eval "$(zoxide init --cmd cd zsh)"
elif [ -n "$BASH_VERSION" ]; then
eval "$(zoxide init --cmd cd bash)"
fi
}
_setup_zoxide
unset -f _setup_zoxide