1diff --git a/functions/gem/_gem b/functions/gem/_gem
2new file mode 100644
3index 0000000000000000000000000000000000000000..83cba40d135796280447ee6a1daf6c9e73df53de
4--- /dev/null
5+++ b/functions/gem/_gem
6@@ -0,0 +1,64 @@
7+#compdef gem
8+#autoload
9+
10+# gem zsh completion, based on homebrew completion
11+
12+_gem_installed() {
13+ installed_gems=(`gem list --local --no-versions`)
14+}
15+
16+local -a _1st_arguments
17+_1st_arguments=(
18+ 'cert:Manage RubyGems certificates and signing settings'
19+ 'check:Check installed gems'
20+ 'cleanup:Clean up old versions of installed gems in the local repository'
21+ 'contents:Display the contents of the installed gems'
22+ 'dependency:Show the dependencies of an installed gem'
23+ 'environment:Display information about the RubyGems environment'
24+ 'fetch:Download a gem and place it in the current directory'
25+ 'generate_index:Generates the index files for a gem server directory'
26+ 'help:Provide help on the `gem` command'
27+ 'install:Install a gem into the local repository'
28+ 'list:Display gems whose name starts with STRING'
29+ 'lock:Generate a lockdown list of gems'
30+ 'mirror:Mirror a gem repository'
31+ 'outdated:Display all gems that need updates'
32+ 'owner:Manage gem owners on RubyGems.org.'
33+ 'pristine:Restores installed gems to pristine condition from files located in the gem cache'
34+ 'push:Push a gem up to RubyGems.org'
35+ 'query:Query gem information in local or remote repositories'
36+ 'rdoc:Generates RDoc for pre-installed gems'
37+ 'search:Display all gems whose name contains STRING'
38+ 'server:Documentation and gem repository HTTP server'
39+ 'sources:Manage the sources and cache file RubyGems uses to search for gems'
40+ 'specification:Display gem specification (in yaml)'
41+ 'stale:List gems along with access times'
42+ 'uninstall:Uninstall gems from the local repository'
43+ 'unpack:Unpack an installed gem to the current directory'
44+ 'update:Update the named gems (or all installed gems) in the local repository'
45+ 'which:Find the location of a library file you can require'
46+)
47+
48+local expl
49+local -a gems installed_gems
50+
51+_arguments \
52+ '(-v --version)'{-v,--version}'[show version]' \
53+ '(-h --help)'{-h,--help}'[show help]' \
54+ '*:: :->subcmds' && return 0
55+
56+if (( CURRENT == 1 )); then
57+ _describe -t commands "gem subcommand" _1st_arguments
58+ return
59+fi
60+
61+case "$words[1]" in
62+ list)
63+ if [[ "$state" == forms ]]; then
64+ _gem_installed
65+ _requested installed_gems expl 'installed gems' compadd -a installed_gems
66+ fi ;;
67+ uninstall|update)
68+ _gem_installed
69+ _wanted installed_gems expl 'installed gems' compadd -a installed_gems ;;
70+esac
71diff --git a/plugins/gem.plugin.zsh b/plugins/gem.plugin.zsh
72new file mode 100644
73index 0000000000000000000000000000000000000000..0b6ef3c8699f38fa802d905423e95aa7874e7bce
74--- /dev/null
75+++ b/plugins/gem.plugin.zsh
76@@ -0,0 +1,4 @@
77+# add brew completion function to path
78+fpath=($ZSH/functions/gem $fpath)
79+autoload -U compinit
80+compinit -i