Zsh: Refactor system package plugin detection
This commit is contained in:
parent
eb4973ae60
commit
12256f9137
|
@ -6,8 +6,8 @@ function()
|
|||
setopt LOCAL_OPTIONS EXTENDED_GLOB
|
||||
|
||||
local -a _my_plugins=(
|
||||
mafredri/zsh-async
|
||||
zsh-users/zsh-completions
|
||||
mafredri/zsh-async
|
||||
# Must come before autosuggestions and syntax-highlighting
|
||||
Aloxaf/fzf-tab
|
||||
zsh-users/zsh-autosuggestions
|
||||
|
@ -27,34 +27,43 @@ if [[ "$HOST" == "steuerbeamter" ]]; then
|
|||
fi
|
||||
|
||||
local -a _my_plugins_dist
|
||||
# Don't load plugins that are installed by the package manager
|
||||
# Don't fetch plugins that are installed by the package manager
|
||||
if [[ -f /etc/gentoo-release ]]; then
|
||||
local _gentoo_plugin_dir="/usr/share/zsh/site-functions"
|
||||
if [[ -d /var/db/pkg/app-shells/zsh-async-*(#qN) ]]; then
|
||||
_my_plugins=(${_my_plugins:#mafredri/zsh-async})
|
||||
_my_plugins_dist+=(${_gentoo_plugin_dir}/async.zsh)
|
||||
fi
|
||||
if [[ -d /var/db/pkg/app-shells/zsh-completions-*(#qN) ]]; then
|
||||
_my_plugins=(${_my_plugins:#zsh-users/zsh-completions})
|
||||
fi
|
||||
if [[ -d /var/db/pkg/app-shells/fzf-tab-*(#qN) ]]; then
|
||||
_my_plugins=(${_my_plugins:#Aloxaf/fzf-tab})
|
||||
_my_plugins_dist+=(${_gentoo_plugin_dir}/fzf-tab.zsh)
|
||||
fi
|
||||
if [[ -d /var/db/pkg/app-shells/zsh-autosuggestions-*(#qN) ]]; then
|
||||
_my_plugins=(${_my_plugins:#zsh-users/zsh-autosuggestions})
|
||||
_my_plugins_dist+=(${_gentoo_plugin_dir}/zsh-autosuggestions.zsh)
|
||||
fi
|
||||
if [[ -d /var/db/pkg/app-shells/zsh-syntax-highlighting-*(#qN) ]]; then
|
||||
_my_plugins=(${_my_plugins:#zsh-users/zsh-syntax-highlighting})
|
||||
_my_plugins_dist+=(${_gentoo_plugin_dir}/zsh-syntax-highlighting.zsh)
|
||||
fi
|
||||
if [[ -d /var/db/pkg/app-shells/zsh-history-substring-search-*(#qN) ]]; then
|
||||
_my_plugins=(${_my_plugins:#zsh-users/zsh-history-substring-search})
|
||||
_my_plugins_dist+=(${_gentoo_plugin_dir}/zsh-history-substring-search.zsh)
|
||||
fi
|
||||
|
||||
function _plugin_installed()
|
||||
{
|
||||
local catpkg=${1}
|
||||
local uri=${2}
|
||||
local filename=${3}
|
||||
|
||||
if [[ -d /var/db/pkg/${catpkg}-*(#qN) ]]; then
|
||||
_my_plugins=(${_my_plugins:#${uri}})
|
||||
_my_plugins_dist+=(/usr/share/zsh/site-functions/${filename})
|
||||
fi
|
||||
}
|
||||
_plugin_installed app-shells/zsh-async \
|
||||
mafredri/zsh-async \
|
||||
async.zsh
|
||||
_plugin_installed app-shells/fzf-tab \
|
||||
Aloxaf/fzf-tab \
|
||||
fzf-tab.zsh
|
||||
_plugin_installed app-shells/zsh-autosuggestions \
|
||||
zsh-users/zsh-autosuggestions \
|
||||
zsh-autosuggestions.zsh
|
||||
_plugin_installed app-shells/zsh-syntax-highlighting \
|
||||
zsh-users/zsh-syntax-highlighting \
|
||||
zsh-syntax-highlighting.zsh
|
||||
_plugin_installed app-shells/zsh-history-substring-search \
|
||||
zsh-users/zsh-history-substring-search \
|
||||
zsh-history-substring-search.zsh
|
||||
unfunction _plugin_installed
|
||||
fi
|
||||
if [[ -n ${_my_plugins_dist} ]]; then
|
||||
export ZSH_PLUGIN_DIST="${_my_plugins_dist}" # Arrays can not be exported
|
||||
fi
|
||||
export ZSH_PLUGIN_DIST="${_my_plugins_dist}" # Arrays can not be exported
|
||||
|
||||
[[ -z ${_my_plugins} ]] && return
|
||||
# If there are plugins not handled by the package manager, use antibody
|
||||
|
|
Loading…
Reference in New Issue
Block a user