Add zsh-completions
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`.
This commit is contained in:
parent
8526bdb4e3
commit
8997d9cae0
@ -29,10 +29,13 @@
|
|||||||
- https://github.com/zsh-users/zsh-autosuggestions.git
|
- https://github.com/zsh-users/zsh-autosuggestions.git
|
||||||
- https://github.com/zsh-users/zsh-history-substring-search.git
|
- https://github.com/zsh-users/zsh-history-substring-search.git
|
||||||
- https://github.com/zsh-users/zsh-syntax-highlighting.git
|
- https://github.com/zsh-users/zsh-syntax-highlighting.git
|
||||||
|
- https://github.com/zsh-users/zsh-completions.git
|
||||||
- https://github.com/junegunn/fzf.git
|
- https://github.com/junegunn/fzf.git
|
||||||
- command:
|
- command:
|
||||||
- fzf/install --bin
|
- fzf/install --bin
|
||||||
- symlink:
|
- symlink:
|
||||||
- {src: fzf/bin/fzf, dst: ~/.local/bin/fzf}
|
- {src: fzf/bin/fzf, dst: ~/.local/bin/fzf}
|
||||||
- {src: fzf/bin/fzf-tmux, dst: ~/.local/bin/fzf-tmux}
|
- {src: fzf/bin/fzf-tmux, dst: ~/.local/bin/fzf-tmux}
|
||||||
|
- command:
|
||||||
|
- zsh update-completion-links.zsh
|
||||||
- message: zsh will be the default prompt after next login
|
- message: zsh will be the default prompt after next login
|
||||||
|
19
update-completion-links.zsh
Executable file
19
update-completion-links.zsh
Executable file
@ -0,0 +1,19 @@
|
|||||||
|
#!/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
|
Loading…
x
Reference in New Issue
Block a user