The [zsh-completions](https://github.com/zsh-users/zsh-completions) repo contains completions for various commands but not all of these are useful so the `update-completion-links.zsh` script inspects the `PATH` to determine which of the completions should be symlinked to `~/.local/share/zsh/site-functions` which resides on the `fpath`.
20 lines
653 B
Bash
Executable File
20 lines
653 B
Bash
Executable File
#!/usr/bin/env zsh
|
|
|
|
# Check if third party completions are present.
|
|
local zsh_completions=~/.config/zsh/zsh-completions
|
|
[ ! -d $zsh_completions ] && return 0
|
|
|
|
# Loop over all completions.
|
|
for completion in $zsh_completions/src/_*; do
|
|
local name=`basename $completion`
|
|
local symlink=~/.local/share/zsh/site-functions/$name
|
|
# Remove existing completion file if it exists.
|
|
[ -f $symlink ] && rm $symlink
|
|
# Check if the command exists on the PATH.
|
|
if which ${name:1} &> /dev/null; then
|
|
# Symlink the completion for the existing command.
|
|
[ `uname` = Darwin ] && \
|
|
ln -s $completion $symlink || ln -sr $completion $symlink
|
|
fi
|
|
done
|