autojump.plugin.zsh 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. (( $+commands[autojump] )) || {
  2. echo '[oh-my-zsh] Please install autojump first (https://github.com/wting/autojump)'
  3. return
  4. }
  5. declare -a autojump_paths
  6. autojump_paths=(
  7. $HOME/.autojump/etc/profile.d/autojump.zsh # manual installation
  8. $HOME/.autojump/share/autojump/autojump.zsh # manual installation
  9. $HOME/.nix-profile/etc/profile.d/autojump.sh # NixOS installation
  10. /run/current-system/sw/share/autojump/autojump.zsh # NixOS installation
  11. /usr/share/autojump/autojump.zsh # Debian and Ubuntu package
  12. /etc/profile.d/autojump.zsh # manual installation
  13. /etc/profile.d/autojump.sh # Gentoo installation
  14. /usr/local/share/autojump/autojump.zsh # FreeBSD installation
  15. /opt/local/etc/profile.d/autojump.sh # macOS with MacPorts
  16. /usr/local/etc/profile.d/autojump.sh # macOS with Homebrew (default)
  17. )
  18. for file in $autojump_paths; do
  19. if [[ -f "$file" ]]; then
  20. source "$file"
  21. found=1
  22. break
  23. fi
  24. done
  25. # if no path found, try Homebrew
  26. if (( ! found && $+commands[brew] )); then
  27. file=$(brew --prefix)/etc/profile.d/autojump.sh
  28. if [[ -f "$file" ]]; then
  29. source "$file"
  30. found=1
  31. fi
  32. fi
  33. (( ! found )) && echo '[oh-my-zsh] autojump script not found'
  34. unset autojump_paths file found