ZSH Autosuggestions plugin.

This commit is contained in:
Stanislav Nikitin 2021-04-03 17:01:19 +05:00
parent 4218c6b8b6
commit 858db76ad6
Signed by: pztrn
GPG Key ID: 1E944A0F0568B550
6 changed files with 38 additions and 1 deletions

View File

@ -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.

13
zsh/05-plugins.zsh Normal file
View File

@ -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

View File

@ -0,0 +1,2 @@
# List of plugins to enable.
ENABLED_PLUGINS=("autosuggestions")

View File

@ -1,2 +1,2 @@
# This is default PATHs.
export PATH="/bin:/usr/lib:/usr/lib/colorgcc/bin:/usr/sbin:/sbin:$PATH"
export PATH="/usr/lib/colorgcc/bin:/usr/sbin:/sbin:$PATH"

View File

@ -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