diff options
Diffstat (limited to 'plugins/fabric')
-rw-r--r-- | plugins/fabric/README.md | 9 | ||||
-rw-r--r-- | plugins/fabric/_fab | 19 | ||||
-rw-r--r-- | plugins/fabric/fabric.plugin.zsh | 1 |
3 files changed, 23 insertions, 6 deletions
diff --git a/plugins/fabric/README.md b/plugins/fabric/README.md new file mode 100644 index 000000000..cf0fa81f4 --- /dev/null +++ b/plugins/fabric/README.md @@ -0,0 +1,9 @@ +# Fabric + +This plugin provides completion for [Fabric](https://www.fabfile.org/). + +To use it add fabric to the plugins array in your zshrc file. + +```bash +plugins=(... fabric) +``` diff --git a/plugins/fabric/_fab b/plugins/fabric/_fab index 9628e1224..9102dadef 100644 --- a/plugins/fabric/_fab +++ b/plugins/fabric/_fab @@ -4,10 +4,19 @@ local curcontext=$curcontext state line declare -A opt_args -declare target_list -target_list=(`fab --shortlist 2>/dev/null`) +declare -a target_list +target_list=("${(@f)$(fab -l 2>/dev/null | awk '{ + if (NF == 0 || NR == 1) next + if (NF < 2) print $1 + else { + docstring=substr($0, index($0,$2)) + gsub(":", "\\:", docstring) + print $1":"docstring + } +}')}") -_targets() { +_fab_targets() { + [[ -n "$target_list" ]] || return _describe -t commands "fabric targets" target_list } @@ -28,7 +37,7 @@ _arguments -w -S -C \ '(-)--shortlist[print non-verbose list of possible commands and exit]: :->noargs' \ '(--reject-unknown-hosts)--reject-unknown-hosts[reject unknown hosts]' \ '(--no-pty)--no-pty[do not use pseudo-terminal in run/sudo]' \ - "(-d+ --display=-)"{-d+,--display=-}"[print detailed info about a given command]: :_targets" \ + "(-d+ --display=-)"{-d+,--display=-}"[print detailed info about a given command]: :_fab_targets" \ '(-D --disable-known-hosts)'{-D,--disable-known-hosts}'[do not load user known_hosts file]' \ '(-r --reject-unknown-hosts)'{-r,--reject-unknown-hosts}'[reject unknown hosts]' \ '(-u+ --user=-)'{-u+,--user=-}'[username to use when connecting to remote hosts]: :' \ @@ -53,7 +62,7 @@ if [[ CURRENT -ge 1 ]]; then levels) _describe -t commands "output levels" output_levels;; *) - _targets;; + _fab_targets;; esac return diff --git a/plugins/fabric/fabric.plugin.zsh b/plugins/fabric/fabric.plugin.zsh index aca411329..e69de29bb 100644 --- a/plugins/fabric/fabric.plugin.zsh +++ b/plugins/fabric/fabric.plugin.zsh @@ -1 +0,0 @@ -# DECLARION: This plugin was created by vhbit. What I did is just making a portal from https://github.com/vhbit/fabric-zsh-autocomplete. |