Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 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

mkdir -p ~/.config/exercism
mv ../shell/exercism_completion.zsh ~/.config/exercism/exercism_completion.zsh
Load up the completion by placing the `exercism_completion.zsh` somewhere on
your `$fpath` as `_exercism`. For example:

Load up the completion in your `.zshrc`, `.zsh_profile` or `.profile` by adding
the following snippet
mkdir -p ~/.zsh/functions
mv ../shell/exercism_completion.zsh ~/.zsh/functions/_exercism

if [ -f ~/.config/exercism/exercism_completion.zsh ]; then
source ~/.config/exercism/exercism_completion.zsh
fi
and then add the directory to your `$fpath` in your `.zshrc`, `.zsh_profile` or
`.profile` before running `compinit`:

export fpath=(~/.zsh/functions $fpath)
autoload -U compinit && compinit


#### Oh my Zsh
Expand All @@ -37,4 +39,3 @@ If you are using the popular [oh-my-zsh](https://github.com/robbyrussell/oh-my-z
Completions must go in the user defined `$fish_complete_path`. By default, this is `~/.config/fish/completions`

mv ../shell/exercism.fish ~/.config/fish/exercism.fish

62 changes: 30 additions & 32 deletions shell/exercism_completion.zsh
Original file line number Diff line number Diff line change
@@ -1,36 +1,34 @@
_exercism() {
local curcontext="$curcontext" state line
typeset -A opt_args
#compdef exercism

local -a options
options=(configure:"Writes config values to a JSON file."
download:"Downloads and saves a specified submission into the local system"
open:"Opens a browser to exercism.io for the specified submission."
submit:"Submits a new iteration to a problem on exercism.io."
troubleshoot:"Outputs useful debug information."
upgrade:"Upgrades to the latest available version."
version:"Outputs version information."
workspace:"Outputs the root directory for Exercism exercises."
help:"Shows a list of commands or help for one command")
local curcontext="$curcontext" state line
typeset -A opt_args

_arguments -s -S \
{-h,--help}"[show help]" \
{-t,--timeout}"[override default HTTP timeout]" \
{-v,--verbose}"[turn on verbose logging]" \
'(-): :->command' \
'(-)*:: :->option-or-argument' \
&& return 0;
local -a options
options=(configure:"Writes config values to a JSON file."
download:"Downloads and saves a specified submission into the local system"
open:"Opens a browser to exercism.io for the specified submission."
submit:"Submits a new iteration to a problem on exercism.io."
troubleshoot:"Outputs useful debug information."
upgrade:"Upgrades to the latest available version."
version:"Outputs version information."
workspace:"Outputs the root directory for Exercism exercises."
help:"Shows a list of commands or help for one command")

case $state in
(command)
_describe 'commands' options ;;
(option-or-argument)
case $words[1] in
s*)
_files
;;
esac
esac
}
_arguments -s -S \
{-h,--help}"[show help]" \
{-t,--timeout}"[override default HTTP timeout]" \
{-v,--verbose}"[turn on verbose logging]" \
'(-): :->command' \
'(-)*:: :->option-or-argument' \
&& return 0;

compdef '_exercism' exercism
case $state in
(command)
_describe 'commands' options ;;
(option-or-argument)
case $words[1] in
s*)
_files
;;
esac
esac