autojump.plugin.zsh 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. declare -a autojump_paths
  2. autojump_paths=(
  3. $HOME/.autojump/etc/profile.d/autojump.zsh # manual installation
  4. $HOME/.autojump/share/autojump/autojump.zsh # manual installation
  5. $HOME/.nix-profile/etc/profile.d/autojump.sh # NixOS installation
  6. /run/current-system/sw/share/autojump/autojump.zsh # NixOS installation
  7. /etc/profiles/per-user/$USER/share/autojump/autojump.zsh # Home Manager, NixOS with user-scoped packages
  8. /usr/share/autojump/autojump.zsh # Debian and Ubuntu package
  9. /etc/profile.d/autojump.zsh # manual installation
  10. /etc/profile.d/autojump.sh # Gentoo installation
  11. /usr/local/share/autojump/autojump.zsh # FreeBSD installation
  12. /usr/pkg/share/autojump/autojump.zsh # NetBSD installation
  13. /opt/local/etc/profile.d/autojump.sh # macOS with MacPorts
  14. /usr/local/etc/profile.d/autojump.sh # macOS with Homebrew (default)
  15. /opt/homebrew/etc/profile.d/autojump.sh # macOS with Homebrew (default on M1 macs)
  16. /opt/pkg/share/autojump/autojump.zsh # macOS with pkgsrc
  17. /etc/profiles/per-user/$USER/etc/profile.d/autojump.sh # macOS Nix, Home Manager and flakes
  18. )
  19. for file in $autojump_paths; do
  20. if [[ -f "$file" ]]; then
  21. source "$file"
  22. found=1
  23. break
  24. fi
  25. done
  26. # if no path found, try Homebrew
  27. if (( ! found && $+commands[brew] )); then
  28. file=$(brew --prefix)/etc/profile.d/autojump.sh
  29. if [[ -f "$file" ]]; then
  30. source "$file"
  31. found=1
  32. fi
  33. fi
  34. (( ! found )) && echo '[oh-my-zsh] autojump not found. Please install it first.'
  35. unset autojump_paths file found