Fixes zoxide and compoletions.
This commit is contained in:
@@ -1,12 +1,36 @@
|
||||
# TODO: Check if zoxide_path exists.
|
||||
# TODO: Check shell better.
|
||||
# -n $zoxide_path -a -n $zoxide_path
|
||||
function anon() {
|
||||
zoxide_path=$(which zoxide)
|
||||
if [ -n $zoxide_path -a $zoxide_path != "zoxide not found" ]; then
|
||||
if [ "$SHELL" = "/bin/zsh" ]; then
|
||||
eval "$(zoxide init --cmd cd zsh)"
|
||||
# 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
|
||||
fi
|
||||
}
|
||||
unset -f anon
|
||||
_setup_zoxide
|
||||
unset -f _setup_zoxide
|
||||
|
||||
Reference in New Issue
Block a user