[READ-ONLY] Mirror of https://github.com/mrgnw/dotfiles. My shell customizations - aliases, functions, and themes.
dotfiles shell zinit zsh
0

Configure Feed

Select the types of activity you want to include in your feed.

dotfiles / zoxide.zsh
2.4 kB 92 lines
1# ============================================================================= 2# 3# Utility functions for zoxide. 4# 5 6# pwd based on the value of _ZO_RESOLVE_SYMLINKS. 7function __zoxide_pwd() { 8 \builtin pwd -L 9} 10 11# cd + custom logic based on the value of _ZO_ECHO. 12function __zoxide_cd() { 13 # shellcheck disable=SC2164 14 \builtin cd "$@" 15} 16 17# ============================================================================= 18# 19# Hook configuration for zoxide. 20# 21 22# Hook to add new entries to the database. 23function __zoxide_hook() { 24 zoxide add -- "$(__zoxide_pwd)" 25} 26 27# Initialize hook. 28# shellcheck disable=SC2154 29if [[ ${precmd_functions[(Ie)__zoxide_hook]} -eq 0 ]] && [[ ${chpwd_functions[(Ie)__zoxide_hook]} -eq 0 ]]; then 30 chpwd_functions=("${chpwd_functions[@]}" "__zoxide_hook") 31fi 32 33# ============================================================================= 34# 35# When using zoxide with --no-aliases, alias these internal functions as 36# desired. 37# 38 39# Jump to a directory using only keywords. 40function __zoxide_z() { 41 if [ "$#" -eq 0 ]; then 42 __zoxide_cd ~ 43 elif [ "$#" -eq 1 ] && [ "$1" = '-' ]; then 44 if [ -n "${OLDPWD}" ]; then 45 __zoxide_cd "${OLDPWD}" 46 else 47 # shellcheck disable=SC2016 48 \builtin printf 'zoxide: $OLDPWD is not set' 49 return 1 50 fi 51 elif [ "$#" -eq 1 ] && [ -d "$1" ]; then 52 __zoxide_cd "$1" 53 else 54 \builtin local result 55 result="$(zoxide query --exclude "$(__zoxide_pwd)" -- "$@")" \ 56 && __zoxide_cd "${result}" 57 fi 58} 59 60# Jump to a directory using interactive search. 61function __zoxide_zi() { 62 \builtin local result 63 result="$(zoxide query -i -- "$@")" && __zoxide_cd "${result}" 64} 65 66# ============================================================================= 67# 68# Convenient aliases for zoxide. Disable these using --no-aliases. 69# 70 71# Remove definitions. 72function __zoxide_unset() { 73 \builtin unalias "$@" &>/dev/null 74 \builtin unfunction "$@" &>/dev/null 75 \builtin unset "$@" &>/dev/null 76} 77 78__zoxide_unset 'z' 79function z() { 80 __zoxide_z "$@" 81} 82 83__zoxide_unset 'zi' 84function zi() { 85 __zoxide_zi "$@" 86} 87 88# ============================================================================= 89# 90# To initialize zoxide, add this to your configuration (usually ~/.zshrc): 91# 92# eval "$(zoxide init zsh)"