Add zsh completion path, completions plugin

Added `$XDG_CONFIG_HOME/zsh/completions` to fpath for zsh to source
completions from. Any stow modules creating scripts and functions which
should be auto-completable can add their own completion scripts to this
directory for zsh to automatically pick them up.

Add zsh-users/zsh-completions plugin to provide completions for a wide
array of applications (e.g. glances, nvm).
This commit is contained in:
Marty Oehme 2020-02-02 23:32:37 +01:00
parent 1684aaa50f
commit fbc1c44652
3 changed files with 18 additions and 12 deletions

View file

@ -18,3 +18,8 @@ if [ -d "$XDG_CONFIG_HOME/zsh/env.d" ]; then
done done
unset _env unset _env
fi fi
# add XDG_CONFIG_HOME/zsh/completions to fpath
# zsh uses it to look for completions; throw all
# completions in these dotfiles in there
fpath=("$XDG_CONFIG_HOME/zsh/completions" $fpath)

View file

@ -4,6 +4,16 @@
CONFDIR="${XDG_CONFIG_HOME:-$HOME/.config}" CONFDIR="${XDG_CONFIG_HOME:-$HOME/.config}"
ZSHCONFDIR="$CONFDIR/zsh" ZSHCONFDIR="$CONFDIR/zsh"
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.config/zsh/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block, everything else may go below.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
# load all plugins
[ -f "$ZSHCONFDIR/plugins.zsh" ] && source "$ZSHCONFDIR/plugins.zsh"
# Set completion style # Set completion style
# The following lines were added by compinstall # The following lines were added by compinstall
zstyle ':completion:*' completer _complete _ignored _approximate zstyle ':completion:*' completer _complete _ignored _approximate
@ -16,17 +26,6 @@ zstyle :compinstall filename "$ZSHCONFDIR/.zshrc"
autoload -Uz compinit zmv autoload -Uz compinit zmv
compinit compinit
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.config/zsh/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block, everything else may go below.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
# load all plugins
[ -f "$ZSHCONFDIR/plugins.zsh" ] && source "$ZSHCONFDIR/plugins.zsh"
# shellcheck source=alias # shellcheck source=alias
[ -f "$CONFDIR/sh/alias" ] && source "$CONFDIR/sh/alias" [ -f "$CONFDIR/sh/alias" ] && source "$CONFDIR/sh/alias"
# load additional aliases # load additional aliases

View file

@ -58,6 +58,8 @@ load_plugins() {
zgen oh-my-zsh plugins/colored-man-pages zgen oh-my-zsh plugins/colored-man-pages
zgen load zsh-users/zsh-completions
# Load me last # Load me last
GENCOMPL_FPATH=${XDG_CONFIG_HOME:-"$HOME/.config/zsh"}/complete GENCOMPL_FPATH=${XDG_CONFIG_HOME:-"$HOME/.config/zsh"}/complete