bb64446ebf51ef9ab8c6cf9f2569a0900529861e

Author
Marc Cornellà <marc.cornella@live.com>
Committer
Marc Cornellà <marc.cornella@live.com>
Date

Message

Merge branch 'fix/autojump-plugin'

Fixes #7568
Closes #4542
Closes #5163
Closes #6868

Diff

 1diff --git a/plugins/autojump/autojump.plugin.zsh b/plugins/autojump/autojump.plugin.zsh
 2index c0af676317ac3a6e478e0428bbe2d6a4ce1df71d..13c1d00ed5f0f46d01b5250dfa001ddf6239567b 100644
 3--- a/plugins/autojump/autojump.plugin.zsh
 4+++ b/plugins/autojump/autojump.plugin.zsh
 5@@ -1,23 +1,39 @@
 6-if [ $commands[autojump] ]; then # check if autojump is installed
 7-  if [ -f $HOME/.autojump/etc/profile.d/autojump.zsh ]; then # manual user-local installation
 8-    . $HOME/.autojump/etc/profile.d/autojump.zsh
 9-  elif [ -f $HOME/.autojump/share/autojump/autojump.zsh ]; then # another manual user-local installation
10-    . $HOME/.autojump/share/autojump/autojump.zsh
11-  elif [ -f $HOME/.nix-profile/etc/profile.d/autojump.zsh ]; then # nix installation
12-    . $HOME/.nix-profile/etc/profile.d/autojump.zsh
13-  elif [ -f /run/current-system/sw/share/autojump/autojump.zsh ]; then # nixos installation
14-    . /run/current-system/sw/share/autojump/autojump.zsh
15-  elif [ -f /usr/share/autojump/autojump.zsh ]; then # debian and ubuntu package
16-    . /usr/share/autojump/autojump.zsh
17-  elif [ -f /etc/profile.d/autojump.zsh ]; then # manual installation
18-    . /etc/profile.d/autojump.zsh
19-  elif [ -f /etc/profile.d/autojump.sh ]; then # gentoo installation
20-    . /etc/profile.d/autojump.sh
21-  elif [ -f /usr/local/share/autojump/autojump.zsh ]; then # freebsd installation
22-    . /usr/local/share/autojump/autojump.zsh
23-  elif [ -f /opt/local/etc/profile.d/autojump.sh ]; then # mac os x with ports
24-    . /opt/local/etc/profile.d/autojump.sh
25-  elif [ $commands[brew] -a -f `brew --prefix`/etc/autojump.sh ]; then # mac os x with brew
26-    . `brew --prefix`/etc/autojump.sh
27+(( $+commands[autojump] )) || {
28+  echo '[oh-my-zsh] Please install autojump first (https://github.com/wting/autojump)'
29+  return
30+}
31+
32+declare -a autojump_paths
33+autojump_paths=(
34+  $HOME/.autojump/etc/profile.d/autojump.zsh         # manual installation
35+  $HOME/.autojump/share/autojump/autojump.zsh        # manual installation
36+  $HOME/.nix-profile/etc/profile.d/autojump.sh       # NixOS installation
37+  /run/current-system/sw/share/autojump/autojump.zsh # NixOS installation
38+  /usr/share/autojump/autojump.zsh                   # Debian and Ubuntu package
39+  /etc/profile.d/autojump.zsh                        # manual installation
40+  /etc/profile.d/autojump.sh                         # Gentoo installation
41+  /usr/local/share/autojump/autojump.zsh             # FreeBSD installation
42+  /opt/local/etc/profile.d/autojump.sh               # macOS with MacPorts
43+  /usr/local/etc/profile.d/autojump.sh               # macOS with Homebrew (default)
44+)
45+
46+for file in $autojump_paths; do
47+  if [[ -f "$file" ]]; then
48+    source "$file"
49+    found=1
50+    break
51+  fi
52+done
53+
54+# if no path found, try Homebrew
55+if (( ! found && $+commands[brew] )); then
56+  file=$(brew --prefix)/etc/profile.d/autojump.sh
57+  if [[ -f "$file" ]]; then
58+    source "$file"
59+    found=1
60   fi
61 fi
62+
63+(( ! found )) && echo '[oh-my-zsh] autojump script not found'
64+
65+unset autojump_paths file found