Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
_mix zsh completion
#compdef mix
# Elixir mix zsh completion
local -a _1st_arguments
'archive:Archive this project into a .ez file'
' this project into a .ez file'
'archive.install:Install an archive locally'
'archive.uninstall:Uninstall archives'
'clean:Clean generated application files'
'compile:Compile source files'
'deps:List dependencies and their status'
"deps.clean:Remove dependencies' files"
'deps.compile:Compile dependencies'
'deps.get:Get all out of date dependencies'
'deps.unlock:Unlock the given dependencies'
'deps.update:Update dependencies'
'do:Executes the commands separated by comma'
'ecto.create:Create the storage for the repo'
'ecto.drop:Drop the storage for the repo'
'ecto.gen.migration:Generate a new migration for the repo'
'ecto.gen.repo:Generate a new repository'
'ecto.migrate:Run migrations up on a repo'
'ecto.rollback:Rollback migrations from a repo'
'escriptize:Generates an escript for the project'
'help:Print help information for tasks'
'hex:Print hex help information'
'hex.config:Read or update hex config'
' docs for package'
' hex information'
'hex.key:Hex API key tasks'
'hex.owner:Hex package ownership tasks'
'hex.publish:Publish a new package version'
' for package names'
'hex.user:Hex user tasks'
'local:List local tasks'
'local.install:Install a task or an archive locally'
'local.rebar:Install rebar locally'
'local.uninstall:Uninstall local tasks or archives'
'local.hex:Install Hex locally'
'new:Creates a new Elixir project'
'phoenix.gen.resource:Generates resource files'
' a new Phoenix application'
'phoenix.routes:Prints all routes'
'phoenix.server:Starts applications and their servers'
'release:Build a release for the current mix application.'
'release.clean:Clean up any release-related files.'
'release.plugins:View information about active release plugins'
'run:Run the given file or expression'
"test:Run a project's tests"
'--help:Describe available tasks'
'--version:Prints the Elixir version information'
__task_list ()
local expl
declare -a tasks
tasks=(archive clean compile deps deps.clean deps.compile deps.get deps.unlock deps.update do escriptize help local local.install local.rebar local.uninstall new run test)
_wanted tasks expl 'help' compadd $tasks
local expl
local curcontext="$curcontext" state line
typeset -A opt_args
_arguments -C \
':command:->command' \
case $state in
_describe -t commands "mix subcommand" _1st_arguments
case $line[1] in
_arguments ':feature:__task_list'

This comment has been minimized.

Copy link

@jasonm23 jasonm23 commented Jul 20, 2016

I know this is a bit old, but it's probably better to dynamically build the 1st arguments array, using something like this:

IFS=$'\n' _1st_arguments=($(
                             mix --help             \
                               | tr -s ' '          \
                               | sed -e 's/ # /:/'  \
                                   -e 's/^mix //'   \
                                   -e 's/^mix:.*//' \
                                   -e 's/^iex.*//'  \
                               | sort -u

  '--help:Describe available tasks'
  '--version:Prints the Elixir version information'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment