From 481a649f90008e8c45e650fb7127c9c7df0028e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20G=C3=BCntner?= Date: Wed, 15 Jun 2016 12:27:25 +0200 Subject: [PATCH 1/7] NixOS: Use autojump.sh to figure out location of autojump.zsh MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maximilian Güntner --- plugins/autojump/autojump.plugin.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/autojump/autojump.plugin.zsh b/plugins/autojump/autojump.plugin.zsh index c0af67631..3946106b0 100644 --- a/plugins/autojump/autojump.plugin.zsh +++ b/plugins/autojump/autojump.plugin.zsh @@ -3,8 +3,8 @@ if [ $commands[autojump] ]; then # check if autojump is installed . $HOME/.autojump/etc/profile.d/autojump.zsh elif [ -f $HOME/.autojump/share/autojump/autojump.zsh ]; then # another manual user-local installation . $HOME/.autojump/share/autojump/autojump.zsh - elif [ -f $HOME/.nix-profile/etc/profile.d/autojump.zsh ]; then # nix installation - . $HOME/.nix-profile/etc/profile.d/autojump.zsh + elif [ -f $HOME/.nix-profile/etc/profile.d/autojump.sh ]; then # nix installation + . $HOME/.nix-profile/etc/profile.d/autojump.sh elif [ -f /run/current-system/sw/share/autojump/autojump.zsh ]; then # nixos installation . /run/current-system/sw/share/autojump/autojump.zsh elif [ -f /usr/share/autojump/autojump.zsh ]; then # debian and ubuntu package From 5e9ee67f2b7e53c9e4bb5a0220276a97a22ca0e6 Mon Sep 17 00:00:00 2001 From: Alex Parker Date: Fri, 23 Oct 2015 13:00:12 -0600 Subject: [PATCH 2/7] Update autojump.plugin.zsh I was adding autojump on a new machine and annoyingly forgot that autojump was to be installed on its own. This may be helpful. --- plugins/autojump/autojump.plugin.zsh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/autojump/autojump.plugin.zsh b/plugins/autojump/autojump.plugin.zsh index 3946106b0..c7da73b23 100644 --- a/plugins/autojump/autojump.plugin.zsh +++ b/plugins/autojump/autojump.plugin.zsh @@ -20,4 +20,6 @@ if [ $commands[autojump] ]; then # check if autojump is installed elif [ $commands[brew] -a -f `brew --prefix`/etc/autojump.sh ]; then # mac os x with brew . `brew --prefix`/etc/autojump.sh fi +else + echo 'Please install autojump to enable the plugin (https://github.com/wting/autojump)' fi From ab63d240dadc964eee4fcdf14c0c46689f879ac8 Mon Sep 17 00:00:00 2001 From: rl1k <38787215+rl1k@users.noreply.github.com> Date: Mon, 28 May 2018 21:57:49 +0200 Subject: [PATCH 3/7] Use source instead of dot to load autojump --- plugins/autojump/autojump.plugin.zsh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/plugins/autojump/autojump.plugin.zsh b/plugins/autojump/autojump.plugin.zsh index c7da73b23..17f01a9cf 100644 --- a/plugins/autojump/autojump.plugin.zsh +++ b/plugins/autojump/autojump.plugin.zsh @@ -1,24 +1,24 @@ if [ $commands[autojump] ]; then # check if autojump is installed if [ -f $HOME/.autojump/etc/profile.d/autojump.zsh ]; then # manual user-local installation - . $HOME/.autojump/etc/profile.d/autojump.zsh + source $HOME/.autojump/etc/profile.d/autojump.zsh elif [ -f $HOME/.autojump/share/autojump/autojump.zsh ]; then # another manual user-local installation - . $HOME/.autojump/share/autojump/autojump.zsh + source $HOME/.autojump/share/autojump/autojump.zsh elif [ -f $HOME/.nix-profile/etc/profile.d/autojump.sh ]; then # nix installation - . $HOME/.nix-profile/etc/profile.d/autojump.sh + source $HOME/.nix-profile/etc/profile.d/autojump.sh elif [ -f /run/current-system/sw/share/autojump/autojump.zsh ]; then # nixos installation - . /run/current-system/sw/share/autojump/autojump.zsh + source /run/current-system/sw/share/autojump/autojump.zsh elif [ -f /usr/share/autojump/autojump.zsh ]; then # debian and ubuntu package - . /usr/share/autojump/autojump.zsh + source /usr/share/autojump/autojump.zsh elif [ -f /etc/profile.d/autojump.zsh ]; then # manual installation - . /etc/profile.d/autojump.zsh + source /etc/profile.d/autojump.zsh elif [ -f /etc/profile.d/autojump.sh ]; then # gentoo installation - . /etc/profile.d/autojump.sh + source /etc/profile.d/autojump.sh elif [ -f /usr/local/share/autojump/autojump.zsh ]; then # freebsd installation - . /usr/local/share/autojump/autojump.zsh + source /usr/local/share/autojump/autojump.zsh elif [ -f /opt/local/etc/profile.d/autojump.sh ]; then # mac os x with ports - . /opt/local/etc/profile.d/autojump.sh + source /opt/local/etc/profile.d/autojump.sh elif [ $commands[brew] -a -f `brew --prefix`/etc/autojump.sh ]; then # mac os x with brew - . `brew --prefix`/etc/autojump.sh + source `brew --prefix`/etc/autojump.sh fi else echo 'Please install autojump to enable the plugin (https://github.com/wting/autojump)' From 4ef29c9f1883acecb638a64ddb1eff8618312cdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Tue, 9 Apr 2019 19:21:05 +0200 Subject: [PATCH 4/7] Fix homebrew path location --- plugins/autojump/autojump.plugin.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/autojump/autojump.plugin.zsh b/plugins/autojump/autojump.plugin.zsh index 17f01a9cf..3434fb37b 100644 --- a/plugins/autojump/autojump.plugin.zsh +++ b/plugins/autojump/autojump.plugin.zsh @@ -17,8 +17,8 @@ if [ $commands[autojump] ]; then # check if autojump is installed source /usr/local/share/autojump/autojump.zsh elif [ -f /opt/local/etc/profile.d/autojump.sh ]; then # mac os x with ports source /opt/local/etc/profile.d/autojump.sh - elif [ $commands[brew] -a -f `brew --prefix`/etc/autojump.sh ]; then # mac os x with brew - source `brew --prefix`/etc/autojump.sh + elif [ $commands[brew] -a -f $(brew --prefix)/etc/profile.d/autojump.sh ]; then # mac os x with brew + source $(brew --prefix)/etc/profile.d/autojump.sh fi else echo 'Please install autojump to enable the plugin (https://github.com/wting/autojump)' From 5a424fc12fc62512400887236ef20ea2268bba94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Tue, 9 Apr 2019 19:22:51 +0200 Subject: [PATCH 5/7] Check first default Homebrew prefix --- plugins/autojump/autojump.plugin.zsh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/autojump/autojump.plugin.zsh b/plugins/autojump/autojump.plugin.zsh index 3434fb37b..81664e1ae 100644 --- a/plugins/autojump/autojump.plugin.zsh +++ b/plugins/autojump/autojump.plugin.zsh @@ -17,6 +17,8 @@ if [ $commands[autojump] ]; then # check if autojump is installed source /usr/local/share/autojump/autojump.zsh elif [ -f /opt/local/etc/profile.d/autojump.sh ]; then # mac os x with ports source /opt/local/etc/profile.d/autojump.sh + elif [ -f /usr/local/etc/profile.d/autojump.sh ]; then # mac os x with brew + source /usr/local/etc/profile.d/autojump.sh elif [ $commands[brew] -a -f $(brew --prefix)/etc/profile.d/autojump.sh ]; then # mac os x with brew source $(brew --prefix)/etc/profile.d/autojump.sh fi From fd105b6e528127c2c6f5cf59d0e32d761c206971 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Tue, 9 Apr 2019 19:38:34 +0200 Subject: [PATCH 6/7] Refactor and clean up autojump plugin --- plugins/autojump/autojump.plugin.zsh | 57 ++++++++++++++++------------ 1 file changed, 32 insertions(+), 25 deletions(-) diff --git a/plugins/autojump/autojump.plugin.zsh b/plugins/autojump/autojump.plugin.zsh index 81664e1ae..7ccd09303 100644 --- a/plugins/autojump/autojump.plugin.zsh +++ b/plugins/autojump/autojump.plugin.zsh @@ -1,27 +1,34 @@ -if [ $commands[autojump] ]; then # check if autojump is installed - if [ -f $HOME/.autojump/etc/profile.d/autojump.zsh ]; then # manual user-local installation - source $HOME/.autojump/etc/profile.d/autojump.zsh - elif [ -f $HOME/.autojump/share/autojump/autojump.zsh ]; then # another manual user-local installation - source $HOME/.autojump/share/autojump/autojump.zsh - elif [ -f $HOME/.nix-profile/etc/profile.d/autojump.sh ]; then # nix installation - source $HOME/.nix-profile/etc/profile.d/autojump.sh - elif [ -f /run/current-system/sw/share/autojump/autojump.zsh ]; then # nixos installation - source /run/current-system/sw/share/autojump/autojump.zsh - elif [ -f /usr/share/autojump/autojump.zsh ]; then # debian and ubuntu package - source /usr/share/autojump/autojump.zsh - elif [ -f /etc/profile.d/autojump.zsh ]; then # manual installation - source /etc/profile.d/autojump.zsh - elif [ -f /etc/profile.d/autojump.sh ]; then # gentoo installation - source /etc/profile.d/autojump.sh - elif [ -f /usr/local/share/autojump/autojump.zsh ]; then # freebsd installation - source /usr/local/share/autojump/autojump.zsh - elif [ -f /opt/local/etc/profile.d/autojump.sh ]; then # mac os x with ports - source /opt/local/etc/profile.d/autojump.sh - elif [ -f /usr/local/etc/profile.d/autojump.sh ]; then # mac os x with brew - source /usr/local/etc/profile.d/autojump.sh - elif [ $commands[brew] -a -f $(brew --prefix)/etc/profile.d/autojump.sh ]; then # mac os x with brew - source $(brew --prefix)/etc/profile.d/autojump.sh +(( $+commands[autojump] )) || { + echo '[oh-my-zsh] Please install autojump first (https://github.com/wting/autojump)' + return +} + +declare -a autojump_paths +autojump_paths=( + $HOME/.autojump/etc/profile.d/autojump.zsh # manual installation + $HOME/.autojump/share/autojump/autojump.zsh # manual installation + $HOME/.nix-profile/etc/profile.d/autojump.sh # NixOS installation + /run/current-system/sw/share/autojump/autojump.zsh # NixOS installation + /usr/share/autojump/autojump.zsh # Debian and Ubuntu package + /etc/profile.d/autojump.zsh # manual installation + /etc/profile.d/autojump.sh # Gentoo installation + /usr/local/share/autojump/autojump.zsh # FreeBSD installation + /opt/local/etc/profile.d/autojump.sh # macOS with MacPorts + /usr/local/etc/profile.d/autojump.sh # macOS with Homebrew (default) +) + +for file in $autojump_paths; do + if [[ -f "$file" ]]; then + source "$file" + found=1 + break fi -else - echo 'Please install autojump to enable the plugin (https://github.com/wting/autojump)' +done + +# if no path found, try Homebrew +if (( ! found && $+commands[brew] )); then + file=$(brew --prefix)/etc/profile.d/autojump.sh + [[ -f "$file" ]] && source "$file" fi + +unset autojump_paths file found From b4c06f2b50e499fbd6b827c1b287276d9cacd3e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Cornell=C3=A0?= Date: Tue, 9 Apr 2019 19:41:59 +0200 Subject: [PATCH 7/7] Complain when no autojump script was found --- plugins/autojump/autojump.plugin.zsh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plugins/autojump/autojump.plugin.zsh b/plugins/autojump/autojump.plugin.zsh index 7ccd09303..13c1d00ed 100644 --- a/plugins/autojump/autojump.plugin.zsh +++ b/plugins/autojump/autojump.plugin.zsh @@ -28,7 +28,12 @@ done # if no path found, try Homebrew if (( ! found && $+commands[brew] )); then file=$(brew --prefix)/etc/profile.d/autojump.sh - [[ -f "$file" ]] && source "$file" + if [[ -f "$file" ]]; then + source "$file" + found=1 + fi fi +(( ! found )) && echo '[oh-my-zsh] autojump script not found' + unset autojump_paths file found