summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rwxr-xr-xplugins/bgnotify/bgnotify.plugin.zsh36
-rw-r--r--plugins/capistrano/_capistrano53
-rw-r--r--plugins/capistrano/capistrano.plugin.zsh11
-rw-r--r--plugins/coffee/coffee.plugin.zsh4
-rw-r--r--plugins/emotty/emotty.plugin.zsh43
-rw-r--r--plugins/emotty/emotty_emoji_set.zsh24
-rw-r--r--plugins/emotty/emotty_floral_set.zsh18
-rw-r--r--plugins/emotty/emotty_love_set.zsh34
-rw-r--r--plugins/emotty/emotty_nature_set.zsh58
-rw-r--r--plugins/emotty/emotty_stellar_set.zsh25
-rw-r--r--plugins/emotty/emotty_zodiac_set.zsh29
-rw-r--r--plugins/fancy-ctrl-z/README.md14
-rw-r--r--plugins/fancy-ctrl-z/fancy-ctrl-z.plugin.zsh12
-rw-r--r--plugins/git-extras/git-extras.plugin.zsh194
-rw-r--r--plugins/gnu-utils/gnu-utils.plugin.zsh5
-rw-r--r--plugins/golang/golang.plugin.zsh41
-rw-r--r--plugins/golang/templates/package.txt29
-rw-r--r--plugins/golang/templates/search.txt0
-rw-r--r--plugins/gulp/gulp.plugin.zsh29
-rw-r--r--plugins/npm/npm.plugin.zsh3
-rw-r--r--plugins/osx/osx.plugin.zsh84
-rw-r--r--plugins/rails/rails.plugin.zsh4
-rw-r--r--plugins/scw/README.md7
-rw-r--r--plugins/scw/_scw333
-rw-r--r--plugins/sudo/sudo.plugin.zsh6
-rw-r--r--plugins/svn/svn.plugin.zsh10
-rw-r--r--plugins/taskwarrior/README.md13
-rw-r--r--plugins/taskwarrior/_task312
-rw-r--r--plugins/taskwarrior/taskwarrior.plugin.zsh14
-rw-r--r--plugins/terminalapp/terminalapp.plugin.zsh45
-rw-r--r--plugins/vagrant/_vagrant36
-rw-r--r--plugins/vim-interaction/vim-interaction.plugin.zsh22
-rw-r--r--plugins/xcode/README.md84
-rw-r--r--plugins/xcode/_xcselv19
-rw-r--r--plugins/xcode/xcode.plugin.zsh192
35 files changed, 1449 insertions, 394 deletions
diff --git a/plugins/bgnotify/bgnotify.plugin.zsh b/plugins/bgnotify/bgnotify.plugin.zsh
index b70b42f98..459f5214e 100755
--- a/plugins/bgnotify/bgnotify.plugin.zsh
+++ b/plugins/bgnotify/bgnotify.plugin.zsh
@@ -11,31 +11,38 @@ autoload -Uz add-zsh-hook || { print "can't add zsh hook!"; return }
## definitions ##
-if ! (type bgnotify_formatted | grep -q 'function'); then
- function bgnotify_formatted {
- ## exit_status, command, elapsed_time
- [ $1 -eq 0 ] && title="#win (took $3 s)" || title="#fail (took $3 s)"
- bgnotify "$title" "$2"
+if ! (type bgnotify_formatted | grep -q 'function'); then ## allow custom function override
+ function bgnotify_formatted { ## args: (exit_status, command, elapsed_seconds)
+ elapsed="$(( $3 % 60 ))s"
+ (( $3 >= 60 )) && elapsed="$((( $3 % 3600) / 60 ))m $elapsed"
+ (( $3 >= 3600 )) && elapsed="$(( $3 / 3600 ))h $elapsed"
+ [ $1 -eq 0 ] && bgnotify "#win (took $elapsed)" "$2" || bgnotify "#fail (took $elapsed)" "$2"
}
fi
currentWindowId () {
if hash osascript 2>/dev/null; then #osx
osascript -e 'tell application (path to frontmost application as text) to id of front window' 2&> /dev/null || echo "0"
- elif hash notify-send 2>/dev/null; then #ubuntu!
- xprop -root | awk '/NET_ACTIVE_WINDOW/ { print $5; exit }'
+ elif (hash notify-send 2>/dev/null || hash kdialog 2>/dev/null); then #ubuntu!
+ xprop -root 2> /dev/null | awk '/NET_ACTIVE_WINDOW/{print $5;exit} END{exit !$5}' || echo "0"
else
echo $EPOCHSECONDS #fallback for windows
fi
}
-bgnotify () {
+bgnotify () { ## args: (title, subtitle)
if hash terminal-notifier 2>/dev/null; then #osx
- terminal-notifier -message "$2" -title "$1"
+ [[ "$TERM_PROGRAM" == 'iTerm.app' ]] && term_id='com.googlecode.iterm2';
+ [[ "$TERM_PROGRAM" == 'Apple_Terminal' ]] && term_id='com.apple.terminal';
+ ## now call terminal-notifier, (hopefully with $term_id!)
+ [ -z "$term_id" ] && terminal-notifier -message "$2" -title "$1" >/dev/null ||
+ terminal-notifier -message "$2" -title "$1" -activate "$term_id" -sender "$term_id" >/dev/null
elif hash growlnotify 2>/dev/null; then #osx growl
growlnotify -m "$1" "$2"
- elif hash notify-send 2>/dev/null; then #ubuntu!
+ elif hash notify-send 2>/dev/null; then #ubuntu gnome!
notify-send "$1" "$2"
+ elif hash kdialog 2>/dev/null; then #ubuntu kde!
+ kdialog -title "$1" --passivepopup "$2" 5
elif hash notifu 2>/dev/null; then #cygwyn support!
notifu /m "$2" /p "$1"
fi
@@ -46,7 +53,7 @@ bgnotify () {
bgnotify_begin() {
bgnotify_timestamp=$EPOCHSECONDS
- bgnotify_lastcmd=$1
+ bgnotify_lastcmd="$1"
bgnotify_windowid=$(currentWindowId)
}
@@ -63,5 +70,8 @@ bgnotify_end() {
bgnotify_timestamp=0 #reset it to 0!
}
-add-zsh-hook preexec bgnotify_begin
-add-zsh-hook precmd bgnotify_end
+## only enable if a local (non-ssh) connection
+if [ -z "$SSH_CLIENT" ] && [ -z "$SSH_TTY" ]; then
+ add-zsh-hook preexec bgnotify_begin
+ add-zsh-hook precmd bgnotify_end
+fi
diff --git a/plugins/capistrano/_capistrano b/plugins/capistrano/_capistrano
index 3cadf3d54..e6e71ffcc 100644
--- a/plugins/capistrano/_capistrano
+++ b/plugins/capistrano/_capistrano
@@ -1,10 +1,49 @@
-#compdef cap
+#compdef shipit
#autoload
-if [[ -f config/deploy.rb || -f Capfile ]]; then
- if [[ ! -f .cap_tasks~ || config/deploy.rb -nt .cap_tasks~ ]]; then
- echo "\nGenerating .cap_tasks~..." > /dev/stderr
- cap -v --tasks | grep '#' | cut -d " " -f 2 > .cap_tasks~
+# Added `shipit` because `cap` is a reserved word. `cap` completion doesn't work.
+# http://zsh.sourceforge.net/Doc/Release/Zsh-Modules.html#The-zsh_002fcap-Module
+
+local curcontext="$curcontext" state line ret=1
+local -a _configs
+
+_arguments -C \
+ '1: :->cmds' \
+ '2:: :->args' && ret=0
+
+_cap_tasks() {
+ if [[ -f config/deploy.rb || -f Capfile ]]; then
+ if [[ ! -f .cap_tasks~ ]]; then
+ shipit -v --tasks | sed 's/\(\[\)\(.*\)\(\]\)/\2:/' | awk '{command=$2; $1=$2=$3=""; gsub(/^[ \t\r\n]+/, "", $0); gsub(":", "\\:", command); print command"["$0"]"}' > .cap_tasks~
+ fi
+
+ OLD_IFS=$IFS
+ IFS=$'\n'
+ _values 'cap commands' $(< .cap_tasks~)
+ IFS=$OLD_IFS
+ # zmodload zsh/mapfile
+ # _values ${(f)mapfile[.cap_tasks~]}
fi
- compadd `cat .cap_tasks~`
-fi
+}
+
+_cap_stages() {
+ compadd $(find config/deploy -name \*.rb | cut -d/ -f3 | sed s:.rb::g)
+}
+
+case $state in
+ cmds)
+ # check if it uses multistage
+ if [[ -d config/deploy ]]; then
+ _cap_stages
+ else
+ _cap_tasks
+ fi
+ ret=0
+ ;;
+ args)
+ _cap_tasks
+ ret=0
+ ;;
+esac
+
+return ret
diff --git a/plugins/capistrano/capistrano.plugin.zsh b/plugins/capistrano/capistrano.plugin.zsh
new file mode 100644
index 000000000..c85eb474c
--- /dev/null
+++ b/plugins/capistrano/capistrano.plugin.zsh
@@ -0,0 +1,11 @@
+# Added `shipit` because `cap` is a reserved word. `cap` completion doesn't work.
+# http://zsh.sourceforge.net/Doc/Release/Zsh-Modules.html#The-zsh_002fcap-Module
+
+func shipit() {
+ if [ -f Gemfile ]
+ then
+ bundle exec cap $*
+ else
+ cap $*
+ fi
+}
diff --git a/plugins/coffee/coffee.plugin.zsh b/plugins/coffee/coffee.plugin.zsh
index 1a7bedd87..4e98e0228 100644
--- a/plugins/coffee/coffee.plugin.zsh
+++ b/plugins/coffee/coffee.plugin.zsh
@@ -2,11 +2,11 @@
# compile a string of coffeescript and print to output
cf () {
- coffee -peb $1
+ coffee -peb "$1"
}
# compile & copy to clipboard
cfc () {
- cf $1 | pbcopy
+ cf "$1" | pbcopy
}
# compile from pasteboard & print
diff --git a/plugins/emotty/emotty.plugin.zsh b/plugins/emotty/emotty.plugin.zsh
new file mode 100644
index 000000000..b32dd1a4c
--- /dev/null
+++ b/plugins/emotty/emotty.plugin.zsh
@@ -0,0 +1,43 @@
+# ------------------------------------------------------------------------------
+# FILE: emotty.plugin.zsh
+# DESCRIPTION: Return an emoji for the current $TTY number.
+# AUTHOR: Alexis Hildebrandt (afh[at]surryhill.net)
+# VERSION: 1.0.0
+# DEPENDS: emoji plugin
+#
+# There are different sets of emoji characters available, to choose a different
+# set export emotty_set to the name of the set you would like to use, e.g.:
+# % export emotty_set=nature
+# ------------------------------------------------------------------------------
+
+typeset -gAH _emotty_sets
+local _emotty_plugin_dir="${0:h}"
+source "$_emotty_plugin_dir/emotty_stellar_set.zsh"
+source "$_emotty_plugin_dir/emotty_floral_set.zsh"
+source "$_emotty_plugin_dir/emotty_zodiac_set.zsh"
+source "$_emotty_plugin_dir/emotty_nature_set.zsh"
+source "$_emotty_plugin_dir/emotty_emoji_set.zsh"
+source "$_emotty_plugin_dir/emotty_love_set.zsh"
+unset _emotty_plugin_dir
+
+emotty_default_set=emoji
+
+function emotty() {
+ # Use emotty set defined by user, fallback to default
+ local emotty=${_emotty_sets[${emotty_set:-$emotty_default_set}]}
+ # Parse $TTY number, normalizing it to an emotty set index
+ (( tty = (${TTY##/dev/ttys} % ${#${=emotty}}) + 1 ))
+ local character_name=${${=emotty}[tty]}
+ echo "${emoji[${character_name}]}${emoji2[emoji_style]}"
+}
+
+function display_emotty() {
+ local name=$1
+ for i in ${=_emotty_sets[$name]}; do
+ printf "${emoji[$i]}${emoji2[emoji_style]} "
+ done
+ print
+ for i in ${=_emotty_sets[$name]}; do
+ print "${emoji[$i]}${emoji2[emoji_style]} = $i"
+ done
+}
diff --git a/plugins/emotty/emotty_emoji_set.zsh b/plugins/emotty/emotty_emoji_set.zsh
new file mode 100644
index 000000000..00e317131
--- /dev/null
+++ b/plugins/emotty/emotty_emoji_set.zsh
@@ -0,0 +1,24 @@
+#!/usr/bin/env zsh
+# vim:ft=zsh ts=2 sw=2 sts=2
+
+_emotty_sets[emoji]="
+ crystal_ball
+ ghost
+ jack_o_lantern
+ see_no_evil_monkey
+ hear_no_evil_monkey
+ speak_no_evil_monkey
+ smiling_cat_face_with_open_mouth
+ extraterrestrial_alien
+ rocket
+ billiards
+ bomb
+ pill
+ japanese_symbol_for_beginner
+ direct_hit
+ cyclone
+ diamond_shape_with_a_dot_inside
+ sparkle
+ eight_spoked_asterisk
+ eight_pointed_black_star
+ "
diff --git a/plugins/emotty/emotty_floral_set.zsh b/plugins/emotty/emotty_floral_set.zsh
new file mode 100644
index 000000000..f761feae6
--- /dev/null
+++ b/plugins/emotty/emotty_floral_set.zsh
@@ -0,0 +1,18 @@
+#!/usr/bin/env zsh
+# vim:ft=zsh ts=2 sw=2 sts=2
+
+_emotty_sets[floral]="
+ hibiscus
+ cherry_blossom
+ blossom
+ sunflower
+ bouquet
+ tulip
+ rose
+ four_leaf_clover
+ seedling
+ herb
+ palm_tree
+ evergreen_tree
+ deciduous_tree
+ "
diff --git a/plugins/emotty/emotty_love_set.zsh b/plugins/emotty/emotty_love_set.zsh
new file mode 100644
index 000000000..8f19e6902
--- /dev/null
+++ b/plugins/emotty/emotty_love_set.zsh
@@ -0,0 +1,34 @@
+#!/usr/bin/env zsh
+# vim:ft=zsh ts=2 sw=2 sts=2
+
+# Note: The heavy_black_heart emoji requires $emoji2[emoji_style]
+# to be rendered as the emoji red heart.
+_emotty_sets[love]="
+ green_heart
+ blue_heart
+ purple_heart
+ yellow_heart
+ heavy_black_heart
+ broken_heart
+ heart_with_arrow
+ heart_with_ribbon
+ sparkling_heart
+ two_hearts
+ revolving_hearts
+ growing_heart
+ beating_heart
+ heart_decoration
+ couple_with_heart
+ kiss
+ man_and_woman_holding_hands
+ two_women_holding_hands
+ two_men_holding_hands
+ kiss_mark
+ smiling_face_with_heart_shaped_eyes
+ kissing_face
+ face_throwing_a_kiss
+ kissing_face_with_smiling_eyes
+ kissing_face_with_closed_eyes
+ smiling_cat_face_with_heart_shaped_eyes
+ kissing_cat_face_with_closed_eyes
+ "
diff --git a/plugins/emotty/emotty_nature_set.zsh b/plugins/emotty/emotty_nature_set.zsh
new file mode 100644
index 000000000..8dab4c1ba
--- /dev/null
+++ b/plugins/emotty/emotty_nature_set.zsh
@@ -0,0 +1,58 @@
+#!/usr/bin/env zsh
+# vim:ft=zsh ts=2 sw=2 sts=2
+
+_emotty_sets[nature]="
+ mouse_face
+ hamster_face
+ rabbit_face
+ dog_face
+ cat_face
+ tiger_face
+ bear_face
+ monkey_face
+ koala
+ panda_face
+ chicken
+ baby_chick
+ bird
+ penguin
+ cow_face
+ pig_face
+ frog_face
+ boar
+ wolf_face
+ horse_face
+ snail
+ bug
+ ant
+ honeybee
+ lady_beetle
+ spouting_whale
+ dolphin
+ octopus
+ fish
+ tropical_fish
+ snake
+ turtle
+ lemon
+ tangerine
+ peach
+ mushroom
+ tomato
+ strawberry
+ red_apple
+ cherries
+ grapes
+ aubergine
+ watermelon
+ banana
+ pineapple
+ melon
+ pear
+ green_apple
+ ear_of_maize
+ sunflower
+ seedling
+ herb
+ four_leaf_clover
+ "
diff --git a/plugins/emotty/emotty_stellar_set.zsh b/plugins/emotty/emotty_stellar_set.zsh
new file mode 100644
index 000000000..8e7e61068
--- /dev/null
+++ b/plugins/emotty/emotty_stellar_set.zsh
@@ -0,0 +1,25 @@
+#!/usr/bin/env zsh
+# vim:ft=zsh ts=2 sw=2 sts=2
+
+# NOTE: The following emoji show as $'character' in the title
+# white_medium_star
+# sparkles
+# dizzy_symbol
+
+_emotty_sets[stellar]="
+ full_moon_symbol
+ waning_gibbous_moon_symbol
+ waning_crescent_moon_symbol
+ last_quarter_moon_symbol
+ new_moon_symbol
+ new_moon_with_face
+ waxing_crescent_moon_symbol
+ first_quarter_moon_symbol
+ waxing_gibbous_moon_symbol
+ full_moon_with_face
+ sun_with_face
+ glowing_star
+ crescent_moon
+ first_quarter_moon_with_face
+ last_quarter_moon_with_face
+ "
diff --git a/plugins/emotty/emotty_zodiac_set.zsh b/plugins/emotty/emotty_zodiac_set.zsh
new file mode 100644
index 000000000..bde6e3d2e
--- /dev/null
+++ b/plugins/emotty/emotty_zodiac_set.zsh
@@ -0,0 +1,29 @@
+#!/usr/bin/env zsh
+# vim:ft=zsh ts=2 sw=2 sts=2
+
+_emotty_sets[zodiac]="
+ aries
+ taurus
+ gemini
+ cancer
+ leo
+ virgo
+ libra
+ scorpius
+ sagittarius
+ capricorn
+ aquarius
+ pisces
+ rat
+ ox
+ tiger
+ rabbit
+ dragon
+ snake
+ horse
+ goat
+ monkey
+ rooster
+ dog
+ pig
+ "
diff --git a/plugins/fancy-ctrl-z/README.md b/plugins/fancy-ctrl-z/README.md
new file mode 100644
index 000000000..a7670fa2c
--- /dev/null
+++ b/plugins/fancy-ctrl-z/README.md
@@ -0,0 +1,14 @@
+# Use Ctrl-Z to switch back to Vim
+
+I frequently need to execute random command in my shell. To achieve it I pause
+Vim by pressing Ctrl-z, type command and press fg<Enter> to switch back to Vim.
+The fg part really hurt sme. I just wanted to hit Ctrl-z once again to get back
+to Vim. I could not find a solution, so I developed one on my own that
+works wonderfully with ZSH
+
+Source: http://sheerun.net/2014/03/21/how-to-boost-your-vim-productivity/
+
+Credits:
+- original idea by @sheerun
+- added to OMZ by @mbologna
+
diff --git a/plugins/fancy-ctrl-z/fancy-ctrl-z.plugin.zsh b/plugins/fancy-ctrl-z/fancy-ctrl-z.plugin.zsh
new file mode 100644
index 000000000..8ab297913
--- /dev/null
+++ b/plugins/fancy-ctrl-z/fancy-ctrl-z.plugin.zsh
@@ -0,0 +1,12 @@
+fancy-ctrl-z () {
+ if [[ $#BUFFER -eq 0 ]]; then
+ BUFFER="fg"
+ zle accept-line
+ else
+ zle push-input
+ zle clear-screen
+ fi
+}
+zle -N fancy-ctrl-z
+bindkey '^Z' fancy-ctrl-z
+
diff --git a/plugins/git-extras/git-extras.plugin.zsh b/plugins/git-extras/git-extras.plugin.zsh
index 8419166ab..d91c1af81 100644
--- a/plugins/git-extras/git-extras.plugin.zsh
+++ b/plugins/git-extras/git-extras.plugin.zsh
@@ -3,19 +3,20 @@
# Description
# -----------
#
-# Completion script for git-extras (http://github.com/visionmedia/git-extras).
+# Completion script for git-extras (http://github.com/tj/git-extras).
#
# ------------------------------------------------------------------------------
# Authors
# -------
#
# * Alexis GRIMALDI (https://github.com/agrimaldi)
+# * spacewander (https://github.com/spacewander)
#
# ------------------------------------------------------------------------------
# Inspirations
# -----------
#
-# * git-extras (http://github.com/visionmedia/git-extras)
+# * git-extras (http://github.com/tj/git-extras)
# * git-flow-completion (http://github.com/bobthecow/git-flow-completion)
#
# ------------------------------------------------------------------------------
@@ -30,10 +31,21 @@ __git_command_successful () {
}
+__git_commits() {
+ declare -A commits
+ git log --oneline -15 | sed 's/\([[:alnum:]]\{7\}\) /\1:/' | while read commit
+ do
+ hash=$(echo $commit | cut -d':' -f1)
+ commits[$hash]="$commit"
+ done
+ local ret=1
+ _describe -t commits commit commits && ret=0
+}
+
__git_tag_names() {
local expl
declare -a tag_names
- tag_names=(${${(f)"$(_call_program branchrefs git for-each-ref --format='"%(refname)"' refs/tags 2>/dev/null)"}#refs/tags/})
+ tag_names=(${${(f)"$(_call_program tags git for-each-ref --format='"%(refname)"' refs/tags 2>/dev/null)"}#refs/tags/})
__git_command_successful || return
_wanted tag-names expl tag-name compadd $* - $tag_names
}
@@ -47,31 +59,27 @@ __git_branch_names() {
_wanted branch-names expl branch-name compadd $* - $branch_names
}
-
-__git_feature_branch_names() {
+__git_specific_branch_names() {
local expl
declare -a branch_names
- branch_names=(${${(f)"$(_call_program branchrefs git for-each-ref --format='"%(refname)"' refs/heads/feature 2>/dev/null)"}#refs/heads/feature/})
+ branch_names=(${${(f)"$(_call_program branchrefs git for-each-ref --format='"%(refname)"' refs/heads/"$1" 2>/dev/null)"}#refs/heads/$1/})
__git_command_successful || return
_wanted branch-names expl branch-name compadd $* - $branch_names
}
+__git_feature_branch_names() {
+ __git_specific_branch_names 'feature'
+}
+
+
__git_refactor_branch_names() {
- local expl
- declare -a branch_names
- branch_names=(${${(f)"$(_call_program branchrefs git for-each-ref --format='"%(refname)"' refs/heads/refactor 2>/dev/null)"}#refs/heads/refactor/})
- __git_command_successful || return
- _wanted branch-names expl branch-name compadd $* - $branch_names
+ __git_specific_branch_names 'refactor'
}
__git_bug_branch_names() {
- local expl
- declare -a branch_names
- branch_names=(${${(f)"$(_call_program branchrefs git for-each-ref --format='"%(refname)"' refs/heads/bug 2>/dev/null)"}#refs/heads/bug/})
- __git_command_successful || return
- _wanted branch-names expl branch-name compadd $* - $branch_names
+ __git_specific_branch_names 'bug'
}
@@ -92,19 +100,43 @@ __git_author_names() {
_wanted author-names expl author-name compadd $* - $author_names
}
+# subcommands
-_git-changelog() {
- _arguments \
- '(-l --list)'{-l,--list}'[list commits]' \
+_git-bug() {
+ local curcontext=$curcontext state line ret=1
+ declare -A opt_args
+
+ _arguments -C \
+ ': :->command' \
+ '*:: :->option-or-argument' && ret=0
+
+ case $state in
+ (command)
+ declare -a commands
+ commands=(
+ 'finish:merge bug into the current branch'
+ )
+ _describe -t commands command commands && ret=0
+ ;;
+ (option-or-argument)
+ curcontext=${curcontext%:*}-$line[1]:
+ case $line[1] in
+ (finish)
+ _arguments -C \
+ ':branch-name:__git_bug_branch_names'
+ ;;
+ esac
+ esac
}
-_git-effort() {
+_git-changelog() {
_arguments \
- '--above[ignore file with less than x commits]' \
+ '(-l --list)'{-l,--list}'[list commits]' \
}
+
_git-contrib() {
_arguments \
':author:__git_author_names'
@@ -135,6 +167,11 @@ _git-delete-tag() {
}
+_git-effort() {
+ _arguments \
+ '--above[ignore file with less than x commits]'
+}
+
_git-extras() {
local curcontext=$curcontext state line ret=1
declare -A opt_args
@@ -154,20 +191,7 @@ _git-extras() {
esac
_arguments \
- '(-v --version)'{-v,--version}'[show current version]' \
-}
-
-
-_git-graft() {
- _arguments \
- ':src-branch-name:__git_branch_names' \
- ':dest-branch-name:__git_branch_names'
-}
-
-
-_git-squash() {
- _arguments \
- ':branch-name:__git_branch_names'
+ '(-v --version)'{-v,--version}'[show current version]'
}
@@ -199,6 +223,25 @@ _git-feature() {
}
+_git-graft() {
+ _arguments \
+ ':src-branch-name:__git_branch_names' \
+ ':dest-branch-name:__git_branch_names'
+}
+
+
+_git-ignore() {
+ _arguments -C \
+ '(--local -l)'{--local,-l}'[show local gitignore]' \
+ '(--global -g)'{--global,-g}'[show global gitignore]'
+}
+
+_git-missing() {
+ _arguments \
+ ':first-branch-name:__git_branch_names' \
+ ':second-branch-name:__git_branch_names'
+}
+
_git-refactor() {
local curcontext=$curcontext state line ret=1
declare -A opt_args
@@ -227,59 +270,62 @@ _git-refactor() {
}
-_git-bug() {
- local curcontext=$curcontext state line ret=1
- declare -A opt_args
-
- _arguments -C \
- ': :->command' \
- '*:: :->option-or-argument' && ret=0
+_git-squash() {
+ _arguments \
+ ':branch-name:__git_branch_names'
+}
- case $state in
- (command)
- declare -a commands
- commands=(
- 'finish:merge bug into the current branch'
- )
- _describe -t commands command commands && ret=0
- ;;
- (option-or-argument)
- curcontext=${curcontext%:*}-$line[1]:
- case $line[1] in
- (finish)
- _arguments -C \
- ':branch-name:__git_bug_branch_names'
- ;;
- esac
- esac
+_git-summary() {
+ _arguments '--line[summarize with lines other than commits]'
+ __git_commits
}
+_git-undo(){
+ _arguments -C \
+ '(--soft -s)'{--soft,-s}'[only rolls back the commit but changes remain un-staged]' \
+ '(--hard -h)'{--hard,-h}'[wipes your commit(s)]'
+}
+
zstyle ':completion:*:*:git:*' user-commands \
+ alias:'define, search and show aliases' \
+ archive-file:'export the current HEAD of the git repository to a archive' \
+ back:'undo and stage latest commits' \
+ bug:'create a bug branch' \
changelog:'populate changelog file with commits since the previous tag' \
+ commits-since:'list commits since a given date' \
contrib:'display author contributions' \
count:'count commits' \
+ create-branch:'create local and remote branch' \
delete-branch:'delete local and remote branch' \
+ delete-merged-brancees:'delete merged branches'\
delete-submodule:'delete submodule' \
delete-tag:'delete local and remote tag' \
+ effort:'display effort statistics' \
extras:'git-extras' \
- graft:'merge commits from source branch to destination branch' \
- squash:'merge commits from source branch into the current one as a single commit' \
feature:'create a feature branch' \
- refactor:'create a refactor branch' \
- bug:'create a bug branch' \
- summary:'repository summary' \
- effort:'display effort statistics' \
- repl:'read-eval-print-loop' \
- commits-since:'list commits since a given date' \
- release:'release commit with the given tag' \
- alias:'define, search and show aliases' \
+ fork:'fork a repo on github' \
+ fresh-branch:'create empty local branch' \
+ gh-pages:'create the GitHub Pages branch' \
+ graft:'merge commits from source branch to destination branch' \
ignore:'add patterns to .gitignore' \
info:'show info about the repository' \
- create-branch:'create local and remote branch' \
- fresh-branch:'create empty local branch' \
- undo:'remove the latest commit' \
+ local-commits:'list unpushed commits on the local branch' \
+ lock:'lock a file excluded from version control' \
+ locked:'ls files that have been locked' \
+ missing:'show commits missing from another branch' \
+ pr:'checks out a pull request locally' \
+ rebase-patch:'rebases a patch' \
+ refactor:'create a refactor branch' \
+ release:'commit, tag and push changes to the repository' \
+ rename-tag:'rename a tag' \
+ repl:'read-eval-print-loop' \
+ reset-file:'reset one file' \
+ root:'show path of root' \
setup:'setup a git repository' \
+ show-tree:'show branch tree of commit history' \
+ squash:'merge commits from source branch into the current one as a single commit' \
+ summary:'repository summary' \
touch:'one step creation of new files' \
- obliterate:'Completely remove a file from the repository, including past commits and tags' \
- local-commits:'list unpushed commits on the local branch' \
+ undo:'remove the latest commit' \
+ unlock:'unlock a file excluded from version control'
diff --git a/plugins/gnu-utils/gnu-utils.plugin.zsh b/plugins/gnu-utils/gnu-utils.plugin.zsh
index e59265d66..de95f7e6c 100644
--- a/plugins/gnu-utils/gnu-utils.plugin.zsh
+++ b/plugins/gnu-utils/gnu-utils.plugin.zsh
@@ -29,7 +29,10 @@ if [[ -x "${commands[gwhoami]}" ]]; then
'gunexpand' 'guniq' 'gunlink' 'guptime' 'gusers' 'gvdir' 'gwc' 'gwho'
'gwhoami' 'gyes')
- # Not part of coreutils, installed separately.
+ # findutils
+ gcmds+=('gfind' 'gxargs' 'glocate')
+
+ # Not part of either coreutils or findutils, installed separately.
gcmds+=('gsed' 'gtar' 'gtime')
for gcmd in "${gcmds[@]}"; do
diff --git a/plugins/golang/golang.plugin.zsh b/plugins/golang/golang.plugin.zsh
index 900fc630d..1ce3cea58 100644
--- a/plugins/golang/golang.plugin.zsh
+++ b/plugins/golang/golang.plugin.zsh
@@ -54,23 +54,42 @@ __go_tool_complete() {
'-installsuffix[suffix to add to package directory]:suffix'
'-tags[list of build tags to consider satisfied]:tags'
)
- __go_list() {
- local expl importpaths
- declare -a importpaths
- importpaths=($(go list ${words[$CURRENT]}... 2>/dev/null))
- _wanted importpaths expl 'import paths' compadd "$@" - "${importpaths[@]}"
+ __go_packages() {
+ local gopaths
+ declare -a gopaths
+ gopaths=("${(s/:/)$(go env GOPATH)}")
+ gopaths+=("$(go env GOROOT)")
+ for p in $gopaths; do
+ _path_files -W "$p/src" -/
+ done
+ }
+ __go_identifiers() {
+ compadd $(godoc -templates $ZSH/plugins/golang/templates ${words[-2]} 2> /dev/null)
}
case ${words[2]} in
- clean|doc)
- _arguments -s -w : '*:importpaths:__go_list'
+ doc)
+ _arguments -s -w \
+ "-c[symbol matching honors case (paths not affected)]" \
+ "-cmd[show symbols with package docs even if package is a command]" \
+ "-u[show unexported symbols as well as exported]" \
+ "2:importpaths:__go_packages" \
+ ":next identifiers:__go_identifiers"
+ ;;
+ clean)
+ _arguments -s -w \
+ "-i[remove the corresponding installed archive or binary (what 'go install' would create)]" \
+ "-n[print the remove commands it would execute, but not run them]" \
+ "-r[apply recursively to all the dependencies of the packages named by the import paths]" \
+ "-x[print remove commands as it executes them]" \
+ "*:importpaths:__go_packages"
;;
fix|fmt|list|vet)
- _alternative ':importpaths:__go_list' ':files:_path_files -g "*.go"'
+ _alternative ':importpaths:__go_packages' ':files:_path_files -g "*.go"'
;;
install)
_arguments -s -w : ${build_flags[@]} \
"-v[show package names]" \
- '*:importpaths:__go_list'
+ '*:importpaths:__go_packages'
;;
get)
_arguments -s -w : \
@@ -81,7 +100,7 @@ __go_tool_complete() {
${build_flags[@]} \
"-v[show package names]" \
"-o[output file]:file:_files" \
- "*:args:{ _alternative ':importpaths:__go_list' ':files:_path_files -g \"*.go\"' }"
+ "*:args:{ _alternative ':importpaths:__go_packages' ':files:_path_files -g \"*.go\"' }"
;;
test)
_arguments -s -w : \
@@ -103,7 +122,7 @@ __go_tool_complete() {
"-cpuprofile[write CPU profile to file]:file:_files" \
"-memprofile[write heap profile to file]:file:_files" \
"-memprofilerate[set heap profiling rate]:number" \
- "*:args:{ _alternative ':importpaths:__go_list' ':files:_path_files -g \"*.go\"' }"
+ "*:args:{ _alternative ':importpaths:__go_packages' ':files:_path_files -g \"*.go\"' }"
;;
help)
_values "${commands[@]}" \
diff --git a/plugins/golang/templates/package.txt b/plugins/golang/templates/package.txt
new file mode 100644
index 000000000..2b75cce35
--- /dev/null
+++ b/plugins/golang/templates/package.txt
@@ -0,0 +1,29 @@
+{{with .PDoc}}{{/*
+
+Constants
+---------------------------------------
+
+*/}}{{with .Consts}}{{range .}}{{range .Names}}{{.}} {{end}}{{end}}{{end}}{{/*
+
+Variables
+---------------------------------------
+
+*/}}{{with .Vars}}{{range .}}{{range .Names}}{{.}} {{end}}{{end}}{{end}}{{/*
+
+Functions
+---------------------------------------
+
+*/}}{{with .Funcs}}{{range .}}{{ .Name }} {{end}}{{end}}{{/*
+
+Types
+---------------------------------------
+
+*/}}{{with .Types}}{{range .}}{{ $TypeName := .Name }}{{ $TypeName }} {{/*
+
+*/}}{{range .Methods}}{{ $TypeName }}.{{.Name}} {{end}}{{/*
+
+*/}}{{range .Funcs}}{{.Name}} {{end}}{{/*
+
+*/}}{{range .Consts}}{{range .Names}}{{.}} {{end}}{{end}}{{/*
+
+*/}}{{range .Vars}}{{range .Names}}{{.}} {{end}}{{end}}{{end}}{{end}}{{end}}
diff --git a/plugins/golang/templates/search.txt b/plugins/golang/templates/search.txt
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/plugins/golang/templates/search.txt
diff --git a/plugins/gulp/gulp.plugin.zsh b/plugins/gulp/gulp.plugin.zsh
new file mode 100644
index 000000000..6017c7b60
--- /dev/null
+++ b/plugins/gulp/gulp.plugin.zsh
@@ -0,0 +1,29 @@
+#!/usr/bin/env zsh
+
+#
+# gulp-autocompletion-zsh
+#
+# Autocompletion for your gulp.js tasks
+#
+# Copyright(c) 2014 André König <andre.koenig@posteo.de>
+# MIT Licensed
+#
+
+#
+# André König
+# Github: https://github.com/akoenig
+# Twitter: https://twitter.com/caiifr
+#
+
+#
+# Grabs all available tasks from the `gulpfile.js`
+# in the current directory.
+#
+function $$gulp_completion() {
+ compls=$(grep -Eo "gulp.task\(('(([a-zA-Z0-9]|-)*)',)" gulpfile.js 2>/dev/null | grep -Eo "'(([a-zA-Z0-9]|-)*)'" | sed s/"'"//g | sort)
+
+ completions=(${=compls})
+ compadd -- $completions
+}
+
+compdef $$gulp_completion gulp \ No newline at end of file
diff --git a/plugins/npm/npm.plugin.zsh b/plugins/npm/npm.plugin.zsh
index 68ec5fabd..595105d3c 100644
--- a/plugins/npm/npm.plugin.zsh
+++ b/plugins/npm/npm.plugin.zsh
@@ -12,3 +12,6 @@ alias npmS="npm i -S "
# Install and save to dev-dependencies in your package.json
# npmd is used by https://github.com/dominictarr/npmd
alias npmD="npm i -D "
+# Execute command from node_modules folder based on current directory
+# i.e npmE gulp
+alias npmE='PATH="$(npm bin)":"$PATH"'
diff --git a/plugins/osx/osx.plugin.zsh b/plugins/osx/osx.plugin.zsh
index 390960fdc..2cbb95977 100644
--- a/plugins/osx/osx.plugin.zsh
+++ b/plugins/osx/osx.plugin.zsh
@@ -5,29 +5,35 @@
# VERSION: 1.1.0
# ------------------------------------------------------------------------------
-function tab() {
- local command="cd \\\"$PWD\\\"; clear"
- (( $# > 0 )) && command="${command}; $*"
-
- the_app=$(
+function _omz_osx_get_frontmost_app() {
+ local the_app=$(
osascript 2>/dev/null <<EOF
tell application "System Events"
name of first item of (every process whose frontmost is true)
end tell
EOF
)
+ echo "$the_app"
+}
- [[ "$the_app" == 'Terminal' ]] && {
- osascript 2>/dev/null <<EOF
+function tab() {
+ # Must not have trailing semicolon, for iTerm compatibility
+ local command="cd \\\"$PWD\\\"; clear"
+ (( $# > 0 )) && command="${command}; $*"
+
+ local the_app=$(_omz_osx_get_frontmost_app)
+
+ if [[ "$the_app" == 'Terminal' ]]; then
+ # Discarding stdout to quash "tab N of window id XXX" output
+ osascript >/dev/null <<EOF
tell application "System Events"
tell process "Terminal" to keystroke "t" using command down
- tell application "Terminal" to do script "${command}" in front window
end tell
+ tell application "Terminal" to do script "${command}" in front window
EOF
- }
- [[ "$the_app" == 'iTerm' ]] && {
- osascript 2>/dev/null <<EOF
+ elif [[ "$the_app" == 'iTerm' ]]; then
+ osascript <<EOF
tell application "iTerm"
set current_terminal to current terminal
tell current_terminal
@@ -35,29 +41,27 @@ EOF
set current_session to current session
tell current_session
write text "${command}"
- keystroke return
end tell
end tell
end tell
EOF
- }
+
+ else
+ echo "tab: unsupported terminal app: $the_app"
+ false
+
+ fi
}
function vsplit_tab() {
- local command="cd \\\"$PWD\\\""
+ local command="cd \\\"$PWD\\\"; clear"
(( $# > 0 )) && command="${command}; $*"
- the_app=$(
- osascript 2>/dev/null <<EOF
- tell application "System Events"
- name of first item of (every process whose frontmost is true)
- end tell
-EOF
- )
+ local the_app=$(_omz_osx_get_frontmost_app)
- [[ "$the_app" == 'iTerm' ]] && {
- osascript 2>/dev/null <<EOF
- tell application "iTerm" to activate
+ if [[ "$the_app" == 'iTerm' ]]; then
+ osascript <<EOF
+ -- tell application "iTerm" to activate
tell application "System Events"
tell process "iTerm"
@@ -65,26 +69,24 @@ EOF
click
end tell
end tell
- keystroke "${command}; clear;"
- keystroke return
+ keystroke "${command} \n"
end tell
EOF
- }
+
+ else
+ echo "$0: unsupported terminal app: $the_app" >&2
+ false
+
+ fi
}
function split_tab() {
- local command="cd \\\"$PWD\\\""
+ local command="cd \\\"$PWD\\\"; clear"
(( $# > 0 )) && command="${command}; $*"
- the_app=$(
- osascript 2>/dev/null <<EOF
- tell application "System Events"
- name of first item of (every process whose frontmost is true)
- end tell
-EOF
- )
+ local the_app=$(_omz_osx_get_frontmost_app)
- [[ "$the_app" == 'iTerm' ]] && {
+ if [[ "$the_app" == 'iTerm' ]]; then
osascript 2>/dev/null <<EOF
tell application "iTerm" to activate
@@ -94,11 +96,15 @@ EOF
click
end tell
end tell
- keystroke "${command}; clear;"
- keystroke return
+ keystroke "${command} \n"
end tell
EOF
- }
+
+ else
+ echo "$0: unsupported terminal app: $the_app" >&2
+ false
+
+ fi
}
function pfd() {
diff --git a/plugins/rails/rails.plugin.zsh b/plugins/rails/rails.plugin.zsh
index 6824836fc..39e388494 100644
--- a/plugins/rails/rails.plugin.zsh
+++ b/plugins/rails/rails.plugin.zsh
@@ -54,10 +54,12 @@ alias rdrs='rake db:reset'
alias rdtc='rake db:test:clone'
alias rdtp='rake db:test:prepare'
alias rdmtc='rake db:migrate db:test:clone'
-
alias rlc='rake log:clear'
alias rn='rake notes'
alias rr='rake routes'
+alias rrg='rake routes | grep'
+alias rt='rake test'
+
# legacy stuff
alias sstat='thin --stats "/thin/stats" start'
diff --git a/plugins/scw/README.md b/plugins/scw/README.md
new file mode 100644
index 000000000..d2312c2e5
--- /dev/null
+++ b/plugins/scw/README.md
@@ -0,0 +1,7 @@
+## Scaleway CLI autocomplete plugin
+
+[scw](https://github.com/scaleway/scaleway-cli): Manage Bare Metal servers from Command Line (as easily as with Docker)
+
+- Adds autocomplete options for all `scw` commands.
+
+Maintainer : Manfred Touron ([@moul](https://github.com/moul))
diff --git a/plugins/scw/_scw b/plugins/scw/_scw
new file mode 100644
index 000000000..f9fdf916e
--- /dev/null
+++ b/plugins/scw/_scw
@@ -0,0 +1,333 @@
+#compdef scw
+#
+# zsh completion for scw (http://scaleway.com)
+#
+# Inspired by https://github.com/felixr/docker-zsh-completion
+
+__scw_get_servers() {
+ local expl
+ declare -a servers
+ servers=(${(f)"$(_call_program commands scw _completion servers-names)"})
+ _describe -t servers "servers" servers
+}
+
+__scw_stoppedservers() {
+ __scw_get_servers
+}
+
+__scw_runningservers() {
+ __scw_get_servers
+}
+
+__scw_servers () {
+ __scw_get_servers
+}
+
+__scw_images () {
+ local expl
+ declare -a images
+ images=(${(f)"$(_call_program commands scw _completion images-names)"})
+ _describe -t images "images" images
+}
+
+__scw_images_and_snapshots () {
+ __scw_images
+ __scw_snapshots
+}
+
+__scw_snapshots () {
+ local expl
+ declare -a snapshots
+ snapshots=(${(f)"$(_call_program commands scw _completion --prefix snapshots-names)"})
+ _describe -t snapshots "snapshots" snapshots
+}
+
+__scw_bootscripts () {
+ local expl
+ declare -a bootscripts
+ bootscripts=(${(f)"$(_call_program commands scw _completion bootscripts-names)"})
+ _describe -t bootscripts "bootscripts" bootscripts
+}
+
+__scw_tags() {
+ __scw_images
+}
+
+__scw_repositories_with_tags() {
+ __scw_images
+}
+
+__scw_search() {
+ # declare -a scwsearch
+ local cache_policy
+ zstyle -s ":completion:${curcontext}:" cache-policy cache_policy
+ if [[ -z "$cache_policy" ]]; then
+ zstyle ":completion:${curcontext}:" cache-policy __scw_caching_policy
+ fi
+
+ local searchterm cachename
+ searchterm="${words[$CURRENT]%/}"
+ cachename=_scw-search-$searchterm
+
+ local expl
+ local -a result
+ if ( [[ ${(P)+cachename} -eq 0 ]] || _cache_invalid ${cachename#_} ) \
+ && ! _retrieve_cache ${cachename#_}; then
+ _message "Searching for ${searchterm}..."
+ result=(${${${(f)"$(_call_program commands scw search ${searchterm})"}%% *}[2,-1]})
+ _store_cache ${cachename#_} result
+ fi
+ _wanted scwsearch expl 'available images' compadd -a result
+}
+
+__scw_caching_policy()
+{
+ oldp=( "$1"(Nmh+1) ) # 1 hour
+ (( $#oldp ))
+}
+
+
+__scw_repositories () {
+ __scw_images
+}
+
+__scw_commands () {
+ # local -a _scw_subcommands
+ local cache_policy
+
+ zstyle -s ":completion:${curcontext}:" cache-policy cache_policy
+ if [[ -z "$cache_policy" ]]; then
+ zstyle ":completion:${curcontext}:" cache-policy __scw_caching_policy
+ fi
+
+ if ( [[ ${+_scw_subcommands} -eq 0 ]] || _cache_invalid scw_subcommands) \
+ && ! _retrieve_cache scw_subcommands;
+ then
+ local -a lines
+ lines=(${(f)"$(_call_program commands scw 2>&1)"})
+ _scw_subcommands=(${${${lines[$((${lines[(i)Commands:]} + 1)),${lines[(I) *]}]}## #}/ ##/:})
+ _scw_subcommands=($_scw_subcommands 'help:Show help for a command')
+ _store_cache scw_subcommands _scw_subcommands
+ fi
+ _describe -t scw-commands "scw command" _scw_subcommands
+}
+
+__scw_subcommand () {
+ local -a _command_args
+ case "$words[1]" in
+ (attach)
+ _arguments \
+ '--no-stdin[Do not attach stdin]' \
+ ':servers:__scw_runningservers'
+ ;;
+ (commit)
+ _arguments \
+ {-v,--volume=0}'[Volume slot]:volume: ' \
+ ':server:__scw_servers' \
+ ':repository:__scw_repositories_with_tags'
+ ;;
+ (cp)
+ _arguments \
+ ':server:->server' \
+ ':hostpath:_files'
+ case $state in
+ (server)
+ if compset -P '*:'; then
+ _files
+ else
+ __scw_servers -qS ":"
+ fi
+ ;;
+ esac
+ ;;
+ (exec)
+ local state ret
+ _arguments \
+ {-T,--timeout=0}'[Set timeout values to seconds]' \
+ {-w,--wait}'[Wait for SSH to be ready]' \
+ ':servers:__scw_runningservers' \
+ '*::command:->anycommand' && ret=0
+
+ case $state in
+ (anycommand)
+ shift 1 words
+ (( CURRENT-- ))
+ _normal
+ ;;
+ esac
+
+ return ret
+ ;;
+ (history)
+ _arguments \
+ '--no-trunc[Do not truncate output]' \
+ {-q,--quiet}'[Only show numeric IDs]' \
+ '*:images:__scw_images'
+ ;;
+ (images)
+ _arguments \
+ {-a,--all}'[Show all images]' \
+ '--no-trunc[Do not truncate output]' \
+ {-q,--quiet}'[Only show numeric IDs]' \
+ ':repository:__scw_repositories'
+ ;;
+ (info)
+ ;;
+ (inspect)
+ _arguments \
+ {-f,--format=-}'[Format the output using the given go template]:template: ' \
+ '*:servers:__scw_servers'
+ ;;
+ (kill)
+ _arguments \
+ '*:servers:__scw_runningservers'
+ ;;
+ (login)
+ _arguments \
+ {-o,--organization=-}'[Organization]:organization: ' \
+ {-t,--token=-}'[Token]:token: ' \
+ ':server: '
+ ;;
+ (logout)
+ _arguments \
+ ':server: '
+ ;;
+ (logs)
+ _arguments \
+ '*:servers:__scw_servers'
+ ;;
+ (port)
+ _arguments \
+ '1:servers:__scw_runningservers' \
+ '2:port:_ports'
+ ;;
+ (start)
+ _arguments \
+ {-T,--timeout=0}'[Set timeout values to seconds]' \
+ {-w,--wait}'[Wait for SSH to be ready]' \
+ '*:servers:__scw_stoppedservers'
+ ;;
+ (rm)
+ _arguments \
+ '*:servers:__scw_stoppedservers'
+ ;;
+ (rmi)
+ _arguments \
+ '*:images:__scw_images'
+ ;;
+ (restart)
+ _arguments \
+ '*:servers:__scw_runningservers'
+ ;;
+ (stop)
+ _arguments \
+ {-t,--terminate}'[Stop and trash a server with its volumes]' \
+ {-w,--wait}'[Synchronous stop. Wait for server to be stopped]' \
+ '*:servers:__scw_runningservers'
+ ;;
+ (top)
+ _arguments \
+ '1:servers:__scw_runningservers' \
+ '(-)*:: :->ps-arguments'
+ case $state in
+ (ps-arguments)
+ _ps
+ ;;
+ esac
+ ;;
+ (ps)
+ _arguments \
+ {-a,--all}'[Show all servers. Only running servers are shown by default]' \
+ {-l,--latest}'[Show only the latest created server]' \
+ '-n[Show n last created servers, include non-running one]:n:(1 5 10 25 50)' \
+ '--no-trunc[Do not truncate output]' \
+ {-q,--quiet}'[Only show numeric IDs]'
+ ;;
+ (tag)
+ _arguments \
+ {-f,--force}'[force]'\
+ ':image:__scw_images'\
+ ':repository:__scw_repositories_with_tags'
+ ;;
+ (create|run)
+ _arguments \
+ {-a,--attach}'[Attach to stdin, stdout or stderr]' \
+ '*'{-e,--environment=-}'[Set environment variables]:environment variable: ' \
+ '--name=-[Server name]:name: ' \
+ '--bootscript=-[Assign a bootscript]:bootscript:__scw_bootscripts ' \
+ '*-v[Bind mount a volume]:volume: '\
+ '(-):images:__scw_images_and_snapshots' \
+ '(-):command: _command_names -e' \
+ '*::arguments: _normal'
+
+ case $state in
+ (link)
+ if compset -P '*:'; then
+ _wanted alias expl 'Alias' compadd -E ""
+ else
+ __scw_runningservers -qS ":"
+ fi
+ ;;
+ esac
+ ;;
+ (rename)
+ _arguments \
+ ':old name:__scw_servers' \
+ ':new name: '
+ ;;
+ (search)
+ _arguments \
+ '--no-trunc[Do not truncate output]' \
+ ':term: '
+ ;;
+ (wait)
+ _arguments '*:servers:__scw_runningservers'
+ ;;
+ (help)
+ _arguments ':subcommand:__scw_commands'
+ ;;
+ (*)
+ _message 'Unknown sub command'
+ esac
+
+}
+
+_scw () {
+ # Support for subservices, which allows for `compdef _scw scw-shell=_scw_servers`.
+ # Based on /usr/share/zsh/functions/Completion/Unix/_git without support for `ret`.
+ if [[ $service != scw ]]; then
+ _call_function - _$service
+ return
+ fi
+
+ local curcontext="$curcontext" state line
+ typeset -A opt_args
+
+ _arguments -C \
+ '-H[tcp://host:port to bind/connect to]:socket: ' \
+ '(-): :->command' \
+ '(-)*:: :->option-or-argument'
+
+ if (( CURRENT == 1 )); then
+
+ fi
+ case $state in
+ (command)
+ __scw_commands
+ ;;
+ (option-or-argument)
+ curcontext=${curcontext%:*:*}:scw-$words[1]:
+ __scw_subcommand
+ ;;
+ esac
+}
+
+_scw "$@"
+
+# Local Variables:
+# mode: Shell-Script
+# sh-indentation: 4
+# indent-tabs-mode: nil
+# sh-basic-offset: 4
+# End:
+# vim: ft=zsh sw=4 ts=4 et
diff --git a/plugins/sudo/sudo.plugin.zsh b/plugins/sudo/sudo.plugin.zsh
index e3ba39918..0ba8bed5b 100644
--- a/plugins/sudo/sudo.plugin.zsh
+++ b/plugins/sudo/sudo.plugin.zsh
@@ -14,7 +14,11 @@
sudo-command-line() {
[[ -z $BUFFER ]] && zle up-history
- [[ $BUFFER != sudo\ * ]] && LBUFFER="sudo $LBUFFER"
+ if [[ $BUFFER == sudo\ * ]]; then
+ LBUFFER="${LBUFFER#sudo }"
+ else
+ LBUFFER="sudo $LBUFFER"
+ fi
}
zle -N sudo-command-line
# Defined shortcut keys: [Esc] [Esc]
diff --git a/plugins/svn/svn.plugin.zsh b/plugins/svn/svn.plugin.zsh
index 9f7a4c6eb..816055afe 100644
--- a/plugins/svn/svn.plugin.zsh
+++ b/plugins/svn/svn.plugin.zsh
@@ -1,16 +1,17 @@
# vim:ft=zsh ts=2 sw=2 sts=2
#
function svn_prompt_info() {
+ local _DISPLAY
if in_svn; then
if [ "x$SVN_SHOW_BRANCH" = "xtrue" ]; then
unset SVN_SHOW_BRANCH
_DISPLAY=$(svn_get_branch_name)
else
_DISPLAY=$(svn_get_repo_name)
+ _DISPLAY=$(omz_urldecode "${_DISPLAY}")
fi
echo "$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_SVN_PROMPT_PREFIX\
$ZSH_THEME_REPO_NAME_COLOR$_DISPLAY$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_SVN_PROMPT_SUFFIX$ZSH_PROMPT_BASE_COLOR$(svn_dirty)$(svn_dirty_pwd)$ZSH_PROMPT_BASE_COLOR"
- unset _DISPLAY
fi
}
@@ -30,7 +31,7 @@ function svn_get_repo_name() {
}
function svn_get_branch_name() {
- _DISPLAY=$(
+ local _DISPLAY=$(
svn info 2> /dev/null | \
awk -F/ \
'/^URL:/ { \
@@ -49,7 +50,6 @@ function svn_get_branch_name() {
else
echo $_DISPLAY
fi
- unset _DISPLAY
}
function svn_get_rev_nr() {
@@ -60,7 +60,7 @@ function svn_get_rev_nr() {
function svn_dirty_choose() {
if in_svn; then
- root=`svn info 2> /dev/null | sed -n 's/^Working Copy Root Path: //p'`
+ local root=`svn info 2> /dev/null | sed -n 's/^Working Copy Root Path: //p'`
if $(svn status $root 2> /dev/null | command grep -Eq '^\s*[ACDIM!?L]'); then
# Grep exits with 0 when "One or more lines were selected", return "dirty".
echo $1
@@ -77,7 +77,7 @@ function svn_dirty() {
function svn_dirty_choose_pwd () {
if in_svn; then
- root=$PWD
+ local root=$PWD
if $(svn status $root 2> /dev/null | command grep -Eq '^\s*[ACDIM!?L]'); then
# Grep exits with 0 when "One or more lines were selected", return "dirty".
echo $1
diff --git a/plugins/taskwarrior/README.md b/plugins/taskwarrior/README.md
new file mode 100644
index 000000000..053151e78
--- /dev/null
+++ b/plugins/taskwarrior/README.md
@@ -0,0 +1,13 @@
+# taskwarrior
+
+This plugin adds smart tab completion for [TaskWarrior](http://taskwarrior.org/).
+It uses the zsh tab completion script (`_task`) shipped with TaskWarrior for the
+completion definitions.
+
+The latest version pulled in from the official project is of January 1st, 2015.
+
+
+## Examples
+
+Typing `task [TAB]` will give you a list of commands, `task 66[TAB]` shows a
+list of available modifications for that task, etcetera.
diff --git a/plugins/taskwarrior/_task b/plugins/taskwarrior/_task
index 5cc253152..afa30d45a 100644
--- a/plugins/taskwarrior/_task
+++ b/plugins/taskwarrior/_task
@@ -1,9 +1,6 @@
#compdef task
-# zsh completion for taskwarrior
#
-# taskwarrior - a command line task list manager.
-#
-# Copyright 2010 - 2011 Johannes Schlatow
+# Copyright 2010 - 2015 Johannes Schlatow
# Copyright 2009 P.C. Shyamshankar
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -30,31 +27,40 @@ typeset -g _task_cmds _task_projects _task_tags _task_config _task_modifiers
_task_projects=($(task _projects))
_task_tags=($(task _tags))
_task_ids=($(task _ids))
+_task_zshids=( ${(f)"$(task _zshids)"} )
_task_config=($(task _config))
_task_columns=($(task _columns))
_task_modifiers=(
- 'before' \
- 'after' \
- 'none' \
- 'any' \
- 'is' \
- 'isnt' \
- 'has' \
- 'hasnt' \
- 'startswith' \
- 'endswith' \
- 'word' \
- 'noword'
+ 'before' \
+ 'after' \
+ 'none' \
+ 'any' \
+ 'is' \
+ 'isnt' \
+ 'has' \
+ 'hasnt' \
+ 'startswith' \
+ 'endswith' \
+ 'word' \
+ 'noword'
)
_task_conjunctions=(
- 'and' \
- 'or' \
- 'xor' \
- '\)'
- '\('
+ 'and' \
+ 'or' \
+ 'xor' \
+ '\)' \
+ '\(' \
+ '<' \
+ '<=' \
+ '=' \
+ '!=' \
+ '>=' \
+ '>'
)
-_task_cmds=($(task _commands))
-_task_zshcmds=( ${(f)"$(task _zshcommands)"} )
+_task_cmds=($(task _commands; task _aliases))
+_task_zshcmds=( ${(f)"$(task _zshcommands)"} sentinel:sentinel:sentinel )
+
+_task_aliases=($(task _aliases))
_task() {
_arguments -s -S \
@@ -68,110 +74,130 @@ word=$'[^\0]#\0'
# priorities
local -a task_priorities
_regex_words values 'task priorities' \
- 'H:High' \
- 'M:Middle' \
- 'L:Low'
+ 'H:High' \
+ 'M:Middle' \
+ 'L:Low'
task_priorities=("$reply[@]")
# projects
local -a task_projects
task_projects=(
- /"$word"/
- ":values:task projects:compadd -a _task_projects"
+ /"$word"/
+ ":values:task projects:compadd -a _task_projects"
)
local -a _task_dates
_regex_words values 'task dates' \
- 'tod*ay:Today' \
- 'yes*terday:Yesterday' \
- 'tom*orrow:Tomorrow' \
- 'sow:Start of week' \
- 'soww:Start of work week' \
- 'socw:Start of calendar week' \
- 'som:Start of month' \
- 'soy:Start of year' \
- 'eow:End of week' \
- 'eoww:End of work week' \
- 'eocw:End of calendar week' \
- 'eom:End of month' \
- 'eoy:End of year' \
- 'mon:Monday' \
- 'tue:Tuesday'\
- 'wed:Wednesday' \
- 'thu:Thursday' \
- 'fri:Friday' \
- 'sat:Saturday' \
- 'sun:Sunday'
+ 'tod*ay:Today' \
+ 'yes*terday:Yesterday' \
+ 'tom*orrow:Tomorrow' \
+ 'sow:Start of week' \
+ 'soww:Start of work week' \
+ 'socw:Start of calendar week' \
+ 'som:Start of month' \
+ 'soq:Start of quarter' \
+ 'soy:Start of year' \
+ 'eow:End of week' \
+ 'eoww:End of work week' \
+ 'eocw:End of calendar week' \
+ 'eom:End of month' \
+ 'eoq:End of quarter' \
+ 'eoy:End of year' \
+ 'mon:Monday' \
+ 'tue:Tuesday'\
+ 'wed:Wednesday' \
+ 'thu:Thursday' \
+ 'fri:Friday' \
+ 'sat:Saturday' \
+ 'sun:Sunday' \
+ 'good*friday:Good Friday' \
+ 'easter:Easter' \
+ 'eastermonday:Easter Monday' \
+ 'ascension:Ascension' \
+ 'pentecost:Pentecost' \
+ 'midsommar:Midsommar' \
+ 'midsommarafton:Midsommarafton' \
+ 'later:Later' \
+ 'someday:Some Day'
_task_dates=("$reply[@]")
local -a _task_reldates
_regex_words values 'task reldates' \
- 'hrs:n hours' \
- 'day:n days' \
- '1st:first' \
- '2nd:second' \
- '3rd:third' \
- 'th:4th, 5th, etc.' \
- 'wks:weeks'
+ 'hrs:n hours' \
+ 'day:n days' \
+ '1st:first' \
+ '2nd:second' \
+ '3rd:third' \
+ 'th:4th, 5th, etc.' \
+ 'wks:weeks'
_task_reldates=("$reply[@]")
task_dates=(
- \( "$_task_dates[@]" \|
+ \( "$_task_dates[@]" \|
\( /$'[0-9][0-9]#'/- \( "$_task_reldates[@]" \) \)
- \)
+ \)
)
+local -a task_zshids
+_regex_words values 'task IDs' $_task_zshids
+task_zshids=("$reply[@]")
+
_regex_words values 'task frequencies' \
- 'daily:Every day' \
- 'day:Every day' \
- 'weekdays:Every day skipping weekend days' \
- 'weekly:Every week' \
- 'biweekly:Every two weeks' \
- 'fortnight:Every two weeks' \
-+ 'monthly:Every month' \
- 'quarterly:Every three months' \
- 'semiannual:Every six months' \
- 'annual:Every year' \
- 'yearly:Every year' \
- 'biannual:Every two years' \
- 'biyearly:Every two years'
+ 'daily:Every day' \
+ 'day:Every day' \
+ 'weekdays:Every day skipping weekend days' \
+ 'weekly:Every week' \
+ 'biweekly:Every two weeks' \
+ 'fortnight:Every two weeks' \
+ 'monthly:Every month' \
+ 'quarterly:Every three months' \
+ 'semiannual:Every six months' \
+ 'annual:Every year' \
+ 'yearly:Every year' \
+ 'biannual:Every two years' \
+ 'biyearly:Every two years'
_task_freqs=("$reply[@]")
local -a _task_frequencies
_regex_words values 'task frequencies' \
- 'd:days' \
- 'w:weeks' \
- 'q:quarters' \
- 'y:years'
+ 'd:days' \
+ 'w:weeks' \
+ 'q:quarters' \
+ 'y:years'
_task_frequencies=("$reply[@]")
task_freqs=(
- \( "$_task_freqs[@]" \|
+ \( "$_task_freqs[@]" \|
\( /$'[0-9][0-9]#'/- \( "$_task_frequencies[@]" \) \)
- \)
+ \)
)
# attributes
local -a task_attributes
_regex_words -t ':' default 'task attributes' \
- 'pro*ject:Project name:$task_projects' \
- 'du*e:Due date:$task_dates' \
- 'wa*it:Date until task becomes pending:$task_dates' \
- 're*cur:Recurrence frequency:$task_freqs' \
- 'pri*ority:priority:$task_priorities' \
- 'un*til:Recurrence end date:$task_dates' \
- 'fg:Foreground color' \
- 'bg:Background color' \
- 'li*mit:Desired number of rows in report'
+ 'des*cription:Task description text' \
+ 'status:Status of task - pending, completed, deleted, waiting' \
+ 'pro*ject:Project name:$task_projects' \
+ 'pri*ority:priority:$task_priorities' \
+ 'du*e:Due date:$task_dates' \
+ 're*cur:Recurrence frequency:$task_freqs' \
+ 'un*til:Expiration date:$task_dates' \
+ 'li*mit:Desired number of rows in report' \
+ 'wa*it:Date until task becomes pending:$task_dates' \
+ 'ent*ry:Date task was created:$task_dates' \
+ 'end:Date task was completed/deleted:$task_dates' \
+ 'st*art:Date task was started:$task_dates' \
+ 'sc*heduled:Date task is scheduled to start:$task_dates' \
+ 'dep*ends:Other tasks that this task depends upon:$task_zshids'
task_attributes=("$reply[@]")
args=(
- \( "$task_attributes[@]" \|
- \( /'(project|due|wait|recur|priority|until|fg|bg|limit).'/- \( /$'[^:]#:'/ ":default:modifiers:compadd -S ':' -a _task_modifiers" \) \) \|
- \( /'(rc).'/- \( /$'[^:]#:'/ ":arguments:config:compadd -S ':' -a _task_config" \) \) \|
- \( /'(+|-)'/- \( /"$word"/ ":values:remove tag:compadd -a _task_tags" \) \) \|
- \( /"$word"/ \)
- \) \#
+ \( "$task_attributes[@]" \|
+ \( /'(project|description|status|entry|end|start|scheduled|depends|due|wait|recur|priority|until|limit).'/- \( /$'[^:]#:'/ ":default:modifiers:compadd -S ':' -a _task_modifiers" \) \) \|
+ \( /'(rc).'/- \( /$'[^:]#:'/ ":arguments:config:compadd -S ':' -a _task_config" \) \) \|
+ \( /'(+|-)'/- \( /"$word"/ ":values:remove tag:compadd -a _task_tags" \) \) \|
+ \( /"$word"/ \)
+ \) \#
)
_regex_arguments _task_attributes "${args[@]}"
@@ -180,43 +206,50 @@ _regex_arguments _task_attributes "${args[@]}"
# filter completion
(( $+functions[_task_filter] )) ||
_task_filter() {
- _task_attributes "$@"
-
- # TODO complete conjunctions only if the previous word is a filter expression, i.e. attribute, ID, any non-command
- _describe -t default 'task conjunctions' _task_conjunctions
-}
-
-# merge completion
-(( $+functions[_task_merge] )) ||
-_task_merge() {
- # TODO match URIs in .taskrc
- _files
-}
-
-# push completion
-(( $+functions[_task_push] )) ||
-_task_push() {
- # TODO match URIs in .taskrc
- _files
-}
+ _task_attributes "$@"
-# pull completion
-(( $+functions[_task_pull] )) ||
-_task_pull() {
- # TODO match URIs in .taskrc
- _files
+ # TODO complete conjunctions only if the previous word is a filter expression, i.e. attribute, ID, any non-command
+ _describe -t default 'task conjunctions' _task_conjunctions
}
# execute completion
(( $+functions[_task_execute] )) ||
_task_execute() {
- _files
+ _files
}
# id-only completion
(( $+functions[_task_id] )) ||
_task_id() {
- _describe -t values 'task IDs' _task_zshids
+ _describe -t values 'task IDs' _task_zshids
+}
+
+# subcommand-only function
+(( $+functions[_task_subcommands] )) ||
+_task_subcommands() {
+ local -a subcommands
+ local _zshcmd
+ local cmd category desc
+ local lastcategory=''
+ # The list is sorted by category, in the right order.
+ for _zshcmd in "$_task_zshcmds[@]"; do
+ # Parse out the three fields
+ cmd=${_zshcmd%%:*}
+ category=${${_zshcmd#*:}%%:*}
+ desc=${_zshcmd#*:*:}
+
+ # Present each category as soon as the first entry in the *next* category
+ # is seen.
+ if [[ $category != $lastcategory && -n $lastcategory ]]; then
+ _describe -t ${lastcategory}-commands "task ${lastcategory} command" subcommands
+ subcommands=()
+ fi
+
+ # Log the subcommand; we will process it in some future iteration.
+ subcommands+=( "$cmd:$desc" )
+
+ lastcategory=$category
+ done
}
## first level completion => task sub-command completion
@@ -224,27 +257,28 @@ _task_id() {
_task_default() {
local cmd ret=1
- integer i=1
- while (( i < $#words ))
- do
- cmd="${_task_cmds[(r)$words[$i]]}"
- if (( $#cmd )); then
- _call_function ret _task_${cmd} ||
- _call_function ret _task_filter ||
- _message "No command remaining."
- return ret
- fi
- (( i++ ))
- done
-
- # update IDs
- _task_zshids=( ${(f)"$(task _zshids)"} )
-
- _describe -t commands 'task command' _task_zshcmds
- _describe -t values 'task IDs' _task_zshids
- _call_function ret _task_filter
-
- return ret
+ integer i=1
+ while (( i < $#words ))
+ do
+ cmd="${_task_cmds[(r)$words[$i]]}"
+ if (( $#cmd )); then
+ _call_function ret _task_${cmd} ||
+ _call_function ret _task_filter ||
+ _message "No command remaining."
+ return ret
+ fi
+ (( i++ ))
+ done
+
+ # update IDs
+ _task_zshids=( ${(f)"$(task _zshids)"} )
+
+ _task_subcommands
+ _describe -t tasks 'task IDs' _task_zshids
+ _describe -t aliases 'task aliases' _task_aliases
+ _call_function ret _task_filter
+
+ return ret
}
-_task
+_task "$@"
diff --git a/plugins/taskwarrior/taskwarrior.plugin.zsh b/plugins/taskwarrior/taskwarrior.plugin.zsh
index 5d1e6ffea..ab885943f 100644
--- a/plugins/taskwarrior/taskwarrior.plugin.zsh
+++ b/plugins/taskwarrior/taskwarrior.plugin.zsh
@@ -1,17 +1,3 @@
-################################################################################
-# Author: Pete Clark
-# Email: pete[dot]clark[at]gmail[dot]com
-# Version: 0.1 (05/24/2011)
-# License: WTFPL<http://sam.zoy.org/wtfpl/>
-#
-# This oh-my-zsh plugin adds smart tab completion for
-# TaskWarrior<http://taskwarrior.org/>. It uses the zsh tab completion
-# script (_task) distributed with TaskWarrior for the completion definitions.
-#
-# Typing task [tabtab] will give you a list of current tasks, task 66[tabtab]
-# gives a list of available modifications for that task, etc.
-################################################################################
-
zstyle ':completion:*:*:task:*' verbose yes
zstyle ':completion:*:*:task:*:descriptions' format '%U%B%d%b%u'
diff --git a/plugins/terminalapp/terminalapp.plugin.zsh b/plugins/terminalapp/terminalapp.plugin.zsh
index 6e47ee188..7c0c278b9 100644
--- a/plugins/terminalapp/terminalapp.plugin.zsh
+++ b/plugins/terminalapp/terminalapp.plugin.zsh
@@ -1,39 +1,6 @@
-# Set Apple Terminal.app resume directory
-# based on this answer: http://superuser.com/a/315029
-# 2012-10-26: (javageek) Changed code using the updated answer
-
-# Tell the terminal about the working directory whenever it changes.
-if [[ "$TERM_PROGRAM" == "Apple_Terminal" ]] && [[ -z "$INSIDE_EMACS" ]]; then
- update_terminal_cwd() {
- # Identify the directory using a "file:" scheme URL, including
- # the host name to disambiguate local vs. remote paths.
-
- # Percent-encode the pathname.
- local URL_PATH=''
- {
- # Use LANG=C to process text byte-by-byte.
- local i ch hexch LANG=C
- for ((i = 1; i <= ${#PWD}; ++i)); do
- ch="$PWD[i]"
- if [[ "$ch" =~ [/._~A-Za-z0-9-] ]]; then
- URL_PATH+="$ch"
- else
- hexch=$(printf "%02X" "'$ch")
- URL_PATH+="%$hexch"
- fi
- done
- }
-
- local PWD_URL="file://$HOST$URL_PATH"
- #echo "$PWD_URL" # testing
- printf '\e]7;%s\a' "$PWD_URL"
- }
-
- # Register the function so it is called whenever the working
- # directory changes.
- autoload add-zsh-hook
- add-zsh-hook precmd update_terminal_cwd
-
- # Tell the terminal about the initial directory.
- update_terminal_cwd
-fi
+# This file is intentionally empty.
+#
+# The terminalapp plugin is deprecated and may be removed in a future release.
+# Its functionality has been folded in to the core lib/termsupport.zsh, which
+# is loaded for all users. You can remove terminalapp from your $plugins list
+# once all your systems are updated to the current version of Oh My Zsh.
diff --git a/plugins/vagrant/_vagrant b/plugins/vagrant/_vagrant
index 76f80b0d7..764f89545 100644
--- a/plugins/vagrant/_vagrant
+++ b/plugins/vagrant/_vagrant
@@ -1,4 +1,4 @@
-#compdef vagrant
+#compdef vagrant
#autoload
# vagrant zsh completion
@@ -6,37 +6,45 @@
local -a _1st_arguments
_1st_arguments=(
'box:Box commands'
- 'connect:Connects to a shared, remote Vagrant environment'
+ 'connect:Connects to a remotely shared Vagrant environment'
'destroy:Destroys the vagrant environment'
- 'docker-logs:Shows Docker logs'
- 'docker-run:Run one-off commands against a Docker container'
+ 'docker-logs:Outputs the logs from the Docker container'
+ 'docker-run:Run a one-off command in the context of a container'
'global-status:Reports the status of all active Vagrant environments on the system'
'halt:Halts the currently running vagrant environment'
+ 'help:Shows the help for a subcommand'
'init:[box_name] [box_url] Initializes current folder for Vagrant usage'
+ 'list-commands:Outputs all available Vagrant subcommands, even non-primary ones'
'login:Authenticates against a Vagrant Cloud server to access protected boxes'
'package:Packages a vagrant environment for distribution'
'plugin:Plugin commands'
'provision:Run the provisioner'
+ 'push:Deploys code in this environment to a configured destination'
+ 'rdp:Connects to machine via RDP'
'reload:Reload the vagrant environment'
'resume:Resumes a suspend vagrant environment'
- 'share:Shares the Vagrant environment and allows remote access'
+ 'rsync:Syncs rsync synced folders to remote machine'
+ 'rsync-auto:Syncs rsync synced folders automatically when files change'
+ 'share:Shares your Vagrant environment with anyone in the world'
'ssh:SSH into the currently running environment'
- 'ssh-config:outputs .ssh/config valid syntax for connecting to this environment via ssh'
+ 'ssh-config:Outputs .ssh/config valid syntax for connecting to this environment via ssh'
'status:Shows the status of the current Vagrant environment'
'suspend:Suspends the currently running vagrant environment'
'up:Creates the vagrant environment'
- 'version:Prints the currently installed Vagrant version and checks for new updates'
+ 'version:Prints current and latest Vagrant version'
'--help:[TASK] Describe available tasks or one specific task'
'--version:Prints the Vagrant version information'
)
local -a _box_arguments
_box_arguments=(
- 'add:NAME URI Add a box to the system'
- 'help:COMMAND Describe subcommands or one specific subcommand'
+ 'add:ADDRESS Adds a box to the system'
+ 'help:COMMAND List subcommands'
'list:Lists all installed boxes'
- 'remove:NAME Remove a box from the system'
- 'repackage:NAME Repackage an installed box into a `.box` file.'
+ 'outdated:Checks if a box has newer version'
+ 'remove:NAME Removes a box from the system'
+ 'repackage:NAME PROVIDER VERSION Repackages an installed box into a `.box` file'
+ 'update:Updates box to a newer version, if available'
)
__task_list ()
@@ -78,7 +86,7 @@ __vagrant-box ()
(options)
case $line[1] in
(repackage|remove)
- _arguments ':feature:__box_list'
+ _arguments ':feature:__box_list'
;;
esac
;;
@@ -107,14 +115,14 @@ case $state in
(options)
case $line[1] in
(help)
- _arguments ':feature:__task_list'
+ _arguments ':feature:__task_list'
;;
(box)
__vagrant-box
;;
(up|provision|package|destroy|reload|ssh|ssh-config|halt|resume|status)
- _arguments ':feature:__vm_list'
+ _arguments ':feature:__vm_list'
esac
;;
esac
diff --git a/plugins/vim-interaction/vim-interaction.plugin.zsh b/plugins/vim-interaction/vim-interaction.plugin.zsh
index b0b9414cd..b774be342 100644
--- a/plugins/vim-interaction/vim-interaction.plugin.zsh
+++ b/plugins/vim-interaction/vim-interaction.plugin.zsh
@@ -4,17 +4,6 @@
# Derek Wyatt (derek@{myfirstnamemylastname}.org
#
-function resolveFile
-{
- if [ -f "$1" ]; then
- echo $(readlink -f "$1")
- elif [[ "${1#/}" == "$1" ]]; then
- echo "$PWD/$1"
- else
- echo $1
- fi
-}
-
function callvim
{
if [[ $# == 0 ]]; then
@@ -48,13 +37,10 @@ EOH
if [[ ${before#:} != $before && ${before%<cr>} == $before ]]; then
before="$before<cr>"
fi
- local files=""
- for f in $@
- do
- files="$files $(resolveFile $f)"
- done
- if [[ -n $files ]]; then
- files=':args! '"$files<cr>"
+ local files
+ if [[ $# -gt 0 ]]; then
+ # absolute path of files resolving symlinks (:A) and quoting special chars (:q)
+ files=':args! '"${@:A:q}<cr>"
fi
cmd="$before$files$after"
gvim --remote-send "$cmd"
diff --git a/plugins/xcode/README.md b/plugins/xcode/README.md
new file mode 100644
index 000000000..15e657859
--- /dev/null
+++ b/plugins/xcode/README.md
@@ -0,0 +1,84 @@
+# Xcode
+
+## Description
+
+This plugin provides a few utilities that can help you on your daily use of Xcode and iOS development.
+
+To start using it, add the `xcode` plugin to your `plugins` array in `~/.zshrc`:
+
+```zsh
+plugins=(... xcode)
+```
+
+
+## Aliases
+
+| Alias | Description | Command |
+|-------|------------------------------------------|------------------------------------------------|
+| xcb | Build Xcode projects and workspaces | xcodebuild |
+| xcdd | Purge all temporary build information | rm -rf ~/Library/Developer/Xcode/DerivedData/* |
+| xcp | Show currently selected Xcode directory | xcode-select --print-path |
+| xcsel | Select different Xcode directory by path | sudo xcode-select --switch |
+
+
+
+## Functions
+
+### `xc`
+
+Opens the current directory in Xcode as an Xcode project. This will open one of the `.xcworkspace` and `.xcodeproj` files that it can find in the current working directory.
+Returns 1 if it didn't find any relevant files.
+
+### `simulator`
+
+Opens the iOS Simulator from your command line, dependent on whichever is the active developer directory for Xcode. (That is, it respects the `xcsel` setting.)
+
+### `xcselv`
+
+Selects different Xcode installations by version name. This is like `xcsel`, except it takes just a version name as an argument instead of the full path to the Xcode installation. Uses the naming conventions described below.
+
+* `xcselv <version>` selects a version
+ * Example: `xcselv 6.2`
+* `xcselv default` selects the default unversioned `Applications/Xcode.app`
+* `xcselv` with no argument lists the available Xcode versions in a human-readable format
+* `xcselv -l` lists the installed Xcode versions
+* `xcselv -L` lists the installed Xcode versions in a short version-name-only format
+* `xcselv -p` prints info about the active Xcode version
+* `xcselv -h` prints a help message
+
+The option parsing for `xcselv` is naive. Options may not be combined, and only the first option is recognized.
+
+## Multiple Xcode Versions
+
+The `xcselv` command provides support for switching between different Xcode installations using just a version number. Different Xcode versions are identified by file naming conventions.
+
+### Versioned Xcode Naming Conventions
+
+Apple does not seem to explicitly define or provide tooling support for a naming convention or other organizational mechanism for managing versioned Xcode installations. Apple seems to have released beta versions with both `Xcode<version>.app` and `Xcode-<version>.app` style names in the past, and both styles show up in forum and blog discussions.
+
+We've adopted the following naming convention:
+
+* Versioned Xcode installations are identified by the name `Xcode-<version>` or `Xcode<version>`.
+* The `-` separating `"Xcode"` and the version name is optional, and may be replaced by a space.
+* The versioned name may be applied to the `Xcode.app` itself, or a subdirectory underneath `Applications/` containing it.
+* You cannot version both the `Xcode.app` filename itself and the containing subfolder.
+* Thus, all of the following are equivalent.
+ * `Applications/Xcode-<version>.app`
+ * `Applications/Xcode-<version>/Xcode.app`
+ * `Applications/Xcode<version>.app`
+ * `Applications/Xcode <version>.app`
+ * `Applications/Xcode <version>/Xcode.app`
+* Both the system `/Applications/` and user `$HOME/Applications/` directories are searched.
+ * The user's `$HOME/Applications/` takes precedence over `/Applications` for a given version.
+ * If multiple naming variants within the same `Applications/` folder indicate the same version (for example, `Xcode-3.2.1.app`, `Xcode3.2.1.app`, and `Xcode-3.2.1/Xcode.app`), the precedence order is unspecified and implementation-dependent.
+* The `<version>` may be any string that is valid in a filename.
+* The special version name `"default"` refers to the "default" unversioned Xcode at `Applications/Xcode.app` (in either `/Applications/` or `$HOME/Applications/`).
+* Version names may not start with ``"-"`` or whitespace.
+
+The restrictions on the naming convention may need to be tightened in the future. In particular, if there are other well-known applications whose names begin with the string `"Xcode"`, the strings allowed for `<version>` may need to be restricted to avoid colliding with other applications. If there's evidence that one of these naming techniques is strongly favored either in practice or by Apple, we may tighten the naming convention to favor it.
+
+## Caveats
+
+Using `xcsel` or `xcselv` to select an Xcode that is installed under your `$HOME` may break things for other users, depending on your system setup. We let you do this anyway because some people run OS X as effectively single-user, or have open permissions so this will work. You could also use `$DEVELOPER_DIR` as an alternative to `xcsel` that is scoped to the current user or session, instead of a global setting.
+
+This does not verify that the version name in the Xcode filename matches the actual version of that binary. It is the user's responsibility to get the names right.
diff --git a/plugins/xcode/_xcselv b/plugins/xcode/_xcselv
new file mode 100644
index 000000000..f9861d54b
--- /dev/null
+++ b/plugins/xcode/_xcselv
@@ -0,0 +1,19 @@
+#compdef xcselv
+#autoload
+
+function _xcselv_compl_list_versions() {
+ _omz_xcode_list_versions short
+}
+
+_arguments \
+ '(-l -L -p)-h[prints a help message]' \
+ '(-L -p -h)-l[lists installed Xcode versions]' \
+ '(-l -p -h)-L[lists installed Xcode versions (long form)]' \
+ '(-h -l -L)-p[prints active Xcode version]' \
+ && ret=0
+
+local _xcode_versions
+_xcode_versions=($(_xcselv_compl_list_versions))
+_describe -t _xcode_versions 'version' _xcode_versions
+
+return 1
diff --git a/plugins/xcode/xcode.plugin.zsh b/plugins/xcode/xcode.plugin.zsh
index 1d1205b80..b63a857a7 100644
--- a/plugins/xcode/xcode.plugin.zsh
+++ b/plugins/xcode/xcode.plugin.zsh
@@ -1,25 +1,185 @@
-#xc function courtesy of http://gist.github.com/subdigital/5420709
+alias xcb='xcodebuild'
+alias xcdd='rm -rf ~/Library/Developer/Xcode/DerivedData/*'
+alias xcp='xcode-select --print-path'
+alias xcsel='sudo xcode-select --switch'
+
+# original author: @subdigital
+# source: http://gist.github.com/subdigital/5420709
function xc {
- xcode_proj=`ls | grep "\.xc" | sort -r | head -1`
- if [[ `echo -n $xcode_proj | wc -m` == 0 ]]
- then
+ local xcode_proj
+ xcode_proj=(*.{xcworkspace,xcodeproj}(N))
+
+ if [[ ${#xcode_proj} -eq 0 ]]; then
echo "No xcworkspace/xcodeproj file found in the current directory."
+ return 1
else
- echo "Found $xcode_proj"
- open "$xcode_proj"
+ echo "Found ${xcode_proj[1]}"
+ open "${xcode_proj[1]}"
fi
}
-function xcsel {
- sudo xcode-select --switch "$*"
+# "XCode-SELect by Version" - select Xcode by just version number
+# Uses naming convention:
+# - different versions of Xcode are named Xcode-<version>.app or stored
+# in a folder named Xcode-<version>
+# - the special version name "default" refers to the "default" Xcode.app with no suffix
+function xcselv {
+ emulate -L zsh
+ if [[ $# == 0 ]]; then
+ echo "xcselv: error: no option or argument given" >&2
+ echo "xcselv: see 'xcselv -h' for help" >&2
+ return 1
+ elif [[ $1 == "-p" ]]; then
+ _omz_xcode_print_active_version
+ return
+ elif [[ $1 == "-l" ]]; then
+ _omz_xcode_list_versions
+ return
+ elif [[ $1 == "-L" ]]; then
+ _omz_xcode_list_versions short
+ return
+ elif [[ $1 == "-h" ]]; then
+ _omz_xcode_print_xcselv_usage
+ return 0
+ elif [[ $1 == -* && $1 != "-" ]]; then
+ echo "xcselv: error: unrecognized option: $1" >&2
+ echo "xcselv: see 'xcselv -h' for help" >&2
+ return 1
+ fi
+ # Main case: "xcselv <version>" to select a version
+ local version=$1
+ local -A xcode_versions
+ _omz_xcode_locate_versions
+ if [[ -z ${xcode_versions[$version]} ]]; then
+ echo "xcselv: error: Xcode version '$version' not found" >&2
+ return 1
+ fi
+ app="${xcode_versions[$version]}"
+ echo "selecting Xcode $version: $app"
+ xcsel "$app"
}
-alias xcb='xcodebuild'
-alias xcp='xcode-select --print-path'
-alias xcdd='rm -rf ~/Library/Developer/Xcode/DerivedData/*'
+function _omz_xcode_print_xcselv_usage {
+ cat << EOF >&2
+Usage:
+ xcselv <version>
+ xcselv [options]
+
+Options:
+ <version> set the active Xcode version
+ -h print this help message and exit
+ -p print the active Xcode version
+ -l list installed Xcode versions (long human-readable form)
+ -L list installed Xcode versions (short form, version names only)
+EOF
+}
+
+# Parses the Xcode version from a filename based on our conventions
+# Only meaningful when called from other _omz_xcode functions
+function _omz_xcode_parse_versioned_file {
+ local file=$1
+ local basename=${app:t}
+ local dir=${app:h}
+ local parent=${dir:t}
+ #echo "parent=$parent basename=$basename verstr=$verstr ver=$ver" >&2
+ local verstr
+ if [[ $parent == Xcode* ]]; then
+ if [[ $basename == "Xcode.app" ]]; then
+ # "Xcode-<version>/Xcode.app" format
+ verstr=$parent
+ else
+ # Both file and parent dir are versioned. Reject.
+ return 1;
+ fi
+ elif [[ $basename == Xcode*.app ]]; then
+ # "Xcode-<version>.app" format
+ verstr=${basename:r}
+ else
+ # Invalid naming pattern
+ return 1;
+ fi
-if [[ -d $(xcode-select -p)/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app ]]; then
- alias simulator='open $(xcode-select -p)/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app'
-else
- alias simulator='open $(xcode-select -p)/Applications/iOS\ Simulator.app'
-fi
+ local ver=${verstr#Xcode}
+ ver=${ver#[- ]}
+ if [[ -z $ver ]]; then
+ # Unversioned "default" installation location
+ ver="default"
+ fi
+ print -- "$ver"
+}
+
+# Print the active version, using xcselv's notion of versions
+function _omz_xcode_print_active_version {
+ emulate -L zsh
+ local -A xcode_versions
+ local versions version active_path
+ _omz_xcode_locate_versions
+ active_path=$(xcode-select -p)
+ active_path=${active_path%%/Contents/Developer*}
+ versions=(${(kni)xcode_versions})
+ for version ($versions); do
+ if [[ "${xcode_versions[$version]}" == $active_path ]]; then
+ printf "%s (%s)\n" $version $active_path
+ return
+ fi
+ done
+ printf "%s (%s)\n" "<unknown>" $active_path
+}
+
+# Locates all the installed versions of Xcode on this system, for this
+# plugin's internal use.
+# Populates the $xcode_versions associative array variable
+# Caller should local-ize $xcode_versions with `local -A xcode_versions`
+function _omz_xcode_locate_versions {
+ emulate -L zsh
+ local -a app_dirs
+ local app_dir apps app xcode_ver
+ # In increasing precedence order:
+ app_dirs=(/Applications $HOME/Applications)
+ for app_dir ($app_dirs); do
+ apps=( $app_dir/Xcode*.app(N) $app_dir/Xcode*/Xcode.app(N) )
+ for app ($apps); do
+ xcode_ver=$(_omz_xcode_parse_versioned_file $app)
+ if [[ $? != 0 ]]; then
+ continue
+ fi
+ xcode_versions[$xcode_ver]=$app
+ done
+ done
+}
+
+function _omz_xcode_list_versions {
+ emulate -L zsh
+ local -A xcode_versions
+ _omz_xcode_locate_versions
+ local width=1 width_i versions do_short=0
+ if [[ $1 == "short" ]]; then
+ do_short=1
+ fi
+ versions=(${(kni)xcode_versions})
+ for version ($versions); do
+ if [[ $#version > $width ]]; then
+ width=$#version;
+ fi
+ done
+ for version ($versions); do
+ if [[ $do_short == 1 ]]; then
+ printf "%s\n" $version
+ else
+ printf "%-${width}s -> %s\n" "$version" "${xcode_versions[$version]}"
+ fi
+ done
+}
+
+function simulator {
+ local devfolder
+ devfolder="$(xcode-select -p)"
+
+ # Xcode ≤ 5.x
+ if [[ -d "${devfolder}/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone Simulator.app" ]]; then
+ open "${devfolder}/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone Simulator.app"
+ # Xcode ≥ 6.x
+ else
+ open "${devfolder}/Applications/iOS Simulator.app"
+ fi
+}