Skip to content

Commit

Permalink
completions: zsh: refactor completion of exercise slugs
Browse files Browse the repository at this point in the history
  • Loading branch information
ee7 committed Aug 13, 2022
1 parent b43cd5a commit 833522b
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions completions/configlet.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,16 @@ _configlet() {
curcontext="${curcontext%:*:*}:configlet-command-$line[1]:"

_configlet_complete_any_exercise_slug() {
local -a cmd slugs slug_paths
slug_paths=(./exercises/concept/*(/))
slugs=( ${${slug_paths#./exercises/concept/}%-*-*} )
slug_paths=(./exercises/practice/*(/))
slugs+=( ${${slug_paths#./exercises/practice/}%-*-*} )
local -a slugs slug_paths
slug_paths=( ./exercises/{concept,practice}/*(/) )
slugs=( "${slug_paths[@]##*/}" )
compadd "$@" -a slugs
}

_configlet_complete_practice_exercise_slug() {
local -a cmd slugs slug_paths
slug_paths=(./exercises/practice/*(/))
slugs=( ${${slug_paths#./exercises/practice/}%-*-*} )
local -a slugs slug_paths
slug_paths=( ./exercises/practice/*(/) )
slugs=( "${slug_paths[@]##*/}" )
compadd "$@" -a slugs
}

Expand Down

0 comments on commit 833522b

Please sign in to comment.