plugins/autojump: use `_command_exists`

Addresses bash-it/bash-it#1632
pull/1938/head
John D Pell 2021-09-19 21:57:21 -07:00
parent 39d6488c6b
commit de58fdd73f
2 changed files with 9 additions and 5 deletions

View File

@ -77,6 +77,7 @@ completion/available/wpscan.completion.bash
# plugins
#
plugins/available/alias-completion.plugin.bash
plugins/available/autojump.plugin.bash
plugins/available/basher.plugin.bash
plugins/available/cmd-returned-notify.plugin.bash
plugins/available/docker-machine.plugin.bash

View File

@ -1,12 +1,15 @@
# shellcheck shell=bash
cite about-plugin
about-plugin 'Autojump configuration, see https://github.com/wting/autojump for more details'
# Only supports the Homebrew variant, Debian and Arch at the moment.
# Feel free to provide a PR to support other install locations
if _bash_it_homebrew_check && [[ -s "${BASH_IT_HOMEBREW_PREFIX}/etc/profile.d/autojump.sh" ]]; then
. "${BASH_IT_HOMEBREW_PREFIX}/etc/profile.d/autojump.sh"
elif command -v dpkg &>/dev/null && dpkg -s autojump &>/dev/null ; then
. "$(dpkg-query -S autojump.sh | cut -d' ' -f2)"
elif command -v pacman &>/dev/null && pacman -Q autojump &>/dev/null ; then
. "$(pacman -Ql autojump | grep autojump.sh | cut -d' ' -f2)"
source "${BASH_IT_HOMEBREW_PREFIX}/etc/profile.d/autojump.sh"
elif _command_exists dpkg && dpkg -s autojump &> /dev/null; then
# shellcheck disable=SC1090
source "$(dpkg-query -S autojump.sh | cut -d' ' -f2)"
elif _command_exists pacman && pacman -Q autojump &> /dev/null; then
# shellcheck disable=SC1090
source "$(pacman -Ql autojump | grep autojump.sh | cut -d' ' -f2)"
fi