Skip to content

Commit

Permalink
fix: Completions working on zsh.
Browse files Browse the repository at this point in the history
  • Loading branch information
TechDufus committed Oct 4, 2024
1 parent f4e02c4 commit 7b7f112
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
19 changes: 13 additions & 6 deletions roles/zsh/files/zsh/dotfiles_completions.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,20 @@ DOTFILES_ROLES_DIR="$HOME/.dotfiles/roles"
# Function to handle tab completion
_complete_tags() {
local cur_word tags_list
cur_word="${COMP_WORDS[COMP_CWORD]}"
tags_list=$(find "$DOTFILES_ROLES_DIR" -maxdepth 1 -type d -printf "%f\n")
cur_word="${words[CURRENT]}"

COMPREPLY=($(compgen -W "${tags_list}" -- "${cur_word}"))
# Find directories in the specified directory and store them in tags_list
tags_list=($(find "$DOTFILES_ROLES_DIR" -maxdepth 1 -type d -exec basename {} \;))

# Add -t and --skip-tags as options
if [[ "${cur_word}" == -* ]]; then
compadd -W "-t --skip-tags"
else
# Add directories as completion options
compadd "${tags_list[@]}"
fi
}

# Register the completion function for the -t flag
# This isn't perfect, as -t and --skip-tags show up in the completion list
complete -F _complete_tags -o nospace -W "-t --skip-tags" dotfiles
# Register the completion function with compdef
compdef _complete_tags dotfiles

6 changes: 1 addition & 5 deletions roles/zsh/files/zsh/taskfile_completions.zsh
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
#!/usr/bin/env zsh

if [ -x "$(command -v task)" ]; then
if [ -d "${HOME}/.task" ]; then
if [ -d "${HOME}/.task/completions" ]; then
source "${HOME}/.task/completions/task.bash"
fi
fi
eval "$(task --completion zsh)"
fi

0 comments on commit 7b7f112

Please sign in to comment.