Skip to content

Commit

Permalink
Make zsh completion work on $fpath.
Browse files Browse the repository at this point in the history
This allows the file to be placed, e.g., in a system-wide
`site-functions` directory and just work automatically.
  • Loading branch information
QuLogic committed Feb 10, 2019
1 parent a86f829 commit 70ee518
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
14 changes: 8 additions & 6 deletions shell/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,17 @@ adding the following snippet:

### Zsh

Load up the completion by placing the `exercism_completion.zsh` somewhere on
your `$fpath` as `_exercism`. For example:

mkdir -p ~/.config/exercism
mv ../shell/exercism_completion.zsh ~/.config/exercism/exercism_completion.zsh
mv ../shell/exercism_completion.zsh ~/.config/exercism/_exercism

Load up the completion in your `.zshrc`, `.zsh_profile` or `.profile` by adding
the following snippet
and then add the directory to your `$fpath` in your `.zshrc`, `.zsh_profile` or
`.profile` before running `compinit`:

if [ -f ~/.config/exercism/exercism_completion.zsh ]; then
source ~/.config/exercism/exercism_completion.zsh
fi
export fpath=(~/.config/exercism $fpath)
autoload -U compinit && compinit


#### Oh my Zsh
Expand Down
4 changes: 3 additions & 1 deletion shell/exercism_completion.zsh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#compdef exercism

_exercism() {
local curcontext="$curcontext" state line
typeset -A opt_args
Expand Down Expand Up @@ -33,4 +35,4 @@ _exercism() {
esac
}

compdef '_exercism' exercism
_exercism "$@"

0 comments on commit 70ee518

Please sign in to comment.