diff --git a/list-commands-with-available-completions.zsh b/list-commands-with-available-completions.zsh new file mode 100755 index 0000000..23a7111 --- /dev/null +++ b/list-commands-with-available-completions.zsh @@ -0,0 +1,22 @@ +#!/usr/bin/env zsh + +# Loop over available completions and add existing commands to array. +local -a completions +completions=(~/.config/zsh/zsh-completions/src/*) +local -a command_list +for completion in $completions; do + local filename=$(basename $completion) + local name=${filename:1} + if command -v $name &> /dev/null; then + command_list+=($name) + fi +done + +# Print JSON array of commands Ansible can consume. +echo '[' +local length=${#command_list[@]} +for (( i = 1; i < $length; i++ )); do + echo " \"${command_list[$i]}\"," +done +echo " \"${command_list[-1]}\"" +echo ']' diff --git a/update-completion-links.zsh b/update-completion-links.zsh deleted file mode 100755 index 12a6102..0000000 --- a/update-completion-links.zsh +++ /dev/null @@ -1,19 +0,0 @@ -#!/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 command -v ${name:1} &> /dev/null; then - # Symlink the completion for the existing command. - [ `uname` = Darwin ] && \ - ln -s $completion $symlink || ln -sr $completion $symlink - fi -done