From 1a34574498e4f403ba28a8547a28134bcaffe427 Mon Sep 17 00:00:00 2001 From: Han Ngo Date: Sat, 8 Jul 2017 12:29:03 +0700 Subject: [PATCH] Add Elixir and Phoenix framework module --- modules/elixir/README.md | 57 +++++++++++++++++++++++++++++++++++++++ modules/elixir/alias.zsh | 53 ++++++++++++++++++++++++++++++++++++ modules/elixir/init.zsh | 14 ++++++++++ modules/phoenix/README.md | 45 +++++++++++++++++++++++++++++++ modules/phoenix/alias.zsh | 38 ++++++++++++++++++++++++++ modules/phoenix/init.zsh | 17 ++++++++++++ 6 files changed, 224 insertions(+) create mode 100644 modules/elixir/README.md create mode 100644 modules/elixir/alias.zsh create mode 100644 modules/elixir/init.zsh create mode 100644 modules/phoenix/README.md create mode 100644 modules/phoenix/alias.zsh create mode 100644 modules/phoenix/init.zsh diff --git a/modules/elixir/README.md b/modules/elixir/README.md new file mode 100644 index 00000000..b7070b41 --- /dev/null +++ b/modules/elixir/README.md @@ -0,0 +1,57 @@ +Elixir +============= + +Defines [Elixir][1] aliases. + +Aliases +------- + + - `i`='iex' runs interactive elixir + - `ips`='iex -S mix phoenix.server' runs iex in phoenix app + - `ism`='iex -S mix' runs iex in current elixir package + + - `m`='mix' runs the default task + - `mr`='mix run' runs the given file or expression + - `mrnh`='mix run --no-halt' does not halt the system after running the command + - `mrl`='mix release' build an executable release (require [distillery](https://github.com/bitwalker/distillery)) + - `mt`='mix test' runs a project's tests + - `mts`='mix test --stale' runs only tests which reference modules that changed since the last `test --stale` + - `mx`='mix xref' performs cross reference checks + + - `mn`='mix new' creates a new Elixir project + - `mns`='mix new --sup' creates a new Elixir project with a supervision tree + - `mat`='mix app.tree' prints the application tree + + - `mab`='mix archive.build' archives this project into a .ez file + - `mai`='mix archive.install' installs an archive locally + + - `mc`='mix compile' compiles source files + - `mcv`='mix compile --verbose' compiles source files with verbose mode + - `mcx`='mix compile.xref' performs remote dispatch checking + + - `mcr`='mix credo' analyze static code + - `mcrs`='mix credo --strict' + + - `mdc`='mix deps.compile' compiles dependencies + - `mdg`='mix deps.get' gets all out of date dependencies + - `mdt`='mix deps.tree' prints the dependency tree + - `mdu`='mix deps.update' updates the given dependencies + - `mdua`='mix deps.update --all' updates all dependencies + - `mdun`='mix deps.unlock' unlocks the given dependencies + - `mduu`='mix deps.unlock --unused' unlocks unused dependencies + - `mdgc`='mix do deps.get, deps.compile' get all dependencies then compiles them + + - `meb`='mix escript.build' builds an escript for the project + - `mho`='mix hex.outdated' shows outdated Hex deps for the current projects + - `mlh`='mix local.hex' installs Hex locally + +Authors +------- + +*The authors of this module should be contacted via the [issue tracker][2].* + + - [Han Ngo](https://github.com/tieubao) + + +[1]: https://elixir-lang.org +[2]: https://github.com/sorin-ionescu/prezto/issues diff --git a/modules/elixir/alias.zsh b/modules/elixir/alias.zsh new file mode 100644 index 00000000..e5ab1dc0 --- /dev/null +++ b/modules/elixir/alias.zsh @@ -0,0 +1,53 @@ +# +# Defines Mix Elixir aliases. +# +# Authors: +# Han Ngo +# + +# IEx +alias i='iex' +alias ips='iex -S mix phoenix.server' +alias ism='iex -S mix' + +# Mix +alias m='mix' +alias mr='mix run' +alias mrnh='mix run --no-halt' +alias mrl='mix release' +alias mt='mix test' +alias mts='mix test --stale' +alias mtw='mix test.watch' +alias mx='mix xref' + +alias mn='mix new' +alias mns='mix new --sup' +alias mat='mix app.tree' + +alias mab='mix archive.build' +alias mai='mix archive.install' + +alias mc='mix compile' +alias mcv='mix compile --verbose' +alias mcx='mix compile.xref' + +alias mcr='mix credo' +alias mcrs='mix credo --strict' + +alias mdc='mix deps.compile' +alias mdg='mix deps.get' +alias mdu='mix deps.update' +alias mdt='mix deps.tree' +alias mdua='mix deps.update --all' +alias mdun='mix deps.unlock' +alias mduu='mix deps.unlock --unused' +alias mdgc='mix do deps.get, deps.compile' + +alias meb='mix escript.build' +alias mho='mix hex.outdated' +alias mlh='mix local.hex' + +mncd() { + arg="$*" + mix new "$arg";cd "$arg"; +} \ No newline at end of file diff --git a/modules/elixir/init.zsh b/modules/elixir/init.zsh new file mode 100644 index 00000000..8772f602 --- /dev/null +++ b/modules/elixir/init.zsh @@ -0,0 +1,14 @@ +# +# Defines Elixir aliases. +# +# Authors: +# Han Ngo +# + +# Return if requirements are not found. +if (( ! $+commands[elixir] )); then + return 1 +fi + +# Source module files. +source "${0:h}/alias.zsh" \ No newline at end of file diff --git a/modules/phoenix/README.md b/modules/phoenix/README.md new file mode 100644 index 00000000..036f735a --- /dev/null +++ b/modules/phoenix/README.md @@ -0,0 +1,45 @@ +Phoenix Framework +============= + +Defines [Elixir Phoenix][1] aliases. + +Aliases +------- + + - `mpn`='mix phoenix.new' + - `mpr`='mix phoenix.routes' + - `mps`='mix phoenix.server' + + - `mpgc`='mix phoenix.gen.channel' generates a Phoenix channel + - `mpgh`='mix phoenix.gen.html' generates controller, views, and context for an HTML resource + - `mpgj`='mix phoenix.gen.json' generates controller, views, and context for a JSON resource + - `mpgm`='mix phoenix.gen.model' generates an Ecto model in your Phoenix application + - `mpgs`='mix phoenix.gen.secret' generates a secret + + - `mec`='mix ecto.create' creates the repository storage + - `med`='mix ecto.drop' drops the repository storage + - `mem`='mix ecto.migrate' runs the repository migrations + - `megm`='mix ecto.gen.migration' generates a new migration for the repo + - `merb`='mix ecto.rollback' rolls back the repository migrations + - `mecm`='mix do ecto.create, ecto.migrate' creates the repository storage then start migration + + - `kd`='kiex default' sets default elixir version with specific version + - `ki`='kiex install' installs a known release or branch + - `kl`='kiex list' lists installed versions + - `klb`='kiex list branches' lists current branches + - `klk`='kiex list known' lists known releases + - `klr`='kiex list releases' lists known releases + - `ks`='kiex shell' uses sub-shell with specific elixir version + - `ksu`='kiex selfupdate' upgrades kiex + - `ku`='kiex use' use specific elixir version + +Authors +------- + +*The authors of this module should be contacted via the [issue tracker][2].* + + - [Han Ngo](https://github.com/tieubao) + + +[1]: http://www.phoenixframework.org +[2]: https://github.com/sorin-ionescu/prezto/issues diff --git a/modules/phoenix/alias.zsh b/modules/phoenix/alias.zsh new file mode 100644 index 00000000..28135c4c --- /dev/null +++ b/modules/phoenix/alias.zsh @@ -0,0 +1,38 @@ +# +# Defines Mix Elixir & Phoenix aliases. +# +# Authors: +# Han Ngo +# + +# Mix Phoenix +alias mpn='mix phoenix.new' +alias mpr='mix phoenix.routes' +alias mps='mix phoenix.server' + +alias mpgc='mix phoenix.gen.channel' +alias mpgh='mix phoenix.gen.html' +alias mpgj='mix phoenix.gen.json' +alias mpgm='mix phoenix.gen.model' +alias mpgs='mix phoenix.gen.secret' + +# Mix Ecto +alias mec='mix ecto.create' +alias med='mix ecto.drop' +alias mem='mix ecto.migrate' +alias megm='mix ecto.gen.migration' +alias merb='mix ecto.rollback' +alias mers='mix ecto.reset' +alias mes='mix ecto.setup' +alias mecm='mix do ecto.create, ecto.migrate' + +# Kiex - Elixir Version Manager: https://github.com/taylor/kiex +alias kd='kiex default' +alias ki='kiex install' +alias kl='kiex list' +alias klb='kiex list branches' +alias klk='kiex list known' +alias klr='kiex list releases' +alias ks='kiex shell' +alias ksu='kiex selfupdate' +alias ku='kiex use' \ No newline at end of file diff --git a/modules/phoenix/init.zsh b/modules/phoenix/init.zsh new file mode 100644 index 00000000..9b6e8457 --- /dev/null +++ b/modules/phoenix/init.zsh @@ -0,0 +1,17 @@ +# +# Defines Mix Phoenix aliases. +# +# Authors: +# Han Ngo +# + +# Load dependencies. +pmodload 'elixir' + +# Return if requirements are not found. +if (( ! $+commands[mix phoenix.new] )); then + return 1 +fi + +# Source module files. +source "${0:h}/alias.zsh" \ No newline at end of file