diff --git a/zsh/05-vars.zsh b/zsh/03-vars.zsh similarity index 57% rename from zsh/05-vars.zsh rename to zsh/03-vars.zsh index 396d2b1..b98a619 100644 --- a/zsh/05-vars.zsh +++ b/zsh/03-vars.zsh @@ -4,6 +4,15 @@ OS=`uname` OS_RELEASE=`uname -r` +# Distro detection. +LSBRELEASE=$(which lsb_release) +if [ $? -eq 0 ]; then + DISTRO=`lsb_release -i -s` +else + # BSDs OS and macOS can be detected via uname. + DISTRO=${OS} +fi + # Variable forcers. # If DEBUG isn't defined - force it to be 0. diff --git a/zsh/03-apps.zsh b/zsh/04-apps.zsh similarity index 100% rename from zsh/03-apps.zsh rename to zsh/04-apps.zsh diff --git a/zsh/05-plugins.zsh b/zsh/05-plugins.zsh new file mode 100644 index 0000000..c8402f0 --- /dev/null +++ b/zsh/05-plugins.zsh @@ -0,0 +1,13 @@ +# Load enabled plugins. +for plugin in "${ENABLED_PLUGINS[@]}"; do + if [ ! -f "${CONFIG_PATH}/zsh/plugins/${plugin}.plugin.zsh" ]; then + error 0 "Plugin '${plugin}' doesn't exist" + else + source "${CONFIG_PATH}/zsh/plugins/${plugin}.plugin.zsh" + # chpwd injecting. + chpwd_injector=`declare -f ${plugin}_chpwd` + if [ $chpwd_injector ]; then + ${plugin}_chpwd + fi + fi +done diff --git a/zsh/defaults/03-plugins.conf b/zsh/defaults/03-plugins.conf new file mode 100644 index 0000000..5e82ce6 --- /dev/null +++ b/zsh/defaults/03-plugins.conf @@ -0,0 +1,2 @@ +# List of plugins to enable. +ENABLED_PLUGINS=("autosuggestions") diff --git a/zsh/exports/01-path.zsh b/zsh/exports/01-path.zsh index 86c1535..5d732f7 100644 --- a/zsh/exports/01-path.zsh +++ b/zsh/exports/01-path.zsh @@ -1,2 +1,2 @@ # This is default PATHs. -export PATH="/bin:/usr/lib:/usr/lib/colorgcc/bin:/usr/sbin:/sbin:$PATH" \ No newline at end of file +export PATH="/usr/lib/colorgcc/bin:/usr/sbin:/sbin:$PATH" diff --git a/zsh/plugins/autosuggestions.plugin.zsh b/zsh/plugins/autosuggestions.plugin.zsh new file mode 100644 index 0000000..8467501 --- /dev/null +++ b/zsh/plugins/autosuggestions.plugin.zsh @@ -0,0 +1,13 @@ +AUTOSUGGESTIONS_PATH="" + +if [ "${DISTRO}" = "Arch" ]; then AUTOSUGGESTIONS_PATH="/usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh"; fi +if [ "${DISTRO}" = "Debian" ]; then AUTOSUGGESTIONS_PATH="/usr/share/zsh-autosuggestions/zsh-autosuggestions.zsh"; fi +if [ "${DISTRO}" = "Darwin" ]; then AUTOSUGGESTIONS_PATH="/usr/local/share/zsh-autosuggestions/zsh-autosuggestions.zsh"; fi +if [ "${DISTRO}" = "VoidLinux" ]; then AUTOSUGGESTIONS_PATH="/usr/share/zsh/plugins/zsh-autosuggestions.zsh"; fi + +if [ -f "${AUTOSUGGESTIONS_PATH}" ]; then + source "${AUTOSUGGESTIONS_PATH}" + export PLUGIN_ZSH_AUTOSUGGESTIONS_LOADED=1 +else + echo "Autosuggestions plugin enabled but not installed. Please install zsh-autosuggestions as per https://github.com/zsh-users/zsh-autosuggestions/blob/master/INSTALL.md" +fi