#!/usr/bin/env bash # https://zoxide.org/blog/zoxide-download-guide/ # https://zoxide.org/blog/zoxide-alias-autocomplete/ # cargo install --force zoxide # DEST=${1:-/etc/skel} sudo apt update sudo apt install -y zoxide # This initializes zoxide and sets up the 'cd' alias automatically # eval "$(zoxide init zsh --cmd cd)" # What this does: # * cd now uses zoxide's fuzzy logic. # * cd .. still goes up one directory. # * cd /tmp still goes to an absolute path. # * But cd foo will jump to your most frequent foo directory, even if it's # deep in your file system. # # Note: If you use this, the z command will still exist, but cd becomes your # daily driver. # Example: Zsh Lazy Load Script # z() { # unfunction "$0" # eval "$(zoxide init zsh)" # $0 "$@" # } # ⚠️ Warning: The downside of lazy loading is that zoxide won't record directory # changes until after you run z for the first time in that session. If you open # a terminal, cd around manually, and then close it without ever running z, those # paths won't be saved to the database. conf_print_zshrc() { cat <<-'EOF' eval "$(zoxide init zsh --cmd cd)" EOF } conf_print_zshrc | tee "${DEST}/.zshrc.d/004_zoxide.zsh" # z and zi aliaes are part of the eval above. # Alias for interactive selection using fzf # alias zi='__zoxide_zi' conf_print_zsh_alias() { cat <<-'EOF' alias z='__zoxide_z' alias zi='__zoxide_zi' alias j='z' alias jj='zi' EOF } conf_print_zsh_alias | tee "${DEST}/.zsh_aliases.d/004_zoxide.zsh"