diff --git a/README.textile b/README.textile index 1916d9f4e07f..810569486110 100644 --- a/README.textile +++ b/README.textile @@ -1,3 +1,5 @@ +!https://s3.amazonaws.com/ohmyzsh/oh-my-zsh-logo.png! + oh-my-zsh is an open source, community-driven framework for managing your ZSH configuration. It comes bundled with a ton of helpful functions, helpers, plugins, themes, and few things that make you shout... bq. "OH MY ZSHELL!" @@ -12,11 +14,11 @@ You can install this via the command line with either `curl` or `wget`. h4. via `curl` -@curl -L https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh | sh@ +@curl -L https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh | sh@ h4. via `wget` -@wget --no-check-certificate https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | sh@ +@wget --no-check-certificate https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O - | sh@ h3. The manual way diff --git a/lib/aliases.zsh b/lib/aliases.zsh index 2b58c4faa857..2094f60a05d2 100644 --- a/lib/aliases.zsh +++ b/lib/aliases.zsh @@ -6,6 +6,11 @@ alias po='popd' alias ...='cd ../..' alias -- -='cd -' +# Prevent headaches +alias cp='cp -v' +alias rm='rm -v' +alias mv='mv -v' + # Super user alias _='sudo' alias please='sudo' @@ -13,13 +18,23 @@ alias please='sudo' #alias g='grep -in' # Show history -alias history='fc -l 1' - +if [ "$HIST_STAMPS" = "mm/dd/yyyy" ] +then + alias history='fc -fl 1' +elif [ "$HIST_STAMPS" = "dd.mm.yyyy" ] +then + alias history='fc -El 1' +elif [ "$HIST_STAMPS" = "yyyy-mm-dd" ] +then + alias history='fc -il 1' +else + alias history='fc -l 1' +fi # List direcory contents alias lsa='ls -lah' -#alias l='ls -la' -alias ll='ls -l' -alias la='ls -lA' +alias l='ls -lah' +alias ll='ls -lh' +alias la='ls -lAh' alias sl=ls # often screw this up alias afind='ack-grep -il' diff --git a/lib/bzr.zsh b/lib/bzr.zsh new file mode 100644 index 000000000000..005a16500323 --- /dev/null +++ b/lib/bzr.zsh @@ -0,0 +1,10 @@ +## Bazaar integration +## Just works with the GIT integration just add $(bzr_prompt_info) to the PROMPT +function bzr_prompt_info() { + BZR_CB=`bzr nick 2> /dev/null | grep -v "ERROR" | cut -d ":" -f2 | awk -F / '{print "bzr::"$1}'` + if [ -n "$BZR_CB" ]; then + BZR_DIRTY="" + [[ -n `bzr status` ]] && BZR_DIRTY=" %{$fg[red]%} * %{$fg[green]%}" + echo "$ZSH_THEME_SCM_PROMPT_PREFIX$BZR_CB$BZR_DIRTY$ZSH_THEME_GIT_PROMPT_SUFFIX" + fi +} \ No newline at end of file diff --git a/lib/correction.zsh b/lib/correction.zsh index 436446101ad0..47eb83b1d523 100644 --- a/lib/correction.zsh +++ b/lib/correction.zsh @@ -1,14 +1,13 @@ -if [[ "$DISABLE_CORRECTION" == "true" ]]; then - return -else +alias man='nocorrect man' +alias mv='nocorrect mv' +alias mysql='nocorrect mysql' +alias mkdir='nocorrect mkdir' +alias gist='nocorrect gist' +alias heroku='nocorrect heroku' +alias ebuild='nocorrect ebuild' +alias hpodder='nocorrect hpodder' +alias sudo='nocorrect sudo' + +if [[ "$ENABLE_CORRECTION" == "true" ]]; then setopt correct_all - alias man='nocorrect man' - alias mv='nocorrect mv' - alias mysql='nocorrect mysql' - alias mkdir='nocorrect mkdir' - alias gist='nocorrect gist' - alias heroku='nocorrect heroku' - alias ebuild='nocorrect ebuild' - alias hpodder='nocorrect hpodder' - alias sudo='nocorrect sudo' fi diff --git a/lib/edit-command-line.zsh b/lib/edit-command-line.zsh deleted file mode 100644 index db2000325c82..000000000000 --- a/lib/edit-command-line.zsh +++ /dev/null @@ -1,3 +0,0 @@ -autoload -U edit-command-line -zle -N edit-command-line -bindkey '\C-x\C-e' edit-command-line diff --git a/lib/functions.zsh b/lib/functions.zsh index 63ab755cf72b..aaf8a03e31e8 100644 --- a/lib/functions.zsh +++ b/lib/functions.zsh @@ -15,3 +15,61 @@ function take() { cd $1 } +# +# Get the value of an alias. +# +# Arguments: +# 1. alias - The alias to get its value from +# STDOUT: +# The value of alias $1 (if it has one). +# Return value: +# 0 if the alias was found, +# 1 if it does not exist +# +function alias_value() { + alias "$1" | sed "s/^$1='\(.*\)'$/\1/" + test $(alias "$1") +} + +# +# Try to get the value of an alias, +# otherwise return the input. +# +# Arguments: +# 1. alias - The alias to get its value from +# STDOUT: +# The value of alias $1, or $1 if there is no alias $1. +# Return value: +# Always 0 +# +function try_alias_value() { + alias_value "$1" || echo "$1" +} + +# +# Set variable "$1" to default value "$2" if "$1" is not yet defined. +# +# Arguments: +# 1. name - The variable to set +# 2. val - The default value +# Return value: +# 0 if the variable exists, 3 if it was set +# +function default() { + test `typeset +m "$1"` && return 0 + typeset -g "$1"="$2" && return 3 +} + +# +# Set enviroment variable "$1" to default value "$2" if "$1" is not yet defined. +# +# Arguments: +# 1. name - The env variable to set +# 2. val - The default value +# Return value: +# 0 if the env variable exists, 3 if it was set +# +function env_default() { + env | grep -q "^$1=" && return 0 + export "$1=$2" && return 3 +} diff --git a/lib/git.zsh b/lib/git.zsh index c4b5b5d62e71..305a77aff087 100644 --- a/lib/git.zsh +++ b/lib/git.zsh @@ -1,8 +1,10 @@ # get the name of the branch we are on function git_prompt_info() { - ref=$(git symbolic-ref HEAD 2> /dev/null) || \ - ref=$(git rev-parse --short HEAD 2> /dev/null) || return - echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_SUFFIX" + if [[ "$(git config --get oh-my-zsh.hide-status)" != "1" ]]; then + ref=$(command git symbolic-ref HEAD 2> /dev/null) || \ + ref=$(command git rev-parse --short HEAD 2> /dev/null) || return + echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_SUFFIX" + fi } @@ -11,14 +13,14 @@ parse_git_dirty() { local SUBMODULE_SYNTAX='' local GIT_STATUS='' local CLEAN_MESSAGE='nothing to commit (working directory clean)' - if [[ "$(git config --get oh-my-zsh.hide-status)" != "1" ]]; then + if [[ "$(command git config --get oh-my-zsh.hide-status)" != "1" ]]; then if [[ $POST_1_7_2_GIT -gt 0 ]]; then SUBMODULE_SYNTAX="--ignore-submodules=dirty" fi if [[ "$DISABLE_UNTRACKED_FILES_DIRTY" == "true" ]]; then - GIT_STATUS=$(git status -s ${SUBMODULE_SYNTAX} -uno 2> /dev/null | tail -n1) + GIT_STATUS=$(command git status -s ${SUBMODULE_SYNTAX} -uno 2> /dev/null | tail -n1) else - GIT_STATUS=$(git status -s ${SUBMODULE_SYNTAX} 2> /dev/null | tail -n1) + GIT_STATUS=$(command git status -s ${SUBMODULE_SYNTAX} 2> /dev/null | tail -n1) fi if [[ -n $GIT_STATUS ]]; then echo "$ZSH_THEME_GIT_PROMPT_DIRTY" @@ -32,10 +34,10 @@ parse_git_dirty() { # get the difference between the local and remote branches git_remote_status() { - remote=${$(git rev-parse --verify ${hook_com[branch]}@{upstream} --symbolic-full-name 2>/dev/null)/refs\/remotes\/} + remote=${$(command git rev-parse --verify ${hook_com[branch]}@{upstream} --symbolic-full-name 2>/dev/null)/refs\/remotes\/} if [[ -n ${remote} ]] ; then - ahead=$(git rev-list ${hook_com[branch]}@{upstream}..HEAD 2>/dev/null | wc -l) - behind=$(git rev-list HEAD..${hook_com[branch]}@{upstream} 2>/dev/null | wc -l) + ahead=$(command git rev-list ${hook_com[branch]}@{upstream}..HEAD 2>/dev/null | wc -l) + behind=$(command git rev-list HEAD..${hook_com[branch]}@{upstream} 2>/dev/null | wc -l) if [ $ahead -eq 0 ] && [ $behind -gt 0 ] then @@ -52,24 +54,24 @@ git_remote_status() { # Checks if there are commits ahead from remote function git_prompt_ahead() { - if $(echo "$(git log origin/$(current_branch)..HEAD 2> /dev/null)" | grep '^commit' &> /dev/null); then + if $(echo "$(command git log origin/$(current_branch)..HEAD 2> /dev/null)" | grep '^commit' &> /dev/null); then echo "$ZSH_THEME_GIT_PROMPT_AHEAD" fi } # Formats prompt string for current git commit short SHA function git_prompt_short_sha() { - SHA=$(git rev-parse --short HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER" + SHA=$(command git rev-parse --short HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER" } # Formats prompt string for current git commit long SHA function git_prompt_long_sha() { - SHA=$(git rev-parse HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER" + SHA=$(command git rev-parse HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER" } # Get the status of the working tree git_prompt_status() { - INDEX=$(git status --porcelain -b 2> /dev/null) + INDEX=$(command git status --porcelain -b 2> /dev/null) STATUS="" if $(echo "$INDEX" | grep -E '^\?\? ' &> /dev/null); then STATUS="$ZSH_THEME_GIT_PROMPT_UNTRACKED$STATUS" @@ -96,7 +98,7 @@ git_prompt_status() { elif $(echo "$INDEX" | grep '^AD ' &> /dev/null); then STATUS="$ZSH_THEME_GIT_PROMPT_DELETED$STATUS" fi - if $(git rev-parse --verify refs/stash >/dev/null 2>&1); then + if $(command git rev-parse --verify refs/stash >/dev/null 2>&1); then STATUS="$ZSH_THEME_GIT_PROMPT_STASHED$STATUS" fi if $(echo "$INDEX" | grep '^UU ' &> /dev/null); then @@ -121,7 +123,7 @@ function git_compare_version() { local INPUT_GIT_VERSION=$1; local INSTALLED_GIT_VERSION INPUT_GIT_VERSION=(${(s/./)INPUT_GIT_VERSION}); - INSTALLED_GIT_VERSION=($(git --version 2>/dev/null)); + INSTALLED_GIT_VERSION=($(command git --version 2>/dev/null)); INSTALLED_GIT_VERSION=(${(s/./)INSTALLED_GIT_VERSION[3]}); for i in {1..3}; do diff --git a/lib/key-bindings.zsh b/lib/key-bindings.zsh index 5f499f3e8a56..49f80c8f34e2 100644 --- a/lib/key-bindings.zsh +++ b/lib/key-bindings.zsh @@ -30,6 +30,11 @@ bindkey "^[[3~" delete-char bindkey "^[3;5~" delete-char bindkey "\e[3~" delete-char +# Edit the current command line in $EDITOR +autoload -U edit-command-line +zle -N edit-command-line +bindkey '\C-x\C-e' edit-command-line + # consider emacs keybindings: #bindkey -e ## emacs key bindings diff --git a/lib/nvm.zsh b/lib/nvm.zsh new file mode 100644 index 000000000000..5cadf706195f --- /dev/null +++ b/lib/nvm.zsh @@ -0,0 +1,9 @@ +# get the node.js version +function nvm_prompt_info() { + [ -f $HOME/.nvm/nvm.sh ] || return + local nvm_prompt + nvm_prompt=$(node -v 2>/dev/null) + [[ "${nvm_prompt}x" == "x" ]] && return + nvm_prompt=${nvm_prompt:1} + echo "${ZSH_THEME_NVM_PROMPT_PREFIX}${nvm_prompt}${ZSH_THEME_NVM_PROMPT_SUFFIX}" +} diff --git a/lib/prompt_info_functions.zsh b/lib/prompt_info_functions.zsh new file mode 100644 index 000000000000..335c02a3d038 --- /dev/null +++ b/lib/prompt_info_functions.zsh @@ -0,0 +1,33 @@ +# *_prompt_info functions for usage in your prompt +# +# Plugin creators, please add your *_prompt_info function to the list +# of dummy implementations to help theme creators not receiving errors +# without the need of implementing conditional clauses. +# +# See also lib/bzr.zsh, lib/git.zsh and lib/nvm.zsh for +# git_prompt_info, bzr_prompt_info and nvm_prompt_info + +# Dummy implementations that return false to prevent command_not_found +# errors with themes, that implement these functions +# Real implementations will be used when the respective plugins are loaded +function chruby_prompt_info hg_prompt_info pyenv_prompt_info \ + rbenv_prompt_info svn_prompt_info vi_mode_prompt_info \ + virtualenv_prompt_info { + return 1 +} + +# oh-my-zsh supports an rvm prompt by default +# get the name of the rvm ruby version +function rvm_prompt_info() { + [ -f $HOME/.rvm/bin/rvm-prompt ] || return 1 + local rvm_prompt + rvm_prompt=$($HOME/.rvm/bin/rvm-prompt ${=ZSH_THEME_RVM_PROMPT_OPTIONS} 2>/dev/null) + [[ "${rvm_prompt}x" == "x" ]] && return 1 + echo "${ZSH_THEME_RVM_PROMPT_PREFIX:=(}${rvm_prompt}${ZSH_THEME_RVM_PROMPT_SUFFIX:=)}" +} + +# use this to enable users to see their ruby version, no matter which +# version management system they use +function ruby_prompt_info() { + echo $(rvm_prompt_info || rbenv_prompt_info || chruby_prompt_info) +} diff --git a/lib/rbenv.zsh b/lib/rbenv.zsh deleted file mode 100644 index a8b6c323ccae..000000000000 --- a/lib/rbenv.zsh +++ /dev/null @@ -1,2 +0,0 @@ -# using the rbenv plugin will override this with a real implementation -function rbenv_prompt_info() {} diff --git a/lib/rvm.zsh b/lib/rvm.zsh deleted file mode 100644 index e8744e61e373..000000000000 --- a/lib/rvm.zsh +++ /dev/null @@ -1,8 +0,0 @@ -# get the name of the ruby version -function rvm_prompt_info() { - [ -f $HOME/.rvm/bin/rvm-prompt ] || return - local rvm_prompt - rvm_prompt=$($HOME/.rvm/bin/rvm-prompt ${ZSH_THEME_RVM_PROMPT_OPTIONS} 2>/dev/null) - [[ "${rvm_prompt}x" == "x" ]] && return - echo "${ZSH_THEME_RVM_PROMPT_PREFIX:=(}${rvm_prompt}${ZSH_THEME_RVM_PROMPT_SUFFIX:=)}" -} diff --git a/lib/spectrum.zsh b/lib/spectrum.zsh index 2fdf537ef5e2..166c942fb908 100644 --- a/lib/spectrum.zsh +++ b/lib/spectrum.zsh @@ -26,3 +26,10 @@ function spectrum_ls() { done } +# Show all 256 colors where the background is set to specific color +function spectrum_bls() { + for code in {000..255}; do + ((cc = code + 1)) + print -P -- "$BG[$code]$code: Test %{$reset_color%}" + done +} diff --git a/lib/termsupport.zsh b/lib/termsupport.zsh index 80319e1a8696..5f2fe63d422f 100644 --- a/lib/termsupport.zsh +++ b/lib/termsupport.zsh @@ -27,9 +27,8 @@ function omz_termsupport_preexec { emulate -L zsh setopt extended_glob local CMD=${1[(wr)^(*=*|sudo|ssh|rake|-*)]} #cmd name only, or if this is sudo or ssh, the next cmd - local LINE="${2:gs/$/\\$}" - LINE="${LINE:gs/%/%%}" - title "$CMD" "%100>...>$LINE%<<" + local LINE="${2:gs/%/%%}" + title '$CMD' '%100>...>$LINE%<<' } autoload -U add-zsh-hook diff --git a/lib/theme-and-appearance.zsh b/lib/theme-and-appearance.zsh index 2677615c046e..0353f9db4d1c 100644 --- a/lib/theme-and-appearance.zsh +++ b/lib/theme-and-appearance.zsh @@ -11,6 +11,10 @@ then # On NetBSD, test if "gls" (GNU ls) is installed (this one supports colors); # otherwise, leave ls as is, because NetBSD's ls doesn't support -G gls --color -d . &>/dev/null 2>&1 && alias ls='gls --color=tty' + elif [[ "$(uname -s)" == "OpenBSD" ]]; then + # On OpenBSD, test if "colorls" is installed (this one supports colors); + # otherwise, leave ls as is, because OpenBSD's ls doesn't support -G + colorls -G -d . &>/dev/null 2>&1 && alias ls='colorls -G' else ls --color -d . &>/dev/null 2>&1 && alias ls='ls --color=tty' || alias ls='ls -G' fi diff --git a/oh-my-zsh.sh b/oh-my-zsh.sh index 93c10e3d2e92..3c0f4f8f5f99 100644 --- a/oh-my-zsh.sh +++ b/oh-my-zsh.sh @@ -1,7 +1,6 @@ # Check for updates on initial load... -if [ "$DISABLE_AUTO_UPDATE" != "true" ] -then - /usr/bin/env ZSH=$ZSH DISABLE_UPDATE_PROMPT=$DISABLE_UPDATE_PROMPT zsh $ZSH/tools/check_for_upgrade.sh +if [ "$DISABLE_AUTO_UPDATE" != "true" ]; then + /usr/bin/env ZSH=$ZSH DISABLE_UPDATE_PROMPT=$DISABLE_UPDATE_PROMPT zsh -f $ZSH/tools/check_for_upgrade.sh fi # Initializes Oh My Zsh @@ -38,10 +37,20 @@ for plugin ($plugins); do fi done +# Figure out the SHORT hostname +if [ -n "$commands[scutil]" ]; then + # OS X + SHORT_HOST=$(scutil --get ComputerName) +else + SHORT_HOST=${HOST/.*/} +fi + +# Save the location of the current completion dump file. +ZSH_COMPDUMP="${ZDOTDIR:-${HOME}}/.zcompdump-${SHORT_HOST}-${ZSH_VERSION}" + # Load and run compinit autoload -U compinit -compinit -i - +compinit -i -d "${ZSH_COMPDUMP}" # Load all of the plugins that were defined in ~/.zshrc for plugin ($plugins); do @@ -59,8 +68,7 @@ done unset config_file # Load the theme -if [ "$ZSH_THEME" = "random" ] -then +if [ "$ZSH_THEME" = "random" ]; then themes=($ZSH/themes/*zsh-theme) N=${#themes[@]} ((N=(RANDOM%N)+1)) @@ -68,13 +76,10 @@ then source "$RANDOM_THEME" echo "[oh-my-zsh] Random theme '$RANDOM_THEME' loaded..." else - if [ ! "$ZSH_THEME" = "" ] - then - if [ -f "$ZSH_CUSTOM/$ZSH_THEME.zsh-theme" ] - then + if [ ! "$ZSH_THEME" = "" ]; then + if [ -f "$ZSH_CUSTOM/$ZSH_THEME.zsh-theme" ]; then source "$ZSH_CUSTOM/$ZSH_THEME.zsh-theme" - elif [ -f "$ZSH_CUSTOM/themes/$ZSH_THEME.zsh-theme" ] - then + elif [ -f "$ZSH_CUSTOM/themes/$ZSH_THEME.zsh-theme" ]; then source "$ZSH_CUSTOM/themes/$ZSH_THEME.zsh-theme" else source "$ZSH/themes/$ZSH_THEME.zsh-theme" diff --git a/plugins/atom/atom.plugin.zsh b/plugins/atom/atom.plugin.zsh new file mode 100644 index 000000000000..048fd75219fd --- /dev/null +++ b/plugins/atom/atom.plugin.zsh @@ -0,0 +1,4 @@ +# +# Your guess is as good as mine. Let's just assume that we will need this... +# - For more info visit... http://atom.io/ +# \ No newline at end of file diff --git a/plugins/autojump/autojump.plugin.zsh b/plugins/autojump/autojump.plugin.zsh index f856f2f01fb8..0aa14959d354 100644 --- a/plugins/autojump/autojump.plugin.zsh +++ b/plugins/autojump/autojump.plugin.zsh @@ -5,6 +5,8 @@ if [ $commands[autojump] ]; then # check if autojump is installed . /etc/profile.d/autojump.zsh elif [ -f /etc/profile.d/autojump.sh ]; then # gentoo installation . /etc/profile.d/autojump.sh + elif [ -f /usr/local/share/autojump/autojump.zsh ]; then # freebsd installation + . /usr/local/share/autojump/autojump.zsh elif [ -f $HOME/.autojump/etc/profile.d/autojump.zsh ]; then # manual user-local installation . $HOME/.autojump/etc/profile.d/autojump.zsh elif [ -f /opt/local/etc/profile.d/autojump.zsh ]; then # mac os x with ports diff --git a/plugins/autopep8/_autopep8 b/plugins/autopep8/_autopep8 new file mode 100644 index 000000000000..c14d06d66814 --- /dev/null +++ b/plugins/autopep8/_autopep8 @@ -0,0 +1,32 @@ +#compdef autopep8 +# +# this is zsh completion function file. +# generated by genzshcomp(ver: 0.5.1) +# + +typeset -A opt_args +local context state line + +_arguments -s -S \ + "--help[show this help message and exit]:" \ + "-h[show this help message and exit]:" \ + "--version[show program's version number and exit]:" \ + "--verbose[print verbose messages; multiple -v result in more verbose messages]" \ + "-v[print verbose messages; multiple -v result in more verbose messages]" \ + "--diff[print the diff for the fixed source]" \ + "-d[print the diff for the fixed source]" \ + "--in-place[make changes to files in place]" \ + "-i[make changes to files in place]" \ + "--recursive[run recursively; must be used with --in-place or --diff]" \ + "-r[run recursively; must be used with --in-place or --diff]" \ + "--jobs[number of parallel jobs; match CPU count if value is less than 1]::n number of parallel jobs; match CPU count if value is:_files" \ + "-j[number of parallel jobs; match CPU count if value is less than 1]::n number of parallel jobs; match CPU count if value is:_files" \ + "--pep8-passes[maximum number of additional pep8 passes (default: 100)]::n:_files" \ + "-p[maximum number of additional pep8 passes (default: 100)]::n:_files" \ + "-a[-a result in more aggressive changes]::result:_files" \ + "--exclude[exclude files/directories that match these comma- separated globs]::globs:_files" \ + "--list-fixes[list codes for fixes; used by --ignore and --select]" \ + "--ignore[do not fix these errors/warnings (default E226,E24)]::errors:_files" \ + "--select[fix only these errors/warnings (e.g. E4,W)]::errors:_files" \ + "--max-line-length[set maximum allowed line length (default: 79)]::n:_files" \ + "*::args:_files" diff --git a/plugins/autopep8/autopep8.plugin.zsh b/plugins/autopep8/autopep8.plugin.zsh new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/plugins/battery/battery.plugin.zsh b/plugins/battery/battery.plugin.zsh index 66bf46d138d5..16ad3e6510a6 100644 --- a/plugins/battery/battery.plugin.zsh +++ b/plugins/battery/battery.plugin.zsh @@ -11,8 +11,9 @@ if [[ $(uname) == "Darwin" ]] ; then function battery_pct() { - typeset -F maxcapacity=$(ioreg -rc "AppleSmartBattery"| grep '^.*"MaxCapacity"\ =\ ' | sed -e 's/^.*"MaxCapacity"\ =\ //') - typeset -F currentcapacity=$(ioreg -rc "AppleSmartBattery"| grep '^.*"CurrentCapacity"\ =\ ' | sed -e 's/^.*CurrentCapacity"\ =\ //') + local smart_battery_status="$(ioreg -rc "AppleSmartBattery")" + typeset -F maxcapacity=$(echo $smart_battery_status | grep '^.*"MaxCapacity"\ =\ ' | sed -e 's/^.*"MaxCapacity"\ =\ //') + typeset -F currentcapacity=$(echo $smart_battery_status | grep '^.*"CurrentCapacity"\ =\ ' | sed -e 's/^.*CurrentCapacity"\ =\ //') integer i=$(((currentcapacity/maxcapacity) * 100)) echo $i } @@ -26,8 +27,9 @@ if [[ $(uname) == "Darwin" ]] ; then } function battery_time_remaining() { - if [[ $(ioreg -rc AppleSmartBattery | grep -c '^.*"ExternalConnected"\ =\ No') -eq 1 ]] ; then - timeremaining=$(ioreg -rc "AppleSmartBattery"| grep '^.*"AvgTimeToEmpty"\ =\ ' | sed -e 's/^.*"AvgTimeToEmpty"\ =\ //') + local smart_battery_status="$(ioreg -rc "AppleSmartBattery")" + if [[ $(echo $smart_battery_status | grep -c '^.*"ExternalConnected"\ =\ No') -eq 1 ]] ; then + timeremaining=$(echo $smart_battery_status | grep '^.*"AvgTimeToEmpty"\ =\ ' | sed -e 's/^.*"AvgTimeToEmpty"\ =\ //') echo "~$((timeremaining / 60)):$((timeremaining % 60))" else echo "∞" @@ -49,6 +51,10 @@ if [[ $(uname) == "Darwin" ]] ; then echo "∞" fi } + + function battery_is_charging() { + [[ $(ioreg -rc "AppleSmartBattery"| grep '^.*"IsCharging"\ =\ ' | sed -e 's/^.*"IsCharging"\ =\ //') == "Yes" ]] + } elif [[ $(uname) == "Linux" ]] ; then @@ -79,4 +85,66 @@ elif [[ $(uname) == "Linux" ]] ; then echo "∞" fi } + + function battery_pct() { + # todo for on linux + } + + function battery_is_charging() { + # todo on linux + false + } + +else + # Empty functions so we don't cause errors in prompts + function battery_pct_remaining() { + } + + function battery_time_remaining() { + } + + function battery_pct_prompt() { + } fi + +function battery_level_gauge() { + local gauge_slots=${BATTERY_GAUGE_SLOTS:-10}; + local green_threshold=${BATTERY_GREEN_THRESHOLD:-6}; + local yellow_threshold=${BATTERY_YELLOW_THRESHOLD:-4}; + local color_green=${BATTERY_COLOR_GREEN:-%F{green}}; + local color_yellow=${BATTERY_COLOR_YELLOW:-%F{yellow}}; + local color_red=${BATTERY_COLOR_RED:-%F{red}}; + local color_reset=${BATTERY_COLOR_RESET:-%{%f%k%b%}}; + local battery_prefix=${BATTERY_GAUGE_PREFIX:-'['}; + local battery_suffix=${BATTERY_GAUGE_SUFFIX:-']'}; + local filled_symbol=${BATTERY_GAUGE_FILLED_SYMBOL:-'▶'}; + local empty_symbol=${BATTERY_GAUGE_EMPTY_SYMBOL:-'▷'}; + local charging_color=${BATTERY_CHARGING_COLOR:-$color_yellow}; + local charging_symbol=${BATTERY_CHARGING_SYMBOL:-'⚡'}; + + local battery_remaining_percentage=$(battery_pct); + + if [[ $battery_remaining_percentage =~ [0-9]+ ]]; then + local filled=$(((( $battery_remaining_percentage + $gauge_slots - 1) / $gauge_slots))); + local empty=$(($gauge_slots - $filled)); + + if [[ $filled -gt $green_threshold ]]; then local gauge_color=$color_green; + elif [[ $filled -gt $yellow_threshold ]]; then local gauge_color=$color_yellow; + else local gauge_color=$color_red; + fi + else + local filled=$gauge_slots; + local empty=0; + filled_symbol=${BATTERY_UNKNOWN_SYMBOL:-'.'}; + fi + + + local charging=' ' && battery_is_charging && charging=$charging_symbol; + + printf ${charging_color//\%/\%\%}$charging${color_reset//\%/\%\%}${battery_prefix//\%/\%\%}${gauge_color//\%/\%\%} + printf ${filled_symbol//\%/\%\%}'%.0s' {1..$filled} + [[ $filled -lt $gauge_slots ]] && printf ${empty_symbol//\%/\%\%}'%.0s' {1..$empty} + printf ${color_reset//\%/\%\%}${battery_suffix//\%/\%\%}${color_reset//\%/\%\%} +} + + diff --git a/plugins/bower/bower.plugin.zsh b/plugins/bower/bower.plugin.zsh index ed9c048400bd..68a67a3cc625 100644 --- a/plugins/bower/bower.plugin.zsh +++ b/plugins/bower/bower.plugin.zsh @@ -2,37 +2,80 @@ alias bi="bower install" alias bl="bower list" alias bs="bower search" -bower_package_list='' - +_bower_installed_packages () { + bower_package_list=$(bower ls --no-color 2>/dev/null| awk 'NR>3{print p}{p=$0}'| cut -d ' ' -f 2|sed 's/#.*//') +} _bower () { - local curcontext="$curcontext" state line - typeset -A opt_args - - _arguments -C \ - ':command:->command' \ - '*::options:->options' - - case $state in - (command) - - local -a subcommands - subcommands=(${=$(bower help | grep help | sed -e 's/,//g')}) - _describe -t commands 'bower' subcommands - ;; - - (options) - case $line[1] in - - (install) - if [ -z "$bower_package_list" ];then - bower_package_list=$(bower search | awk 'NR > 2' | cut -d '-' -f 2 | cut -d ' ' -f 2 | sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g") - fi - compadd "$@" $(echo $bower_package_list) - ;; - esac - ;; - esac + local -a _1st_arguments _no_color _dopts _save_dev _force_lastest _production + local expl + typeset -A opt_args + + _no_color=('--no-color[Do not print colors (available in all commands)]') + + _dopts=( + '(--save)--save[Save installed packages into the project"s bower.json dependencies]' + '(--force)--force[Force fetching remote resources even if a local copy exists on disk]' + ) + + _save_dev=('(--save-dev)--save-dev[Save installed packages into the project"s bower.json devDependencies]') + + _force_lastest=('(--force-latest)--force-latest[Force latest version on conflict]') + + _production=('(--production)--production[Do not install project devDependencies]') + + _1st_arguments=( + 'cache-clean:Clean the Bower cache, or the specified package caches' \ + 'help:Display help information about Bower' \ + 'info:Version info and description of a particular package' \ + 'init:Interactively create a bower.json file' \ + 'install:Install a package locally' \ + 'link:Symlink a package folder' \ + 'lookup:Look up a package URL by name' \ + 'register:Register a package' \ + 'search:Search for a package by name' \ + 'uninstall:Remove a package' \ + 'update:Update a package' \ + {ls,list}:'[List all installed packages]' + ) + _arguments \ + $_no_color \ + '*:: :->subcmds' && return 0 + + if (( CURRENT == 1 )); then + _describe -t commands "bower subcommand" _1st_arguments + return + fi + + case "$words[1]" in + install) + _arguments \ + $_dopts \ + $_save_dev \ + $_force_lastest \ + $_no_color \ + $_production + ;; + update) + _arguments \ + $_dopts \ + $_no_color \ + $_force_lastest + _bower_installed_packages + compadd "$@" $(echo $bower_package_list) + ;; + uninstall) + _arguments \ + $_no_color \ + $_dopts + _bower_installed_packages + compadd "$@" $(echo $bower_package_list) + ;; + *) + $_no_color \ + ;; + esac + } compdef _bower bower diff --git a/plugins/brew/_brew b/plugins/brew/_brew index e43ba2900d6f..d4306f2236f1 100644 --- a/plugins/brew/_brew +++ b/plugins/brew/_brew @@ -26,11 +26,14 @@ _1st_arguments=( 'list:list files in a formula or not-installed formulae' 'log:git commit log for a formula' 'missing:check all installed formuale for missing dependencies.' + 'options:display install options specific to formula.' 'outdated:list formulas for which a newer version is available' 'prune:remove dead links' + 'reinstall:reinstall a formula' 'remove:remove a formula' 'search:search for a formula (/regex/ or string)' 'server:start a local web app that lets you browse formulae (requires Sinatra)' + 'services:manage background services via launchctl' 'unlink:unlink a formula' 'update:freshen up links' 'upgrade:upgrade outdated formulae' @@ -75,7 +78,7 @@ case "$words[1]" in install|home|homepage|log|info|abv|uses|cat|deps|edit|options|versions) _brew_all_formulae _wanted formulae expl 'all formulae' compadd -a formulae ;; - remove|rm|uninstall|unlink|cleanup|link|ln) + reinstall|remove|rm|uninstall|unlink|cleanup|link|ln) _brew_installed_formulae _wanted installed_formulae expl 'installed formulae' compadd -a installed_formulae ;; esac diff --git a/plugins/bundler/bundler.plugin.zsh b/plugins/bundler/bundler.plugin.zsh index 9446aafabab8..9dfed61a46b0 100644 --- a/plugins/bundler/bundler.plugin.zsh +++ b/plugins/bundler/bundler.plugin.zsh @@ -1,5 +1,4 @@ alias be="bundle exec" -alias bi="bundle install" alias bl="bundle list" alias bp="bundle package" alias bo="bundle open" @@ -7,10 +6,34 @@ alias bu="bundle update" # The following is based on https://github.com/gma/bundler-exec -bundled_commands=(annotate cap capify cucumber foreman guard jekyll middleman nanoc rackup rainbows rake rspec ruby shotgun spec spin spork thin thor unicorn unicorn_rails puma) +bundled_commands=(annotate berks cap capify cucumber foodcritic foreman guard jekyll kitchen knife middleman nanoc rackup rainbows rake rspec ruby shotgun spec spin spork strainer tailor taps thin thor unicorn unicorn_rails puma) + +# Remove $UNBUNDLED_COMMANDS from the bundled_commands list +for cmd in $UNBUNDLED_COMMANDS; do + bundled_commands=(${bundled_commands#$cmd}); +done ## Functions +bi() { + if _bundler-installed && _within-bundled-project; then + local bundler_version=`bundle version | cut -d' ' -f3` + if [[ $bundler_version > '1.4.0' || $bundler_version = '1.4.0' ]]; then + if [[ "$(uname)" == 'Darwin' ]] + then + local cores_num="$(sysctl hw.ncpu | awk '{print $2}')" + else + local cores_num="$(nproc)" + fi + bundle install --jobs=$cores_num $@ + else + bundle install $@ + fi + else + echo "Can't 'bundle install' outside a bundled project" + fi +} + _bundler-installed() { which bundle > /dev/null 2>&1 } @@ -42,3 +65,4 @@ for cmd in $bundled_commands; do compdef _$cmd bundled_$cmd=$cmd fi done + diff --git a/plugins/cabal/cabal.plugin.zsh b/plugins/cabal/cabal.plugin.zsh new file mode 100644 index 000000000000..9f76add7a30a --- /dev/null +++ b/plugins/cabal/cabal.plugin.zsh @@ -0,0 +1,47 @@ +function cabal_sandbox_info() { + cabal_files=(*.cabal(N)) + if [ $#cabal_files -gt 0 ]; then + if [ -f cabal.sandbox.config ]; then + echo "%{$fg[green]%}sandboxed%{$reset_color%}" + else + echo "%{$fg[red]%}not sandboxed%{$reset_color%}" + fi + fi +} + +function _cabal_commands() { + local ret=1 state + _arguments ':subcommand:->subcommand' && ret=0 + + case $state in + subcommand) + subcommands=( + "bench:Run the benchmark, if any (configure with UserHooks)" + "build:Make this package ready for installation" + "check:Check the package for common mistakes" + "clean:Clean up after a build" + "copy:Copy teh files into the install locations" + "configure:Prepare to build the package" + "fetch:Downloads packages for later installation" + "haddock:Generate HAddock HTML documentation" + "help:Help about commands" + "hscolour:Generate HsColour colourised code, in HTML format" + "info:Display detailed information about a particular package" + "init:Interactively create a .cabal file" + "install:Installs a list of packages" + "list:List packages matching a search string" + "register:Register this package with the compiler" + "report:Upload build reports to a remote server" + "sdist:Generate a source distribution file (.tar.gz)" + "test:Run the test suite, if any (configure with UserHooks)" + "unpack:Unpacks packages for user inspection" + "update:Updates list of known packages" + "upload:Uploads source packages to Hackage" + ) + _describe -t subcommands 'cabal subcommands' subcommands && ret=0 + esac + + return ret +} + +compdef _cabal_commands cabal diff --git a/plugins/capistrano/_capistrano b/plugins/capistrano/_capistrano index 1002dad96fbb..3cadf3d54be8 100644 --- a/plugins/capistrano/_capistrano +++ b/plugins/capistrano/_capistrano @@ -4,7 +4,7 @@ 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 --tasks | grep '#' | cut -d " " -f 2 > .cap_tasks~ + cap -v --tasks | grep '#' | cut -d " " -f 2 > .cap_tasks~ fi compadd `cat .cap_tasks~` fi diff --git a/plugins/catimg/catimg.plugin.zsh b/plugins/catimg/catimg.plugin.zsh new file mode 100644 index 000000000000..cb92f5986bed --- /dev/null +++ b/plugins/catimg/catimg.plugin.zsh @@ -0,0 +1,17 @@ +################################################################################ +# catimg script by Eduardo San Martin Morote aka Posva # +# http://posva.net # +# # +# Ouput the content of an image to the stdout using the 256 colors of the # +# terminal. # +# Github: https://github.com/posva/catimg # +################################################################################ + + +function catimg() { + if [[ -x `which convert` ]]; then + zsh $ZSH/plugins/catimg/catimg.sh $@ + else + echo "catimg need convert (ImageMagick) to work)" + fi +} diff --git a/plugins/catimg/catimg.sh b/plugins/catimg/catimg.sh new file mode 100755 index 000000000000..cd0f2e3335e5 --- /dev/null +++ b/plugins/catimg/catimg.sh @@ -0,0 +1,88 @@ +################################################################################ +# catimg script by Eduardo San Martin Morote aka Posva # +# http://posva.net # +# # +# Ouput the content of an image to the stdout using the 256 colors of the # +# terminal. # +# Github: https://github.com/posva/catimg # +################################################################################ + +function help() { + echo "Usage catimg [-h] [-w width] [-c char] img" + echo "By default char is \" \" and w is the terminal width" +} + +# VARIABLES +COLOR_FILE=$(dirname $0)/colors.png +CHAR=" " + +WIDTH="" +IMG="" + +while getopts qw:c:h opt; do + case "$opt" in + w) WIDTH="$OPTARG" ;; + c) CHAR="$OPTARG" ;; + h) help; exit ;; + *) help ; exit 1;; + esac + done + +while [ "$1" ]; do + IMG="$1" + shift +done + +if [ "$IMG" = "" -o ! -f "$IMG" ]; then + help + exit 1 +fi + +if [ ! "$WIDTH" ]; then + COLS=$(expr $(tput cols) "/" $(echo -n "$CHAR" | wc -c)) +else + COLS=$(expr $WIDTH "/" $(echo -n "$CHAR" | wc -c)) +fi +WIDTH=$(convert "$IMG" -print "%w\n" /dev/null) +if [ "$WIDTH" -gt "$COLS" ]; then + WIDTH=$COLS +fi + +REMAP="" +if convert "$IMG" -resize $COLS\> +dither -remap $COLOR_FILE /dev/null ; then + REMAP="-remap $COLOR_FILE" +else + echo "The version of convert is too old, don't expect good results :(" >&2 + #convert "$IMG" -colors 256 PNG8:tmp.png + #IMG="tmp.png" +fi + +# Display the image +I=0 +convert "$IMG" -resize $COLS\> +dither `echo $REMAP` txt:- 2>/dev/null | +sed -e 's/.*none.*/NO NO NO/g' -e '1d;s/^.*(\(.*\)[,)].*$/\1/g;y/,/ /' | +while read R G B f; do + if [ ! "$R" = "NO" ]; then + if [ "$R" -eq "$G" -a "$G" -eq "$B" ]; then + (( + I++, + IDX = 232 + R * 23 / 255 + )) + else + (( + I++, + IDX = 16 + + R * 5 / 255 * 36 + + G * 5 / 255 * 6 + + B * 5 / 255 + )) + fi + #echo "$R,$G,$B: $IDX" + echo -ne "\e[48;5;${IDX}m${CHAR}" + else + (( I++ )) + echo -ne "\e[0m${CHAR}" + fi + # New lines + (( $I % $WIDTH )) || echo -e "\e[0m" +done diff --git a/plugins/catimg/colors.png b/plugins/catimg/colors.png new file mode 100644 index 000000000000..5f2c8126bc0d Binary files /dev/null and b/plugins/catimg/colors.png differ diff --git a/plugins/celery/_celery b/plugins/celery/_celery new file mode 100644 index 000000000000..63af9fad58ce --- /dev/null +++ b/plugins/celery/_celery @@ -0,0 +1,129 @@ +#compdef celery +#autoload + +#celery zsh completion + +_celery () { +local -a _1st_arguments ifargs dopts controlargs + +typeset -A opt_args + +_1st_arguments=('worker' 'events' 'beat' 'shell' 'multi' 'amqp' 'status' 'inspect' \ + 'control' 'purge' 'list' 'migrate' 'call' 'result' 'report') +ifargs=('--app=' '--broker=' '--loader=' '--config=' '--version') +dopts=('--detach' '--umask=' '--gid=' '--uid=' '--pidfile=' '--logfile=' '--loglevel=') +controlargs=('--timeout' '--destination') +_arguments \ + '(-A --app=)'{-A,--app}'[app instance to use (e.g. module.attr_name):APP]' \ + '(-b --broker=)'{-b,--broker}'[url to broker. default is "amqp://guest@localhost//":BROKER]' \ + '(--loader)--loader[name of custom loader class to use.:LOADER]' \ + '(--config)--config[Name of the configuration module:CONFIG]' \ + '(--workdir)--workdir[Optional directory to change to after detaching.:WORKING_DIRECTORY]' \ + '(-q --quiet)'{-q,--quiet}'[Don"t show as much output.]' \ + '(-C --no-color)'{-C,--no-color}'[Don"t display colors.]' \ + '(--version)--version[show program"s version number and exit]' \ + '(- : *)'{-h,--help}'[show this help message and exit]' \ + '*:: :->subcmds' && return 0 + +if (( CURRENT == 1 )); then + _describe -t commands "celery subcommand" _1st_arguments + return +fi + +case "$words[1]" in + worker) + _arguments \ + '(-C --concurrency=)'{-C,--concurrency=}'[Number of child processes processing the queue. The default is the number of CPUs.]' \ + '(--pool)--pool=:::(processes eventlet gevent threads solo)' \ + '(--purge --discard)'{--discard,--purge}'[Purges all waiting tasks before the daemon is started.]' \ + '(-f --logfile=)'{-f,--logfile=}'[Path to log file. If no logfile is specified, stderr is used.]' \ + '(--loglevel=)--loglevel=:::(critical error warning info debug)' \ + '(-N --hostname=)'{-N,--hostname=}'[Set custom hostname, e.g. "foo.example.com".]' \ + '(-B --beat)'{-B,--beat}'[Also run the celerybeat periodic task scheduler.]' \ + '(-s --schedule=)'{-s,--schedule=}'[Path to the schedule database if running with the -B option. Defaults to celerybeat-schedule.]' \ + '(-S --statedb=)'{-S,--statedb=}'[Path to the state database.Default: None]' \ + '(-E --events)'{-E,--events}'[Send events that can be captured by monitors like celeryev, celerymon, and others.]' \ + '(--time-limit=)--time-limit=[nables a hard time limit (in seconds int/float) for tasks]' \ + '(--soft-time-limit=)--soft-time-limit=[Enables a soft time limit (in seconds int/float) for tasks]' \ + '(--maxtasksperchild=)--maxtasksperchild=[Maximum number of tasks a pool worker can execute before it"s terminated and replaced by a new worker.]' \ + '(-Q --queues=)'{-Q,--queues=}'[List of queues to enable for this worker, separated by comma. By default all configured queues are enabled.]' \ + '(-I --include=)'{-I,--include=}'[Comma separated list of additional modules to import.]' \ + '(--pidfile=)--pidfile=[Optional file used to store the process pid.]' \ + '(--autoscale=)--autoscale=[Enable autoscaling by providing max_concurrency, min_concurrency.]' \ + '(--autoreload)--autoreload[Enable autoreloading.]' \ + '(--no-execv)--no-execv[Don"t do execv after multiprocessing child fork.]' + compadd -a ifargs + ;; + inspect) + _values -s \ + 'active[dump active tasks (being processed)]' \ + 'active_queues[dump queues being consumed from]' \ + 'ping[ping worker(s)]' \ + 'registered[dump of registered tasks]' \ + 'report[get bugreport info]' \ + 'reserved[dump reserved tasks (waiting to be processed)]' \ + 'revoked[dump of revoked task ids]' \ + 'scheduled[dump scheduled tasks (eta/countdown/retry)]' \ + 'stats[dump worker statistics]' + compadd -a controlargs ifargs + ;; + control) + _values -s \ + 'add_consumer[tell worker(s) to start consuming a queue]' \ + 'autoscale[change autoscale settings]' \ + 'cancel_consumer[tell worker(s) to stop consuming a queue]' \ + 'disable_events[tell worker(s) to disable events]' \ + 'enable_events[tell worker(s) to enable events]' \ + 'pool_grow[start more pool processes]' \ + 'pool_shrink[use less pool processes]' \ + 'rate_limit[tell worker(s) to modify the rate limit for a task type]' \ + 'time_limit[tell worker(s) to modify the time limit for a task type.]' + compadd -a controlargs ifargs + ;; + multi) + _values -s \ + '--nosplash[Don"t display program info.]' \ + '--verbose[Show more output.]' \ + '--no-color[Don"t display colors.]' \ + '--quiet[Don"t show as much output.]' \ + 'start' 'restart' 'stopwait' 'stop' 'show' \ + 'names' 'expand' 'get' 'kill' + compadd -a ifargs + ;; + amqp) + _values -s \ + 'queue.declare' 'queue.purge' 'exchange.delete' 'basic.publish' \ + 'exchange.declare' 'queue.delete' 'queue.bind' 'basic.get' + ;; + list) + _values -s, 'bindings' + ;; + shell) + _values -s \ + '--ipython[force iPython.]' \ + '--bpython[force bpython.]' \ + '--python[force default Python shell.]' \ + '--without-tasks[don"t add tasks to locals.]' \ + '--eventlet[use eventlet.]' \ + '--gevent[use gevent.]' + compadd -a ifargs + ;; + beat) + _arguments \ + '(-s --schedule=)'{-s,--schedule=}'[Path to the schedule database. Defaults to celerybeat-schedule.]' \ + '(-S --scheduler=)'{-S,--scheduler=}'[Scheduler class to use. Default is celery.beat.PersistentScheduler.]' \ + '(--max-interval)--max-interval[]' + compadd -a dopts fargs + ;; + events) + _arguments \ + '(-d --dump)'{-d,--dump}'[Dump events to stdout.]' \ + '(-c --camera=)'{-c,--camera=}'[Take snapshots of events using this camera.]' \ + '(-F --frequency=)'{-F,--frequency=}'[Camera: Shutter frequency. Default is every 1.0 seconds.]' \ + '(-r --maxrate=)'{-r,--maxrate=}'[Camera: Optional shutter rate limit (e.g. 10/m).]' + compadd -a dopts fargs + ;; + *) + ;; + esac +} diff --git a/plugins/chruby/chruby.plugin.zsh b/plugins/chruby/chruby.plugin.zsh new file mode 100644 index 000000000000..2a2c80cf67e6 --- /dev/null +++ b/plugins/chruby/chruby.plugin.zsh @@ -0,0 +1,99 @@ +# +# INSTRUCTIONS +# +# With either a manual or brew installed chruby things should just work. +# +# If you'd prefer to specify an explicit path to load chruby from +# you can set variables like so: +# +# zstyle :omz:plugins:chruby path /local/path/to/chruby.sh +# zstyle :omz:plugins:chruby auto /local/path/to/auto.sh +# +# TODO +# - autodetermine correct source path on non OS X systems +# - completion if ruby-install exists + +# rvm and rbenv plugins also provide this alias +alias rubies='chruby' + +local _chruby_path +local _chruby_auto + +_homebrew-installed() { + whence brew &> /dev/null +} + +_chruby-from-homebrew-installed() { + brew --prefix chruby &> /dev/null +} + +_ruby-build_installed() { + whence ruby-build &> /dev/null +} + +_ruby-install-installed() { + whence ruby-install &> /dev/null +} + +# Simple definition completer for ruby-build +if _ruby-build_installed; then + _ruby-build() { compadd $(ruby-build --definitions) } + compdef _ruby-build ruby-build +fi + +_source_from_omz_settings() { + zstyle -s :omz:plugins:chruby path _chruby_path + zstyle -s :omz:plugins:chruby auto _chruby_auto + + if _chruby_path && [[ -r _chruby_path ]]; then + source ${_chruby_path} + fi + + if _chruby_auto && [[ -r _chruby_auto ]]; then + source ${_chruby_auto} + fi +} + +_chruby_dirs() { + chrubydirs=($HOME/.rubies/ $PREFIX/opt/rubies) + for dir in chrubydirs; do + if [[ -d $dir ]]; then + RUBIES+=$dir + fi + done +} + +if _homebrew-installed && _chruby-from-homebrew-installed ; then + source $(brew --prefix chruby)/share/chruby/chruby.sh + source $(brew --prefix chruby)/share/chruby/auto.sh + _chruby_dirs +elif [[ -r "/usr/local/share/chruby/chruby.sh" ]] ; then + source /usr/local/share/chruby/chruby.sh + source /usr/local/share/chruby/auto.sh + _chruby_dirs +else + _source_from_omz_settings + _chruby_dirs +fi + +function ensure_chruby() { + $(whence chruby) +} + +function current_ruby() { + local _ruby + _ruby="$(chruby |grep \* |tr -d '* ')" + if [[ $(chruby |grep -c \*) -eq 1 ]]; then + echo ${_ruby} + else + echo "system" + fi +} + +function chruby_prompt_info() { + echo "$(current_ruby)" +} + +# complete on installed rubies +_chruby() { compadd $(chruby | tr -d '* ') } +compdef _chruby chruby diff --git a/plugins/coffee/_coffee b/plugins/coffee/_coffee index 5c8eb9a08405..10b6b816489d 100644 --- a/plugins/coffee/_coffee +++ b/plugins/coffee/_coffee @@ -35,27 +35,37 @@ # ------- # # * Mario Fernandez (https://github.com/sirech) +# * Dong Weiming (https://github.com/dongweiming) # # ------------------------------------------------------------------------------ -local curcontext="$curcontext" state line ret=1 +local curcontext="$curcontext" state line ret=1 version opts first second third typeset -A opt_args +version=(${(f)"$(_call_program version $words[1] --version)"}) +version=${${(z)${version[1]}}[3]} +first=$(echo $version|cut -d '.' -f 1) +second=$(echo $version|cut -d '.' -f 2) +third=$(echo $version|cut -d '.' -f 3) +if (( $first < 2 )) && (( $second < 7 )) && (( $third < 3 ));then + opts+=('(-l --lint)'{-l,--lint}'[pipe the compiled JavaScript through JavaScript Lint]' + '(-r --require)'{-r,--require}'[require a library before executing your script]:library') +fi + _arguments -C \ '(- *)'{-h,--help}'[display this help message]' \ '(- *)'{-v,--version}'[display the version number]' \ + $opts \ '(-b --bare)'{-b,--bare}'[compile without a top-level function wrapper]' \ '(-e --eval)'{-e,--eval}'[pass a string from the command line as input]:Inline Script' \ '(-i --interactive)'{-i,--interactive}'[run an interactive CoffeeScript REPL]' \ '(-j --join)'{-j,--join}'[concatenate the source CoffeeScript before compiling]:Destination JS file:_files -g "*.js"' \ - '(-l --lint)'{-l,--lint}'[pipe the compiled JavaScript through JavaScript Lint]' \ '(--nodejs)--nodejs[pass options directly to the "node" binary]' \ '(-c --compile)'{-c,--compile}'[compile to JavaScript and save as .js files]' \ '(-o --output)'{-o,--output}'[set the output directory for compiled JavaScript]:Output Directory:_files -/' \ '(-n -t -p)'{-n,--nodes}'[print out the parse tree that the parser produces]' \ '(-n -t -p)'{-p,--print}'[print out the compiled JavaScript]' \ '(-n -t -p)'{-t,--tokens}'[print out the tokens that the lexer/rewriter produce]' \ - '(-r --require)'{-r,--require}'[require a library before executing your script]:library' \ '(-s --stdio)'{-s,--stdio}'[listen for and compile scripts over stdio]' \ '(-w --watch)'{-w,--watch}'[watch scripts for changes and rerun commands]' \ '*:script or directory:_files' && ret=0 diff --git a/plugins/common-aliases/common-aliases.plugin.zsh b/plugins/common-aliases/common-aliases.plugin.zsh new file mode 100644 index 000000000000..75899ca2cd52 --- /dev/null +++ b/plugins/common-aliases/common-aliases.plugin.zsh @@ -0,0 +1,94 @@ +# Advanced Aliases. +# Use with caution +# + +# ls, the common ones I use a lot shortened for rapid fire usage +alias ls='ls --color' #I like color +alias l='ls -lFh' #size,show type,human readable +alias la='ls -lAFh' #long list,show almost all,show type,human readable +alias lr='ls -tRFh' #sorted by date,recursive,show type,human readable +alias lt='ls -ltFh' #long list,sorted by date,show type,human readable +alias ll='ls -l' #long list +alias ldot='ls -ld .*' +alias lS='ls -1FSsh' +alias lart='ls -1Fcart' +alias lrt='ls -1Fcrt' + +alias zshrc='vim ~/.zshrc' # Quick access to the ~/.zshrc file + +alias grep='grep --color' +alias sgrep='grep -R -n -H -C 5 --exclude-dir={.git,.svn,CVS} ' + +alias t='tail -f' + +# because typing 'cd' is A LOT of work!! +alias ..='cd ../' +alias ...='cd ../../' +alias ....='cd ../../../' +alias .....='cd ../../../../' + +# Command line head / tail shortcuts +alias -g H='| head' +alias -g T='| tail' +alias -g G='| grep' +alias -g L="| less" +alias -g M="| most" +alias -g LL="2>&1 | less" +alias -g CA="2>&1 | cat -A" +alias -g NE="2> /dev/null" +alias -g NUL="> /dev/null 2>&1" +alias -g P="2>&1| pygmentize -l pytb" + +alias dud='du --max-depth=1 -h' +alias duf='du -sh *' +alias fd='find . -type d -name' +alias ff='find . -type f -name' + +alias h='history' +alias hgrep="fc -El 0 | grep" +alias help='man' +alias j='jobs' +alias p='ps -f' +alias sortnr='sort -n -r' +alias unexport='unset' + +alias whereami=display_info + +alias rm='rm -i' +alias cp='cp -i' +alias mv='mv -i' + +# zsh is able to auto-do some kungfoo +# depends on the SUFFIX :) +if [ ${ZSH_VERSION//\./} -ge 420 ]; then + # open browser on urls + _browser_fts=(htm html de org net com at cx nl se dk dk php) + for ft in $_browser_fts ; do alias -s $ft=$BROWSER ; done + + _editor_fts=(cpp cxx cc c hh h inl asc txt TXT tex) + for ft in $_editor_fts ; do alias -s $ft=$EDITOR ; done + + _image_fts=(jpg jpeg png gif mng tiff tif xpm) + for ft in $_image_fts ; do alias -s $ft=$XIVIEWER; done + + _media_fts=(avi mpg mpeg ogm mp3 wav ogg ape rm mov mkv) + for ft in $_media_fts ; do alias -s $ft=mplayer ; done + + #read documents + alias -s pdf=acroread + alias -s ps=gv + alias -s dvi=xdvi + alias -s chm=xchm + alias -s djvu=djview + + #list whats inside packed file + alias -s zip="unzip -l" + alias -s rar="unrar l" + alias -s tar="tar tf" + alias -s tar.gz="echo " + alias -s ace="unace l" +fi + +# Make zsh know about hosts already accessed by SSH +zstyle -e ':completion:*:(ssh|scp|sftp|rsh|rsync):hosts' hosts 'reply=(${=${${(f)"$(cat {/etc/ssh_,~/.ssh/known_}hosts(|2)(N) /dev/null)"}%%[# ]*}//,/ })' + diff --git a/plugins/composer/composer.plugin.zsh b/plugins/composer/composer.plugin.zsh index 2d155754174d..9975aaca482f 100644 --- a/plugins/composer/composer.plugin.zsh +++ b/plugins/composer/composer.plugin.zsh @@ -10,9 +10,25 @@ _composer_get_command_list () { composer --no-ansi | sed "1,/Available commands/d" | awk '/^ [a-z]+/ { print $1 }' } +_composer_get_required_list () { + composer show -s --no-ansi | sed '1,/requires/d' | awk 'NF > 0 && !/^requires \(dev\)/{ print $1 }' +} + _composer () { + local curcontext="$curcontext" state line + typeset -A opt_args + _arguments \ + '1: :->command'\ + '*: :->args' if [ -f composer.json ]; then - compadd `_composer_get_command_list` + case $state in + command) + compadd `_composer_get_command_list` + ;; + *) + compadd `_composer_get_required_list` + ;; + esac else compadd create-project init search selfupdate show fi diff --git a/plugins/debian/debian.plugin.zsh b/plugins/debian/debian.plugin.zsh index b51d0cd37c25..1e15487ba476 100644 --- a/plugins/debian/debian.plugin.zsh +++ b/plugins/debian/debian.plugin.zsh @@ -1,6 +1,7 @@ # Authors: # https://github.com/AlexBio # https://github.com/dbb +# https://github.com/Mappleconfusers # # Debian-related zsh aliases and functions for zsh @@ -56,7 +57,7 @@ if [[ $use_sudo -eq 1 ]]; then alias ar='sudo $apt_pref remove' # apt-get only - alias ads='sudo $apt_pref dselect-upgrade' + alias ads='sudo apt-get dselect-upgrade' # Install all .deb files in the current directory. # Warning: you will need to put the glob in single quotes if you use: @@ -109,6 +110,38 @@ else ?not(~n`uname -r`))'\'' root' fi +# Completion ################################################################ + +# +# Registers a compdef for $1 that calls $apt_pref with the commands $2 +# To do that it creates a new completion function called _apt_pref_$2 +# +apt_pref_compdef() { + local f fb + f="_apt_pref_${2}" + + eval "function ${f}() { + shift words; + service=\"\$apt_pref\"; + words=(\"\$apt_pref\" '$2' \$words); + ((CURRENT++)) + test \"\${apt_pref}\" = 'aptitude' && _aptitude || _apt + }" + + compdef "$f" "$1" +} + +apt_pref_compdef aac "autoclean" +apt_pref_compdef abd "build-dep" +apt_pref_compdef ac "clean" +apt_pref_compdef ad "update" +apt_pref_compdef afu "update" +apt_pref_compdef ag "upgrade" +apt_pref_compdef ai "install" +apt_pref_compdef ail "install" +apt_pref_compdef ap "purge" +apt_pref_compdef ar "remove" +apt_pref_compdef ads "dselect-upgrade" # Misc. ##################################################################### # print all installed packages diff --git a/plugins/docker/README.md b/plugins/docker/README.md new file mode 100644 index 000000000000..231a6dcf5d1f --- /dev/null +++ b/plugins/docker/README.md @@ -0,0 +1,19 @@ +## Docker autocomplete plugin + +- Adds autocomplete options for all docker commands. +- Will also show containerIDs and Image names where applicable + +####Shows help for all commands +![General Help](http://i.imgur.com/tUBO9jh.png "Help for all commands") + + +####Shows your downloaded images where applicable +![Images](http://i.imgur.com/R8ZsWO1.png "Images") + + +####Shows your running containers where applicable +![Containers](http://i.imgur.com/WQtbheg.png "Containers") + + + +Maintainer : Ahmed Azaan ([@aeonazaan](https://twitter.com/aeonazaan)) diff --git a/plugins/docker/_docker b/plugins/docker/_docker new file mode 100644 index 000000000000..f13f876cf9c9 --- /dev/null +++ b/plugins/docker/_docker @@ -0,0 +1,290 @@ +#compdef docker + +# Docker autocompletion for oh-my-zsh +# Requires: Docker installed +# Author : Azaan (@aeonazaan) + + +# ----- Helper functions +# Output a selectable list of all running docker containers +__docker_containers() { + declare -a cont_cmd + cont_cmd=($(docker ps | awk 'NR>1{print $1":[CON("$1")"$2"("$3")]"}')) + _describe 'containers' cont_cmd +} + +# output a selectable list of all docker images +__docker_images() { + declare -a img_cmd + img_cmd=($(docker images | awk 'NR>1{print $1}')) + _describe 'images' img_cmd +} + +# ----- Commands +# Seperate function for each command, makes extension easier later +# --------------------------- +__attach() { + __docker_containers +} + +__build() { + _arguments \ + '-q=false[Suppress verbose build output]' \ + '-t="[fuck to be applied to the resulting image in case of success]' \ + '*:files:_files' +} + +__commit() { + _arguments \ + '-author="[Author]' \ + '-m="[Commit message]' \ + '-run="[Config automatically applied when the image is run.\n]' + __docker_containers +} + +__diff() { + __docker_containers +} + +__export() { + __docker_containers +} + + +__history() { + __docker_images +} + +__images() { + _arguments \ + '-a[show all images]' \ + '-notrunc[dont truncate output]' \ + '-q[only show numeric IDs]' \ + '-viz[output graph in graphviz format]' + __docker_images +} + +__import() { + _arguments '*:files:_files' +} + +__info() { + # no arguments +} + +__insert() { + __docker_images + _arguments '*:files:_files' +} + +__inspect() { + __docker_images + __docker_containers +} + +__kill() { + __docker_containers +} + +__login() { + _arguments \ + '-e="[email]' \ + '-p="[password]' \ + '-u="[username]' \ +} + +__logs() { + __docker_containers +} + +__port() { + __docker_containers +} + +__top() { + __docker_containers +} + +__ps() { + _arguments \ + '-a[Show all containers. Only running containers are shown by default.]' \ + '-beforeId="[Show only container created before Id, include non-running ones.]' \ + '-l[Show only the latest created container, include non-running ones.]' \ + '-n=[Show n last created containers, include non-running ones.]' \ + '-notrurrrrnc[Dont truncate output]' \ + '-q[Only display numeric IDs]' \ + '-s[Display sizes]' \ + '-sinceId="[Show only containers created since Id, include non-running ones.]' +} + +__pull() { + _arguments '-t="[Download tagged image in repository]' +} + +__push() { + +} + +__restart() { + _arguments '-t=[number of seconds to try to stop before killing]' + __docker_containers +} + +__rm() { + _arguments '-v[Remove the volumes associated to the container]' + __docker_containers +} + +__rmi() { + __docker_images +} + +__run() { + _arguments \ + '-a=[Attach to stdin, stdout or stderr.]' \ + '-c=[CPU shares (relative weight)]' \ + '-d[Detached mode: leave the container running in the background]' \ + '-dns=[Set custom dns servers]' \ + '-e=[Set environment variables]' \ + '-entrypoint="[Overwrite the default entrypoint of the image]' \ + '-h="[Container host name]' \ + '-i[Keep stdin open even if not attached]' \ + '-m=[Memory limit (in bytes)]' \ + '-p=[Expose a containers port to the host (use docker port to see the actual mapping)]' \ + '-t[Allocate a pseudo-tty]' \ + '-u="[Username or UID]' \ + '-v=[Bind mount a volume (e.g. from the host: -v /host:/container, from docker: -v /container)]' \ + '-volumes-from="[Mount volumes from the specified container]' + __docker_images +} + +__search() { + _arguments '-notrunc[Dont truncate output]' +} + +__start() { + __docker_containers +} + +__stop() { + _arguments '-t=[number of seconds to try to stop before killing]' + __docker_containers +} + +__tag() { + _arguments '-f[Force]' + __docker_images +} + +__version() { + +} + +__wait() { + __docker_containers +} + +# end commands --------- +# ---------------------- + +local -a _1st_arguments +_1st_arguments=( + "attach":"Attach to a running container" + "build":"Build a container from a Dockerfile" + "commit":"Create a new image from a container's changes" + "diff":"Inspect changes on a container's filesystem" + "export":"Stream the contents of a container as a tar archive" + "history":"Show the history of an image" + "images":"List images" + "import":"Create a new filesystem image from the contents of a tarball" + "info":"Display system-wide information" + "insert":"Insert a file in an image" + "inspect":"Return low-level information on a container" + "kill":"Kill a running container" + "login":"Register or Login to the docker registry server" + "logs":"Fetch the logs of a container" + "port":"Lookup the public-facing port which is NAT-ed to PRIVATE_PORT" + "top":"Lookup the running processes of a container" + "ps":"List containers" + "pull":"Pull an image or a repository from the docker registry server" + "push":"Push an image or a repository to the docker registry server" + "restart":"Restart a running container" + "rm":"Remove one or more containers" + "rmi":"Remove one or more images" + "run":"Run a command in a new container" + "search":"Search for an image in the docker index" + "start":"Start a stopped container" + "stop":"Stop a running container" + "tag":"Tag an image into a repository" + "version":"Show the docker version information" + "wait":"Block until a container stops, then print its exit code" +) + +_arguments '*:: :->command' + +if (( CURRENT == 1 )); then + _describe -t commands "docker command" _1st_arguments + return +fi + +local -a _command_args +case "$words[1]" in + attach) + __docker_containers ;; + build) + __build ;; + commit) + __commit ;; + diff) + __diff ;; + export) + __export ;; + history) + __history ;; + images) + __images ;; + import) + __import ;; + info) + __info ;; + insert) + __insert ;; + inspect) + __inspect ;; + kill) + __kill ;; + login) + __login ;; + logs) + __logs ;; + port) + __port ;; + top) + __top ;; + ps) + __ps ;; + pull) + __pull ;; + push) + __push ;; + restart) + __restart ;; + rm) + __rm ;; + rmi) + __rmi ;; + run) + __run ;; + search) + __search ;; + start) + __start ;; + stop) + __stop ;; + tag) + __tag ;; + version) + __version ;; + wait) + __wait ;; +esac diff --git a/plugins/extract/extract.plugin.zsh b/plugins/extract/extract.plugin.zsh index 23e86c593bba..7352e5bad8c7 100644 --- a/plugins/extract/extract.plugin.zsh +++ b/plugins/extract/extract.plugin.zsh @@ -52,7 +52,7 @@ function extract() { (*.xz) unxz "$1" ;; (*.lzma) unlzma "$1" ;; (*.Z) uncompress "$1" ;; - (*.zip) unzip "$1" -d $extract_dir ;; + (*.zip|*.war|*.jar) unzip "$1" -d $extract_dir ;; (*.rar) unrar x -ad "$1" ;; (*.7z) 7za x "$1" ;; (*.deb) diff --git a/plugins/fastfile/fastfile.plugin.zsh b/plugins/fastfile/fastfile.plugin.zsh new file mode 100644 index 000000000000..775e9483e35c --- /dev/null +++ b/plugins/fastfile/fastfile.plugin.zsh @@ -0,0 +1,138 @@ +################################################################################ +# FILE: fastfile.plugin.zsh +# DESCRIPTION: oh-my-zsh plugin file. +# AUTHOR: Michael Varner (musikmichael@web.de) +# VERSION: 1.0.0 +# +# This plugin adds the ability to on the fly generate and access file shortcuts. +# +################################################################################ + +########################### +# Settings + +# These can be overwritten any time. +# If they are not set yet, they will be +# overwritten with their default values + +default fastfile_dir "${HOME}/.fastfile/" +default fastfile_var_prefix "§" + +########################### +# Impl + +# +# Generate a shortcut +# +# Arguments: +# 1. name - The name of the shortcut (default: name of the file) +# 2. file - The file or directory to make the shortcut for +# STDOUT: +# => fastfle_print +# +function fastfile() { + test "$2" || 2="." + file=$(readlink -f "$2") + + test "$1" || 1="$(basename "$file")" + name=$(echo "$1" | tr " " "_") + + + mkdir -p "${fastfile_dir}" + echo "$file" > "$(fastfile_resolv "$name")" + + fastfile_sync + fastfile_print "$name" +} + +# +# Resolve the location of a shortcut file (the database file, where the value is written!) +# +# Arguments: +# 1. name - The name of the shortcut +# STDOUT: +# The path +# +function fastfile_resolv() { + echo "${fastfile_dir}${1}" +} + +# +# Get the real path of a shortcut +# +# Arguments: +# 1. name - The name of the shortcut +# STDOUT: +# The path +# +function fastfile_get() { + cat "$(fastfile_resolv "$1")" +} + +# +# Print a shortcut +# +# Arguments: +# 1. name - The name of the shortcut +# STDOUT: +# Name and value of the shortcut +# +function fastfile_print() { + echo "${fastfile_var_prefix}${1} -> $(fastfile_get "$1")" +} + +# +# List all shortcuts +# +# STDOUT: +# (=> fastfle_print) for each shortcut +# +function fastfile_ls() { + for f in "${fastfile_dir}"/*; do + file=`basename "$f"` # To enable simpler handeling of spaces in file names + varkey=`echo "$file" | tr " " "_"` + + # Special format for colums + echo "${fastfile_var_prefix}${varkey}|->|$(fastfile_get "$file")" + done | column -t -s "|" +} + +# +# Remove a shortcut +# +# Arguments: +# 1. name - The name of the shortcut (default: name of the file) +# 2. file - The file or directory to make the shortcut for +# STDOUT: +# => fastfle_print +# +function fastfile_rm() { + fastfile_print "$1" + rm "$(fastfile_resolv "$1")" +} + +# +# Generate the aliases for the shortcuts +# +function fastfile_sync() { + for f in "${fastfile_dir}"/*; do + file=`basename "$f"` # To enable simpler handeling of spaces in file names + varkey=`echo "$file" | tr " " "_"` + + alias -g "${fastfile_var_prefix}${varkey}"="'$(fastfile_get "$file")'" + done +} + +################################## +# Shortcuts + +alias ff=fastfile +alias ffp=fastfile_print +alias ffrm=fastfile_rm +alias ffls=fastfile_ls +alias ffsync=fastfile_sync + +################################## +# Init + +fastfile_sync \ No newline at end of file diff --git a/plugins/forklift/forklift.plugin.zsh b/plugins/forklift/forklift.plugin.zsh index 056069d36211..b0e60a43440f 100644 --- a/plugins/forklift/forklift.plugin.zsh +++ b/plugins/forklift/forklift.plugin.zsh @@ -1,5 +1,6 @@ -# Open folder in ForkLift.app from console +# Open folder in ForkLift.app of ForkLift2.app from console # Author: Adam Strzelecki nanoant.com, modified by Bodo Tasche bitboxer.de +# Updated to support ForkLift2 by Johan Kaving # # Usage: # fl [] @@ -22,9 +23,33 @@ function fl { fi fi osascript 2>&1 1>/dev/null < 1)) && + ignored+=(${line[1,CURRENT-1]//(#m)[\[\]()\\*?#<>~\^]/\\$MATCH}) + ((CURRENT < $#line)) && + ignored+=(${line[CURRENT+1,-1]//(#m)[\[\]()\\*?#<>~\^]/\\$MATCH}) + $* -F ignored +} + +(( $+functions[__git_ignore_line_inside_arguments] )) || +__git_ignore_line_inside_arguments () { + declare -a compadd_opts + + zparseopts -D -E -a compadd_opts V: J: 1 2 n f X: M: P: S: r: R: q F: + + __git_ignore_line $* $compadd_opts +} + diff --git a/plugins/git/_git-remote b/plugins/git/_git-remote new file mode 100644 index 000000000000..4ba62a357b88 --- /dev/null +++ b/plugins/git/_git-remote @@ -0,0 +1,74 @@ +#compdef git-remote + +# NOTE: --track is undocumented. +# TODO: --track, -t, --master, and -m should take remote branches, I guess. +# NOTE: --master is undocumented. +# NOTE: --fetch is undocumented. +_git-remote () { + local curcontext=$curcontext state line + declare -A opt_args + + _arguments -C \ + ':command:->command' \ + '*::options:->options' && ret=0 + + case $state in + (command) + declare -a commands + + commands=( + 'add:add a new remote' + 'show:show information about a given remote' + 'prune:delete all stale tracking branches for a given remote' + 'update:fetch updates for a set of remotes' + 'rm:remove a remote from .git/config and all associated tracking branches' + 'rename:rename a remote from .git/config and update all associated tracking branches' + 'set-head:sets or deletes the default branch' + 'set-branches:changes the list of branches tracked by the named remote.' + 'set-url:changes URL remote points to.' + ) + + _describe -t commands 'sub-command' commands && ret=0 + ;; + (options) + case $line[1] in + (add) + _arguments \ + '*'{--track,-t}'[track given branch instead of default glob refspec]:branch:__git_branch_names' \ + '(--master -m)'{--master,-m}'[set the remote'\''s HEAD to point to given master branch]:branch:__git_branch_names' \ + '(--fetch -f)'{--fetch,-f}'[run git-fetch on the new remote after it has been created]' \ + ':branch name:__git_remotes' \ + ':url:_urls' && ret=0 + ;; + (show) + _arguments \ + '-n[do not contact the remote for a list of branches]' \ + ':remote:__git_remotes' && ret=0 + ;; + (prune) + _arguments \ + '(--dry-run -n)'{-n,--dry-run}'[do not actually prune, only list what would be done]' \ + ':remote:__git_remotes' && ret=0 + ;; + (update) + __git_remote-groups && ret=0 + ;; + (rm) + __git_remotes && ret=0 + ;; + (rename) + __git_remotes && ret=0 + ;; + (set-url) + _arguments \ + '*--push[manipulate push URLs]' \ + '(--add)--add[add URL]' \ + '(--delete)--delete[delete URLs]' \ + ':branch name:__git_remotes' \ + ':url:_urls' && ret=0 + ;; + + esac + ;; + esac +} diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index 6c016aa6be11..2b5983f33922 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -5,6 +5,8 @@ alias gst='git status' compdef _git gst=git-status alias gd='git diff' compdef _git gd=git-diff +alias gdc='git diff --cached' +compdef _git gdc=git-diff alias gl='git pull' compdef _git gl=git-pull alias gup='git pull --rebase' @@ -22,6 +24,8 @@ alias gca='git commit -v -a' compdef _git gc=git-commit alias gca!='git commit -v -a --amend' compdef _git gca!=git-commit +alias gcmsg='git commit -m' +compdef _git gcmsg=git-commit alias gco='git checkout' compdef _git gco=git-checkout alias gcm='git checkout master' @@ -37,6 +41,12 @@ alias grset='git remote set-url' compdef _git grset=git-remote alias grup='git remote update' compdef _git grset=git-remote +alias grbi='git rebase -i' +compdef _git grbi=git-rebase +alias grbc='git rebase --continue' +compdef _git grbc=git-rebase +alias grba='git rebase --abort' +compdef _git grba=git-rebase alias gb='git branch' compdef _git gb=git-branch alias gba='git branch -a' @@ -46,14 +56,16 @@ compdef gcount=git alias gcl='git config --list' alias gcp='git cherry-pick' compdef _git gcp=git-cherry-pick -alias glg='git log --stat --max-count=5' +alias glg='git log --stat --max-count=10' compdef _git glg=git-log -alias glgg='git log --graph --max-count=5' +alias glgg='git log --graph --max-count=10' compdef _git glgg=git-log alias glgga='git log --graph --decorate --all' compdef _git glgga=git-log -alias glo='git log --oneline' +alias glo='git log --oneline --decorate --color' compdef _git glo=git-log +alias glog='git log --oneline --decorate --color --graph' +compdef _git glog=git-log alias gss='git status -s' compdef _git gss=git-status alias ga='git add' @@ -62,9 +74,24 @@ alias gm='git merge' compdef _git gm=git-merge alias grh='git reset HEAD' alias grhh='git reset HEAD --hard' +alias gclean='git reset --hard && git clean -dfx' alias gwc='git whatchanged -p --abbrev-commit --pretty=medium' -alias gf='git ls-files | grep' + +#remove the gf alias +#alias gf='git ls-files | grep' + alias gpoat='git push origin --all && git push origin --tags' +alias gmt='git mergetool --no-prompt' +compdef _git gm=git-mergetool + +alias gg='git gui citool' +alias gga='git gui citool --amend' +alias gk='gitk --all --branches' + +alias gsts='git stash show --text' +alias gsta='git stash' +alias gstp='git stash pop' +alias gstd='git stash drop' # Will cd into the top of the current repository # or submodule. @@ -95,6 +122,8 @@ function current_repository() { # these aliases take advantage of the previous function alias ggpull='git pull origin $(current_branch)' compdef ggpull=git +alias ggpur='git pull --rebase origin $(current_branch)' +compdef ggpur=git alias ggpush='git push origin $(current_branch)' compdef ggpush=git alias ggpnp='git pull origin $(current_branch) && git push origin $(current_branch)' @@ -108,3 +137,26 @@ function _git_log_prettily(){ } alias glp="_git_log_prettily" compdef _git glp=git-log + +# Work In Progress (wip) +# These features allow to pause a branch development and switch to another one (wip) +# When you want to go back to work, just unwip it +# +# This function return a warning if the current branch is a wip +function work_in_progress() { + if $(git log -n 1 2>/dev/null | grep -q -c "\-\-wip\-\-"); then + echo "WIP!!" + fi +} +# these alias commit and uncomit wip branches +alias gwip='git add -A; git ls-files --deleted -z | xargs -0 git rm; git commit -m "--wip--"' +alias gunwip='git log -n 1 | grep -q -c "\-\-wip\-\-" && git reset HEAD~1' + +# these alias ignore changes to file +alias gignore='git update-index --assume-unchanged' +alias gunignore='git update-index --no-assume-unchanged' +# list temporarily ignored files +alias gignored='git ls-files -v | grep "^[[:lower:]]"' + + + diff --git a/plugins/gitfast/_git b/plugins/gitfast/_git index cf8116d4770c..fac5e711ebbb 100644 --- a/plugins/gitfast/_git +++ b/plugins/gitfast/_git @@ -2,18 +2,19 @@ # zsh completion wrapper for git # -# You need git's bash completion script installed somewhere, by default on the -# same directory as this script. +# Copyright (c) 2012-2013 Felipe Contreras # -# If your script is on ~/.git-completion.sh instead, you can configure it on -# your ~/.zshrc: +# You need git's bash completion script installed somewhere, by default it +# would be the location bash-completion uses. +# +# If your script is somewhere else, you can configure it on your ~/.zshrc: # # zstyle ':completion:*:*:git:*' script ~/.git-completion.sh # -# The recommended way to install this script is to copy to -# '~/.zsh/completion/_git', and then add the following to your ~/.zshrc file: +# The recommended way to install this script is to copy to '~/.zsh/_git', and +# then add the following to your ~/.zshrc file: # -# fpath=(~/.zsh/completion $fpath) +# fpath=(~/.zsh $fpath) complete () { @@ -21,8 +22,23 @@ complete () return 0 } +zstyle -T ':completion:*:*:git:*' tag-order && \ + zstyle ':completion:*:*:git:*' tag-order 'common-commands' + zstyle -s ":completion:*:*:git:*" script script -test -z "$script" && script="$(dirname ${funcsourcetrace[1]%:*})"/git-completion.bash +if [ -z "$script" ]; then + local -a locations + local e + locations=( + '/etc/bash_completion.d/git' # fedora, old debian + '/usr/share/bash-completion/completions/git' # arch, ubuntu, new debian + '/usr/share/bash-completion/git' # gentoo + $(dirname ${funcsourcetrace[1]%:*})/git-completion.bash + ) + for e in $locations; do + test -f $e && script="$e" && break + done +fi ZSH_VERSION='' . "$script" __gitcomp () @@ -69,18 +85,131 @@ __gitcomp_file () compadd -Q -p "${2-}" -f -- ${=1} && _ret=0 } +__git_zsh_bash_func () +{ + emulate -L ksh + + local command=$1 + + local completion_func="_git_${command//-/_}" + declare -f $completion_func >/dev/null && $completion_func && return + + local expansion=$(__git_aliased_command "$command") + if [ -n "$expansion" ]; then + completion_func="_git_${expansion//-/_}" + declare -f $completion_func >/dev/null && $completion_func + fi +} + +__git_zsh_cmd_common () +{ + local -a list + list=( + add:'add file contents to the index' + bisect:'find by binary search the change that introduced a bug' + branch:'list, create, or delete branches' + checkout:'checkout a branch or paths to the working tree' + clone:'clone a repository into a new directory' + commit:'record changes to the repository' + diff:'show changes between commits, commit and working tree, etc' + fetch:'download objects and refs from another repository' + grep:'print lines matching a pattern' + init:'create an empty Git repository or reinitialize an existing one' + log:'show commit logs' + merge:'join two or more development histories together' + mv:'move or rename a file, a directory, or a symlink' + pull:'fetch from and merge with another repository or a local branch' + push:'update remote refs along with associated objects' + rebase:'forward-port local commits to the updated upstream head' + reset:'reset current HEAD to the specified state' + rm:'remove files from the working tree and from the index' + show:'show various types of objects' + status:'show the working tree status' + tag:'create, list, delete or verify a tag object signed with GPG') + _describe -t common-commands 'common commands' list && _ret=0 +} + +__git_zsh_cmd_alias () +{ + local -a list + list=(${${${(0)"$(git config -z --get-regexp '^alias\.')"}#alias.}%$'\n'*}) + _describe -t alias-commands 'aliases' list $* && _ret=0 +} + +__git_zsh_cmd_all () +{ + local -a list + emulate ksh -c __git_compute_all_commands + list=( ${=__git_all_commands} ) + _describe -t all-commands 'all commands' list && _ret=0 +} + +__git_zsh_main () +{ + local curcontext="$curcontext" state state_descr line + typeset -A opt_args + local -a orig_words + + orig_words=( ${words[@]} ) + + _arguments -C \ + '(-p --paginate --no-pager)'{-p,--paginate}'[pipe all output into ''less'']' \ + '(-p --paginate)--no-pager[do not pipe git output into a pager]' \ + '--git-dir=-[set the path to the repository]: :_directories' \ + '--bare[treat the repository as a bare repository]' \ + '(- :)--version[prints the git suite version]' \ + '--exec-path=-[path to where your core git programs are installed]:: :_directories' \ + '--html-path[print the path where git''s HTML documentation is installed]' \ + '--info-path[print the path where the Info files are installed]' \ + '--man-path[print the manpath (see `man(1)`) for the man pages]' \ + '--work-tree=-[set the path to the working tree]: :_directories' \ + '--namespace=-[set the git namespace]' \ + '--no-replace-objects[do not use replacement refs to replace git objects]' \ + '(- :)--help[prints the synopsis and a list of the most commonly used commands]: :->arg' \ + '(-): :->command' \ + '(-)*:: :->arg' && return + + case $state in + (command) + _alternative \ + 'alias-commands:alias:__git_zsh_cmd_alias' \ + 'common-commands:common:__git_zsh_cmd_common' \ + 'all-commands:all:__git_zsh_cmd_all' && _ret=0 + ;; + (arg) + local command="${words[1]}" __git_dir + + if (( $+opt_args[--bare] )); then + __git_dir='.' + else + __git_dir=${opt_args[--git-dir]} + fi + + (( $+opt_args[--help] )) && command='help' + + words=( ${orig_words[@]} ) + + __git_zsh_bash_func $command + ;; + esac +} + _git () { local _ret=1 - () { - emulate -L ksh - local cur cword prev - cur=${words[CURRENT-1]} - prev=${words[CURRENT-2]} - let cword=CURRENT-1 - __${service}_main - } - let _ret && _default -S '' && _ret=0 + local cur cword prev + + cur=${words[CURRENT]} + prev=${words[CURRENT-1]} + let cword=CURRENT-1 + + if (( $+functions[__${service}_zsh_main] )); then + __${service}_zsh_main + else + emulate ksh -c __${service}_main + fi + + let _ret && _default && _ret=0 return _ret } diff --git a/plugins/gitfast/git-completion.bash b/plugins/gitfast/git-completion.bash index 93eba4675022..5da920ecd9ec 100644 --- a/plugins/gitfast/git-completion.bash +++ b/plugins/gitfast/git-completion.bash @@ -33,8 +33,6 @@ esac # returns location of .git repo __gitdir () { - # Note: this function is duplicated in git-prompt.sh - # When updating it, make sure you update the other one to match. if [ -z "${1-}" ]; then if [ -n "${__git_dir-}" ]; then echo "$__git_dir" @@ -53,19 +51,6 @@ __gitdir () fi } -__gitcomp_1 () -{ - local c IFS=$' \t\n' - for c in $1; do - c="$c$2" - case $c in - --*=*|*.) ;; - *) c="$c " ;; - esac - printf '%s\n' "$c" - done -} - # The following function is based on code from: # # bash_completion - programmable completion functions for bash 3.2+ @@ -195,8 +180,18 @@ _get_comp_words_by_ref () } fi -# Generates completion reply with compgen, appending a space to possible -# completion words, if necessary. +__gitcompadd () +{ + local i=0 + for x in $1; do + if [[ "$x" == "$3"* ]]; then + COMPREPLY[i++]="$2$x$4" + fi + done +} + +# Generates completion reply, appending a space to possible completion words, +# if necessary. # It accepts 1 to 4 arguments: # 1: List of possible completion words. # 2: A prefix to be added to each possible completion word (optional). @@ -208,19 +203,25 @@ __gitcomp () case "$cur_" in --*=) - COMPREPLY=() ;; *) - local IFS=$'\n' - COMPREPLY=($(compgen -P "${2-}" \ - -W "$(__gitcomp_1 "${1-}" "${4-}")" \ - -- "$cur_")) + local c i=0 IFS=$' \t\n' + for c in $1; do + c="$c${4-}" + if [[ $c == "$cur_"* ]]; then + case $c in + --*=*|*.) ;; + *) c="$c " ;; + esac + COMPREPLY[i++]="${2-}$c" + fi + done ;; esac } -# Generates completion reply with compgen from newline-separated possible -# completion words by appending a space to all of them. +# Generates completion reply from newline-separated possible completion words +# by appending a space to all of them. # It accepts 1 to 4 arguments: # 1: List of possible completion words, separated by a single newline. # 2: A prefix to be added to each possible completion word (optional). @@ -231,7 +232,7 @@ __gitcomp () __gitcomp_nl () { local IFS=$'\n' - COMPREPLY=($(compgen -P "${2-}" -S "${4- }" -W "$1" -- "${3-$cur}")) + __gitcompadd "$1" "${2-}" "${3-$cur}" "${4- }" } # Generates completion reply with compgen from newline-separated possible @@ -249,106 +250,50 @@ __gitcomp_file () # since tilde expansion is not applied. # This means that COMPREPLY will be empty and Bash default # completion will be used. - COMPREPLY=($(compgen -P "${2-}" -W "$1" -- "${3-$cur}")) - - # Tell Bash that compspec generates filenames. - compopt -o filenames 2>/dev/null -} - -__git_index_file_list_filter_compat () -{ - local path + __gitcompadd "$1" "${2-}" "${3-$cur}" "" - while read -r path; do - case "$path" in - ?*/*) echo "${path%%/*}/" ;; - *) echo "$path" ;; - esac - done + # use a hack to enable file mode in bash < 4 + compopt -o filenames +o nospace 2>/dev/null || + compgen -f /non-existing-dir/ > /dev/null } -__git_index_file_list_filter_bash () -{ - local path - - while read -r path; do - case "$path" in - ?*/*) - # XXX if we append a slash to directory names when using - # `compopt -o filenames`, Bash will append another slash. - # This is pretty stupid, and this the reason why we have to - # define a compatible version for this function. - echo "${path%%/*}" ;; - *) - echo "$path" ;; - esac - done -} - -# Process path list returned by "ls-files" and "diff-index --name-only" -# commands, in order to list only file names relative to a specified -# directory, and append a slash to directory names. -__git_index_file_list_filter () -{ - # Default to Bash >= 4.x - __git_index_file_list_filter_bash -} - -# Execute git ls-files, returning paths relative to the directory -# specified in the first argument, and using the options specified in -# the second argument. +# Execute 'git ls-files', unless the --committable option is specified, in +# which case it runs 'git diff-index' to find out the files that can be +# committed. It return paths relative to the directory specified in the first +# argument, and using the options specified in the second argument. __git_ls_files_helper () { ( test -n "${CDPATH+set}" && unset CDPATH - # NOTE: $2 is not quoted in order to support multiple options - cd "$1" && git ls-files --exclude-standard $2 + cd "$1" + if [ "$2" == "--committable" ]; then + git diff-index --name-only --relative HEAD + else + # NOTE: $2 is not quoted in order to support multiple options + git ls-files --exclude-standard $2 + fi ) 2>/dev/null } -# Execute git diff-index, returning paths relative to the directory -# specified in the first argument, and using the tree object id -# specified in the second argument. -__git_diff_index_helper () -{ - ( - test -n "${CDPATH+set}" && unset CDPATH - cd "$1" && git diff-index --name-only --relative "$2" - ) 2>/dev/null -} - # __git_index_files accepts 1 or 2 arguments: # 1: Options to pass to ls-files (required). -# Supported options are --cached, --modified, --deleted, --others, -# and --directory. # 2: A directory path (optional). # If provided, only files within the specified directory are listed. # Sub directories are never recursed. Path must have a trailing # slash. __git_index_files () { - local dir="$(__gitdir)" root="${2-.}" + local dir="$(__gitdir)" root="${2-.}" file if [ -d "$dir" ]; then - __git_ls_files_helper "$root" "$1" | __git_index_file_list_filter | - sort | uniq - fi -} - -# __git_diff_index_files accepts 1 or 2 arguments: -# 1) The id of a tree object. -# 2) A directory path (optional). -# If provided, only files within the specified directory are listed. -# Sub directories are never recursed. Path must have a trailing -# slash. -__git_diff_index_files () -{ - local dir="$(__gitdir)" root="${2-.}" - - if [ -d "$dir" ]; then - __git_diff_index_helper "$root" "$1" | __git_index_file_list_filter | - sort | uniq + __git_ls_files_helper "$root" "$1" | + while read -r file; do + case "$file" in + ?*/*) echo "${file%%/*}" ;; + *) echo "$file" ;; + esac + done | sort | uniq fi } @@ -424,14 +369,8 @@ __git_refs () done ;; *) - git ls-remote "$dir" HEAD ORIG_HEAD 'refs/tags/*' 'refs/heads/*' 'refs/remotes/*' 2>/dev/null | \ - while read -r hash i; do - case "$i" in - *^{}) ;; - refs/*) echo "${i#refs/*/}" ;; - *) echo "$i" ;; - esac - done + echo "HEAD" + git for-each-ref --format="%(refname:short)" -- "refs/remotes/$dir/" | sed -e "s#^$dir/##" ;; esac } @@ -549,44 +488,23 @@ __git_complete_revlist_file () } -# __git_complete_index_file requires 1 argument: the options to pass to -# ls-file +# __git_complete_index_file requires 1 argument: +# 1: the options to pass to ls-file +# +# The exception is --committable, which finds the files appropriate commit. __git_complete_index_file () { - local pfx cur_="$cur" + local pfx="" cur_="$cur" case "$cur_" in ?*/*) pfx="${cur_%/*}" cur_="${cur_##*/}" pfx="${pfx}/" - - __gitcomp_file "$(__git_index_files "$1" "$pfx")" "$pfx" "$cur_" - ;; - *) - __gitcomp_file "$(__git_index_files "$1")" "" "$cur_" ;; esac -} - -# __git_complete_diff_index_file requires 1 argument: the id of a tree -# object -__git_complete_diff_index_file () -{ - local pfx cur_="$cur" - case "$cur_" in - ?*/*) - pfx="${cur_%/*}" - cur_="${cur_##*/}" - pfx="${pfx}/" - - __gitcomp_file "$(__git_diff_index_files "$1" "$pfx")" "$pfx" "$cur_" - ;; - *) - __gitcomp_file "$(__git_diff_index_files "$1")" "" "$cur_" - ;; - esac + __gitcomp_file "$(__git_index_files "$1" "$pfx")" "$pfx" "$cur_" } __git_complete_file () @@ -614,7 +532,6 @@ __git_complete_remote_or_refspec () case "$cmd" in push) no_complete_refspec=1 ;; fetch) - COMPREPLY=() return ;; *) ;; @@ -630,7 +547,6 @@ __git_complete_remote_or_refspec () return fi if [ $no_complete_refspec = 1 ]; then - COMPREPLY=() return fi [ "$remote" = "." ] && remote= @@ -732,6 +648,7 @@ __git_list_porcelain_commands () cat-file) : plumbing;; check-attr) : plumbing;; check-ignore) : plumbing;; + check-mailmap) : plumbing;; check-ref-format) : plumbing;; checkout-index) : plumbing;; commit-tree) : plumbing;; @@ -951,7 +868,6 @@ _git_am () " return esac - COMPREPLY=() } _git_apply () @@ -971,7 +887,6 @@ _git_apply () " return esac - COMPREPLY=() } _git_add () @@ -1031,7 +946,6 @@ _git_bisect () __gitcomp_nl "$(__git_refs)" ;; *) - COMPREPLY=() ;; esac } @@ -1124,9 +1038,14 @@ _git_cherry () _git_cherry_pick () { + local dir="$(__gitdir)" + if [ -f "$dir"/CHERRY_PICK_HEAD ]; then + __gitcomp "--continue --quit --abort" + return + fi case "$cur" in --*) - __gitcomp "--edit --no-commit" + __gitcomp "--edit --no-commit --signoff --strategy= --mainline" ;; *) __gitcomp_nl "$(__git_refs)" @@ -1170,7 +1089,6 @@ _git_clone () return ;; esac - COMPREPLY=() } _git_commit () @@ -1182,13 +1100,6 @@ _git_commit () ;; esac - case "$prev" in - -c|-C) - __gitcomp_nl "$(__git_refs)" "" "${cur}" - return - ;; - esac - case "$cur" in --cleanup=*) __gitcomp "default strip verbatim whitespace @@ -1218,7 +1129,7 @@ _git_commit () esac if git rev-parse --verify --quiet HEAD >/dev/null; then - __git_complete_diff_index_file "HEAD" + __git_complete_index_file "--committable" else # This is the first commit __git_complete_index_file "--cached" @@ -1251,7 +1162,7 @@ __git_diff_common_options="--stat --numstat --shortstat --summary --no-prefix --src-prefix= --dst-prefix= --inter-hunk-context= --patience --histogram --minimal - --raw + --raw --word-diff --dirstat --dirstat= --dirstat-by-file --dirstat-by-file= --cumulative --diff-algorithm= @@ -1299,7 +1210,7 @@ _git_difftool () return ;; esac - __git_complete_file + __git_complete_revlist_file } __git_fetch_options=" @@ -1319,11 +1230,12 @@ _git_fetch () } __git_format_patch_options=" - --stdout --attach --no-attach --thread --thread= --output-directory + --stdout --attach --no-attach --thread --thread= --no-thread --numbered --start-number --numbered-files --keep-subject --signoff --signature --no-signature --in-reply-to= --cc= --full-index --binary --not --all --cover-letter --no-prefix --src-prefix= --dst-prefix= --inline --suffix= --ignore-if-in-upstream --subject-prefix= + --output-directory --reroll-count --to= --quiet --notes " _git_format_patch () @@ -1354,7 +1266,6 @@ _git_fsck () return ;; esac - COMPREPLY=() } _git_gc () @@ -1365,7 +1276,6 @@ _git_gc () return ;; esac - COMPREPLY=() } _git_gitk () @@ -1442,7 +1352,6 @@ _git_init () return ;; esac - COMPREPLY=() } _git_ls_files () @@ -1578,7 +1487,6 @@ _git_mergetool () return ;; esac - COMPREPLY=() } _git_merge_base () @@ -1819,7 +1727,7 @@ __git_config_get_set_variables () _git_config () { case "$prev" in - branch.*.remote) + branch.*.remote|branch.*.pushremote) __gitcomp_nl "$(__git_remotes)" return ;; @@ -1827,11 +1735,19 @@ _git_config () __gitcomp_nl "$(__git_refs)" return ;; + branch.*.rebase) + __gitcomp "false true" + return + ;; + remote.pushdefault) + __gitcomp_nl "$(__git_remotes)" + return + ;; remote.*.fetch) local remote="${prev#remote.}" remote="${remote%.fetch}" if [ -z "$cur" ]; then - COMPREPLY=("refs/heads/") + __gitcomp_nl "refs/heads/" "" "" "" return fi __gitcomp_nl "$(__git_refs_remotes "$remote")" @@ -1866,6 +1782,10 @@ _git_config () " return ;; + diff.submodule) + __gitcomp "log short" + return + ;; help.format) __gitcomp "man info web html" return @@ -1891,7 +1811,6 @@ _git_config () return ;; *.*) - COMPREPLY=() return ;; esac @@ -1908,7 +1827,7 @@ _git_config () ;; branch.*.*) local pfx="${cur%.*}." cur_="${cur##*.}" - __gitcomp "remote merge mergeoptions rebase" "$pfx" "$cur_" + __gitcomp "remote pushremote merge mergeoptions rebase" "$pfx" "$cur_" return ;; branch.*) @@ -2039,7 +1958,6 @@ _git_config () core.fileMode core.fsyncobjectfiles core.gitProxy - core.ignoreCygwinFSTricks core.ignoreStat core.ignorecase core.logAllRefUpdates @@ -2061,13 +1979,14 @@ _git_config () core.whitespace core.worktree diff.autorefreshindex - diff.statGraphWidth diff.external diff.ignoreSubmodules diff.mnemonicprefix diff.noprefix diff.renameLimit diff.renames + diff.statGraphWidth + diff.submodule diff.suppressBlankEmpty diff.tool diff.wordRegex @@ -2202,6 +2121,7 @@ _git_config () receive.fsckObjects receive.unpackLimit receive.updateserverinfo + remote.pushdefault remotes. repack.usedeltabaseoffset rerere.autoupdate @@ -2272,7 +2192,6 @@ _git_remote () __gitcomp "$c" ;; *) - COMPREPLY=() ;; esac } @@ -2356,7 +2275,7 @@ _git_show () return ;; esac - __git_complete_file + __git_complete_revlist_file } _git_show_branch () @@ -2388,8 +2307,6 @@ _git_stash () *) if [ -z "$(__git_find_on_cmdline "$save_opts")" ]; then __gitcomp "$subcommands" - else - COMPREPLY=() fi ;; esac @@ -2402,14 +2319,12 @@ _git_stash () __gitcomp "--index --quiet" ;; show,--*|drop,--*|branch,--*) - COMPREPLY=() ;; show,*|apply,*|drop,*|pop,*|branch,*) __gitcomp_nl "$(git --git-dir="$(__gitdir)" stash list \ | sed -n -e 's/:.*//p')" ;; *) - COMPREPLY=() ;; esac fi @@ -2419,7 +2334,7 @@ _git_submodule () { __git_has_doubledash && return - local subcommands="add status init update summary foreach sync" + local subcommands="add status init deinit update summary foreach sync" if [ -z "$(__git_find_on_cmdline "$subcommands")" ]; then case "$cur" in --*) @@ -2451,7 +2366,7 @@ _git_svn () --no-metadata --use-svm-props --use-svnsync-props --log-window-size= --no-checkout --quiet --repack-flags --use-log-author --localtime - --ignore-paths= $remote_opts + --ignore-paths= --include-paths= $remote_opts " local init_opts=" --template= --shared= --trunk= --tags= @@ -2526,7 +2441,6 @@ _git_svn () __gitcomp "--revision= --parent" ;; *) - COMPREPLY=() ;; esac fi @@ -2551,13 +2465,10 @@ _git_tag () case "$prev" in -m|-F) - COMPREPLY=() ;; -*|tag) if [ $f = 1 ]; then __gitcomp_nl "$(__git_tags)" - else - COMPREPLY=() fi ;; *) @@ -2579,9 +2490,10 @@ __git_main () i="${words[c]}" case "$i" in --git-dir=*) __git_dir="${i#--git-dir=}" ;; + --git-dir) ((c++)) ; __git_dir="${words[c]}" ;; --bare) __git_dir="." ;; --help) command="help"; break ;; - -c) c=$((++c)) ;; + -c|--work-tree|--namespace) ((c++)) ;; -*) ;; *) command="$i"; break ;; esac @@ -2599,6 +2511,7 @@ __git_main () --exec-path --exec-path= --html-path + --man-path --info-path --work-tree= --namespace= @@ -2693,35 +2606,19 @@ if [[ -n ${ZSH_VERSION-} ]]; then compadd -Q -p "${2-}" -f -- ${=1} && _ret=0 } - __git_zsh_helper () - { - emulate -L ksh - local cur cword prev - cur=${words[CURRENT-1]} - prev=${words[CURRENT-2]} - let cword=CURRENT-1 - __${service}_main - } - _git () { - emulate -L zsh - local _ret=1 - __git_zsh_helper - let _ret && _default -S '' && _ret=0 + local _ret=1 cur cword prev + cur=${words[CURRENT]} + prev=${words[CURRENT-1]} + let cword=CURRENT-1 + emulate ksh -c __${service}_main + let _ret && _default && _ret=0 return _ret } compdef _git git gitk return -elif [[ -n ${BASH_VERSION-} ]]; then - if ((${BASH_VERSINFO[0]} < 4)); then - # compopt is not supported - __git_index_file_list_filter () - { - __git_index_file_list_filter_compat - } - fi fi __git_func_wrap () diff --git a/plugins/gitfast/git-prompt.sh b/plugins/gitfast/git-prompt.sh index 65f8368f1a7c..a81ef5a482d4 100644 --- a/plugins/gitfast/git-prompt.sh +++ b/plugins/gitfast/git-prompt.sh @@ -3,7 +3,7 @@ # Copyright (C) 2006,2007 Shawn O. Pearce # Distributed under the GNU General Public License, version 2.0. # -# This script allows you to see the current branch in your prompt. +# This script allows you to see repository status in your prompt. # # To enable: # @@ -13,23 +13,27 @@ # 3a) Change your PS1 to call __git_ps1 as # command-substitution: # Bash: PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ ' -# ZSH: PS1='[%n@%m %c$(__git_ps1 " (%s)")]\$ ' +# ZSH: setopt PROMPT_SUBST ; PS1='[%n@%m %c$(__git_ps1 " (%s)")]\$ ' # the optional argument will be used as format string. -# 3b) Alternatively, if you are using bash, __git_ps1 can be -# used for PROMPT_COMMAND with two parameters,
 and
-#        , which are strings you would put in $PS1 before
-#        and after the status string generated by the git-prompt
-#        machinery.  e.g.
-#           PROMPT_COMMAND='__git_ps1 "\u@\h:\w" "\\\$ "'
-#        will show username, at-sign, host, colon, cwd, then
-#        various status string, followed by dollar and SP, as
-#        your prompt.
+#    3b) Alternatively, for a slightly faster prompt, __git_ps1 can
+#        be used for PROMPT_COMMAND in Bash or for precmd() in Zsh
+#        with two parameters, 
 and , which are strings
+#        you would put in $PS1 before and after the status string
+#        generated by the git-prompt machinery.  e.g.
+#        Bash: PROMPT_COMMAND='__git_ps1 "\u@\h:\w" "\\\$ "'
+#          will show username, at-sign, host, colon, cwd, then
+#          various status string, followed by dollar and SP, as
+#          your prompt.
+#        ZSH:  precmd () { __git_ps1 "%n" ":%~$ " "|%s" }
+#          will show username, pipe, then various status string,
+#          followed by colon, cwd, dollar and SP, as your prompt.
 #        Optionally, you can supply a third argument with a printf
 #        format string to finetune the output of the branch status
 #
-# The argument to __git_ps1 will be displayed only if you are currently
-# in a git repository.  The %s token will be the name of the current
-# branch.
+# The repository status will be displayed only if you are currently in a
+# git repository. The %s token is the placeholder for the shown status.
+#
+# The prompt status always includes the current branch name.
 #
 # In addition, if you set GIT_PS1_SHOWDIRTYSTATE to a nonempty value,
 # unstaged (*) and staged (+) changes will be shown next to the branch
@@ -77,31 +81,8 @@
 #
 # If you would like a colored hint about the current dirty state, set
 # GIT_PS1_SHOWCOLORHINTS to a nonempty value. The colors are based on
-# the colored output of "git status -sb".
-
-# __gitdir accepts 0 or 1 arguments (i.e., location)
-# returns location of .git repo
-__gitdir ()
-{
-	# Note: this function is duplicated in git-completion.bash
-	# When updating it, make sure you update the other one to match.
-	if [ -z "${1-}" ]; then
-		if [ -n "${__git_dir-}" ]; then
-			echo "$__git_dir"
-		elif [ -n "${GIT_DIR-}" ]; then
-			test -d "${GIT_DIR-}" || return 1
-			echo "$GIT_DIR"
-		elif [ -d .git ]; then
-			echo .git
-		else
-			git rev-parse --git-dir 2>/dev/null
-		fi
-	elif [ -d "$1/.git" ]; then
-		echo "$1/.git"
-	else
-		echo "$1"
-	fi
-}
+# the colored output of "git status -sb" and are available only when
+# using __git_ps1 for PROMPT_COMMAND or precmd.
 
 # stores the divergence from upstream in $p
 # used by GIT_PS1_SHOWUPSTREAM
@@ -124,7 +105,7 @@ __git_ps1_show_upstream ()
 			fi
 			;;
 		svn-remote.*.url)
-			svn_remote[ $((${#svn_remote[@]} + 1)) ]="$value"
+			svn_remote[$((${#svn_remote[@]} + 1))]="$value"
 			svn_url_pattern+="\\|$value"
 			upstream=svn+git # default upstream is SVN if available, else git
 			;;
@@ -146,10 +127,11 @@ __git_ps1_show_upstream ()
 	svn*)
 		# get the upstream from the "git-svn-id: ..." in a commit message
 		# (git-svn uses essentially the same procedure internally)
-		local svn_upstream=($(git log --first-parent -1 \
+		local -a svn_upstream
+		svn_upstream=($(git log --first-parent -1 \
 					--grep="^git-svn-id: \(${svn_url_pattern#??}\)" 2>/dev/null))
 		if [[ 0 -ne ${#svn_upstream[@]} ]]; then
-			svn_upstream=${svn_upstream[ ${#svn_upstream[@]} - 2 ]}
+			svn_upstream=${svn_upstream[${#svn_upstream[@]} - 2]}
 			svn_upstream=${svn_upstream%@*}
 			local n_stop="${#svn_remote[@]}"
 			for ((n=1; n <= n_stop; n++)); do
@@ -222,6 +204,51 @@ __git_ps1_show_upstream ()
 
 }
 
+# Helper function that is meant to be called from __git_ps1.  It
+# injects color codes into the appropriate gitstring variables used
+# to build a gitstring.
+__git_ps1_colorize_gitstring ()
+{
+	if [[ -n ${ZSH_VERSION-} ]]; then
+		local c_red='%F{red}'
+		local c_green='%F{green}'
+		local c_lblue='%F{blue}'
+		local c_clear='%f'
+	else
+		# Using \[ and \] around colors is necessary to prevent
+		# issues with command line editing/browsing/completion!
+		local c_red='\[\e[31m\]'
+		local c_green='\[\e[32m\]'
+		local c_lblue='\[\e[1;34m\]'
+		local c_clear='\[\e[0m\]'
+	fi
+	local bad_color=$c_red
+	local ok_color=$c_green
+	local flags_color="$c_lblue"
+
+	local branch_color=""
+	if [ $detached = no ]; then
+		branch_color="$ok_color"
+	else
+		branch_color="$bad_color"
+	fi
+	c="$branch_color$c"
+
+	z="$c_clear$z"
+	if [ "$w" = "*" ]; then
+		w="$bad_color$w"
+	fi
+	if [ -n "$i" ]; then
+		i="$ok_color$i"
+	fi
+	if [ -n "$s" ]; then
+		s="$flags_color$s"
+	fi
+	if [ -n "$u" ]; then
+		u="$bad_color$u"
+	fi
+	r="$c_clear$r"
+}
 
 # __git_ps1 accepts 0 or 1 arguments (i.e., format string)
 # when called from PS1 using command substitution
@@ -254,39 +281,83 @@ __git_ps1 ()
 		;;
 	esac
 
-	local g="$(__gitdir)"
-	if [ -z "$g" ]; then
+	local repo_info rev_parse_exit_code
+	repo_info="$(git rev-parse --git-dir --is-inside-git-dir \
+		--is-bare-repository --is-inside-work-tree \
+		--short HEAD 2>/dev/null)"
+	rev_parse_exit_code="$?"
+
+	if [ -z "$repo_info" ]; then
 		if [ $pcmode = yes ]; then
 			#In PC mode PS1 always needs to be set
 			PS1="$ps1pc_start$ps1pc_end"
 		fi
-	else
-		local r=""
-		local b=""
+		return
+	fi
+
+	local short_sha
+	if [ "$rev_parse_exit_code" = "0" ]; then
+		short_sha="${repo_info##*$'\n'}"
+		repo_info="${repo_info%$'\n'*}"
+	fi
+	local inside_worktree="${repo_info##*$'\n'}"
+	repo_info="${repo_info%$'\n'*}"
+	local bare_repo="${repo_info##*$'\n'}"
+	repo_info="${repo_info%$'\n'*}"
+	local inside_gitdir="${repo_info##*$'\n'}"
+	local g="${repo_info%$'\n'*}"
+
+	local r=""
+	local b=""
+	local step=""
+	local total=""
+	if [ -d "$g/rebase-merge" ]; then
+		read b 2>/dev/null <"$g/rebase-merge/head-name"
+		read step 2>/dev/null <"$g/rebase-merge/msgnum"
+		read total 2>/dev/null <"$g/rebase-merge/end"
 		if [ -f "$g/rebase-merge/interactive" ]; then
 			r="|REBASE-i"
-			b="$(cat "$g/rebase-merge/head-name")"
-		elif [ -d "$g/rebase-merge" ]; then
+		else
 			r="|REBASE-m"
-			b="$(cat "$g/rebase-merge/head-name")"
+		fi
+	else
+		if [ -d "$g/rebase-apply" ]; then
+			read step 2>/dev/null <"$g/rebase-apply/next"
+			read total 2>/dev/null <"$g/rebase-apply/last"
+			if [ -f "$g/rebase-apply/rebasing" ]; then
+				read b 2>/dev/null <"$g/rebase-apply/head-name"
+				r="|REBASE"
+			elif [ -f "$g/rebase-apply/applying" ]; then
+				r="|AM"
+			else
+				r="|AM/REBASE"
+			fi
+		elif [ -f "$g/MERGE_HEAD" ]; then
+			r="|MERGING"
+		elif [ -f "$g/CHERRY_PICK_HEAD" ]; then
+			r="|CHERRY-PICKING"
+		elif [ -f "$g/REVERT_HEAD" ]; then
+			r="|REVERTING"
+		elif [ -f "$g/BISECT_LOG" ]; then
+			r="|BISECTING"
+		fi
+
+		if [ -n "$b" ]; then
+			:
+		elif [ -h "$g/HEAD" ]; then
+			# symlink symbolic ref
+			b="$(git symbolic-ref HEAD 2>/dev/null)"
 		else
-			if [ -d "$g/rebase-apply" ]; then
-				if [ -f "$g/rebase-apply/rebasing" ]; then
-					r="|REBASE"
-				elif [ -f "$g/rebase-apply/applying" ]; then
-					r="|AM"
-				else
-					r="|AM/REBASE"
+			local head=""
+			if ! read head 2>/dev/null <"$g/HEAD"; then
+				if [ $pcmode = yes ]; then
+					PS1="$ps1pc_start$ps1pc_end"
 				fi
-			elif [ -f "$g/MERGE_HEAD" ]; then
-				r="|MERGING"
-			elif [ -f "$g/CHERRY_PICK_HEAD" ]; then
-				r="|CHERRY-PICKING"
-			elif [ -f "$g/BISECT_LOG" ]; then
-				r="|BISECTING"
+				return
 			fi
-
-			b="$(git symbolic-ref HEAD 2>/dev/null)" || {
+			# is it a symbolic ref?
+			b="${head#ref: }"
+			if [ "$head" = "$b" ]; then
 				detached=yes
 				b="$(
 				case "${GIT_PS1_DESCRIBE_STYLE-}" in
@@ -300,100 +371,75 @@ __git_ps1 ()
 					git describe --tags --exact-match HEAD ;;
 				esac 2>/dev/null)" ||
 
-				b="$(cut -c1-7 "$g/HEAD" 2>/dev/null)..." ||
-				b="unknown"
+				b="$short_sha..."
 				b="($b)"
-			}
+			fi
 		fi
+	fi
+
+	if [ -n "$step" ] && [ -n "$total" ]; then
+		r="$r $step/$total"
+	fi
 
-		local w=""
-		local i=""
-		local s=""
-		local u=""
-		local c=""
-		local p=""
+	local w=""
+	local i=""
+	local s=""
+	local u=""
+	local c=""
+	local p=""
 
-		if [ "true" = "$(git rev-parse --is-inside-git-dir 2>/dev/null)" ]; then
-			if [ "true" = "$(git rev-parse --is-bare-repository 2>/dev/null)" ]; then
-				c="BARE:"
+	if [ "true" = "$inside_gitdir" ]; then
+		if [ "true" = "$bare_repo" ]; then
+			c="BARE:"
+		else
+			b="GIT_DIR!"
+		fi
+	elif [ "true" = "$inside_worktree" ]; then
+		if [ -n "${GIT_PS1_SHOWDIRTYSTATE-}" ] &&
+		   [ "$(git config --bool bash.showDirtyState)" != "false" ]
+		then
+			git diff --no-ext-diff --quiet --exit-code || w="*"
+			if [ -n "$short_sha" ]; then
+				git diff-index --cached --quiet HEAD -- || i="+"
 			else
-				b="GIT_DIR!"
-			fi
-		elif [ "true" = "$(git rev-parse --is-inside-work-tree 2>/dev/null)" ]; then
-			if [ -n "${GIT_PS1_SHOWDIRTYSTATE-}" ] &&
-			   [ "$(git config --bool bash.showDirtyState)" != "false" ]
-			then
-				git diff --no-ext-diff --quiet --exit-code || w="*"
-				if git rev-parse --quiet --verify HEAD >/dev/null; then
-					git diff-index --cached --quiet HEAD -- || i="+"
-				else
-					i="#"
-				fi
-			fi
-			if [ -n "${GIT_PS1_SHOWSTASHSTATE-}" ]; then
-				git rev-parse --verify refs/stash >/dev/null 2>&1 && s="$"
+				i="#"
 			fi
+		fi
+		if [ -n "${GIT_PS1_SHOWSTASHSTATE-}" ] &&
+		   [ -r "$g/refs/stash" ]; then
+			s="$"
+		fi
 
-			if [ -n "${GIT_PS1_SHOWUNTRACKEDFILES-}" ] &&
-			   [ "$(git config --bool bash.showUntrackedFiles)" != "false" ] &&
-			   [ -n "$(git ls-files --others --exclude-standard)" ]
-			then
-				u="%%"
-			fi
+		if [ -n "${GIT_PS1_SHOWUNTRACKEDFILES-}" ] &&
+		   [ "$(git config --bool bash.showUntrackedFiles)" != "false" ] &&
+		   git ls-files --others --exclude-standard --error-unmatch -- '*' >/dev/null 2>/dev/null
+		then
+			u="%${ZSH_VERSION+%}"
+		fi
 
-			if [ -n "${GIT_PS1_SHOWUPSTREAM-}" ]; then
-				__git_ps1_show_upstream
-			fi
+		if [ -n "${GIT_PS1_SHOWUPSTREAM-}" ]; then
+			__git_ps1_show_upstream
 		fi
+	fi
 
-		local f="$w$i$s$u"
-		if [ $pcmode = yes ]; then
-			local gitstring=
-			if [ -n "${GIT_PS1_SHOWCOLORHINTS-}" ]; then
-				local c_red='\e[31m'
-				local c_green='\e[32m'
-				local c_lblue='\e[1;34m'
-				local c_clear='\e[0m'
-				local bad_color=$c_red
-				local ok_color=$c_green
-				local branch_color="$c_clear"
-				local flags_color="$c_lblue"
-				local branchstring="$c${b##refs/heads/}"
+	local z="${GIT_PS1_STATESEPARATOR-" "}"
 
-				if [ $detached = no ]; then
-					branch_color="$ok_color"
-				else
-					branch_color="$bad_color"
-				fi
+	# NO color option unless in PROMPT_COMMAND mode
+	if [ $pcmode = yes ] && [ -n "${GIT_PS1_SHOWCOLORHINTS-}" ]; then
+		__git_ps1_colorize_gitstring
+	fi
 
-				# Setting gitstring directly with \[ and \] around colors
-				# is necessary to prevent wrapping issues!
-				gitstring="\[$branch_color\]$branchstring\[$c_clear\]"
+	local f="$w$i$s$u"
+	local gitstring="$c${b##refs/heads/}${f:+$z$f}$r$p"
 
-				if [ -n "$w$i$s$u$r$p" ]; then
-					gitstring="$gitstring "
-				fi
-				if [ "$w" = "*" ]; then
-					gitstring="$gitstring\[$bad_color\]$w"
-				fi
-				if [ -n "$i" ]; then
-					gitstring="$gitstring\[$ok_color\]$i"
-				fi
-				if [ -n "$s" ]; then
-					gitstring="$gitstring\[$flags_color\]$s"
-				fi
-				if [ -n "$u" ]; then
-					gitstring="$gitstring\[$bad_color\]$u"
-				fi
-				gitstring="$gitstring\[$c_clear\]$r$p"
-			else
-				gitstring="$c${b##refs/heads/}${f:+ $f}$r$p"
-			fi
+	if [ $pcmode = yes ]; then
+		if [[ -n ${ZSH_VERSION-} ]]; then
 			gitstring=$(printf -- "$printf_format" "$gitstring")
-			PS1="$ps1pc_start$gitstring$ps1pc_end"
 		else
-			# NO color option unless in PROMPT_COMMAND mode
-			printf -- "$printf_format" "$c${b##refs/heads/}${f:+ $f}$r$p"
+			printf -v gitstring -- "$printf_format" "$gitstring"
 		fi
+		PS1="$ps1pc_start$gitstring$ps1pc_end"
+	else
+		printf -- "$printf_format" "$gitstring"
 	fi
 }
diff --git a/plugins/gitignore/gitignore.plugin.zsh b/plugins/gitignore/gitignore.plugin.zsh
new file mode 100644
index 000000000000..be037d87a660
--- /dev/null
+++ b/plugins/gitignore/gitignore.plugin.zsh
@@ -0,0 +1,12 @@
+function gi() { curl http://www.gitignore.io/api/$@ ;}
+
+_gitignireio_get_command_list() {
+  curl -s http://www.gitignore.io/api/list | tr "," "\n"
+}
+
+_gitignireio () {
+  compset -P '*,'
+  compadd -S '' `_gitignireio_get_command_list`
+}
+
+compdef _gitignireio gi
diff --git a/plugins/go/go.plugin.zsh b/plugins/go/go.plugin.zsh
deleted file mode 100644
index 23afa96569e1..000000000000
--- a/plugins/go/go.plugin.zsh
+++ /dev/null
@@ -1,151 +0,0 @@
-# install in /etc/zsh/zshrc or your personal .zshrc
-
-# gc
-prefixes=(5 6 8)
-for p in $prefixes; do
-	compctl -g "*.${p}" ${p}l
-	compctl -g "*.go" ${p}g
-done
-
-# standard go tools
-compctl -g "*.go" gofmt
-
-# gccgo
-compctl -g "*.go" gccgo
-
-# go tool
-__go_tool_complete() {
-  typeset -a commands build_flags
-  commands+=(
-    'build[compile packages and dependencies]'
-    'clean[remove object files]'
-    'doc[run godoc on package sources]'
-    'fix[run go tool fix on packages]'
-    'fmt[run gofmt on package sources]'
-    'get[download and install packages and dependencies]'
-    'help[display help]'
-    'install[compile and install packages and dependencies]'
-    'list[list packages]'
-    'run[compile and run Go program]'
-    'test[test packages]'
-    'tool[run specified go tool]'
-    'version[print Go version]'
-    'vet[run go tool vet on packages]'
-  )
-  if (( CURRENT == 2 )); then
-    # explain go commands
-    _values 'go tool commands' ${commands[@]}
-    return
-  fi
-  build_flags=(
-    '-a[force reinstallation of packages that are already up-to-date]'
-    '-n[print the commands but do not run them]'
-    "-p[number of parallel builds]:number"
-    '-x[print the commands]'
-    "-work[print temporary directory name and keep it]"
-    "-gcflags[flags for 5g/6g/8g]:flags"
-    "-ldflags[flags for 5l/6l/8l]:flags"
-    "-gccgoflags[flags for gccgo]:flags"
-  )
-  __go_list() {
-      local expl importpaths
-      declare -a importpaths
-      importpaths=($(go list ${words[$CURRENT]}... 2>/dev/null))
-      _wanted importpaths expl 'import paths' compadd "$@" - "${importpaths[@]}"
-  }
-  case ${words[2]} in
-  clean|doc)
-      _arguments -s -w : '*:importpaths:__go_list'
-      ;;
-  fix|fmt|list|vet)
-      _alternative ':importpaths:__go_list' ':files:_path_files -g "*.go"'
-      ;;
-  install)
-      _arguments -s -w : ${build_flags[@]} \
-        "-v[show package names]" \
-	'*:importpaths:__go_list'
-      ;;
-  get)
-      _arguments -s -w : \
-        ${build_flags[@]}
-      ;;
-  build)
-      _arguments -s -w : \
-        ${build_flags[@]} \
-        "-v[show package names]" \
-        "-o[output file]:file:_files" \
-        "*:args:{ _alternative ':importpaths:__go_list' ':files:_path_files -g \"*.go\"' }"
-      ;;
-  test)
-      _arguments -s -w : \
-        ${build_flags[@]} \
-        "-c[do not run, compile the test binary]" \
-        "-i[do not run, install dependencies]" \
-        "-v[print test output]" \
-        "-x[print the commands]" \
-        "-short[use short mode]" \
-        "-parallel[number of parallel tests]:number" \
-        "-cpu[values of GOMAXPROCS to use]:number list" \
-        "-run[run tests and examples matching regexp]:regexp" \
-        "-bench[run benchmarks matching regexp]:regexp" \
-        "-benchtime[run each benchmark during n seconds]:duration" \
-        "-timeout[kill test after that duration]:duration" \
-        "-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\"' }"
-      ;;
-  help)
-      _values "${commands[@]}" \
-        'gopath[GOPATH environment variable]' \
-        'importpath[description of import paths]' \
-        'remote[remote import path syntax]' \
-        'testflag[description of testing flags]' \
-        'testfunc[description of testing functions]'
-      ;;
-  run)
-      _arguments -s -w : \
-          ${build_flags[@]} \
-          '*:file:_path_files -g "*.go"'
-      ;;
-  tool)
-      if (( CURRENT == 3 )); then
-          _values "go tool" $(go tool)
-          return
-      fi
-      case ${words[3]} in
-      [568]g)
-          _arguments -s -w : \
-              '-I[search for packages in DIR]:includes:_path_files -/' \
-              '-L[show full path in file:line prints]' \
-              '-S[print the assembly language]' \
-              '-V[print the compiler version]' \
-              '-e[no limit on number of errors printed]' \
-              '-h[panic on an error]' \
-              '-l[disable inlining]' \
-              '-m[print optimization decisions]' \
-              '-o[file specify output file]:file' \
-              '-p[assumed import path for this code]:importpath' \
-              '-u[disable package unsafe]' \
-              "*:file:_files -g '*.go'"
-          ;;
-      [568]l)
-          local O=${words[3]%l}
-          _arguments -s -w : \
-              '-o[file specify output file]:file' \
-              '-L[search for packages in DIR]:includes:_path_files -/' \
-              "*:file:_files -g '*.[ao$O]'"
-          ;;
-      dist)
-          _values "dist tool" banner bootstrap clean env install version
-          ;;
-      *)
-          # use files by default
-          _files
-          ;;
-      esac
-      ;;
-  esac
-}
-
-compdef __go_tool_complete go
diff --git a/plugins/go/go.plugin.zsh b/plugins/go/go.plugin.zsh
new file mode 120000
index 000000000000..cf943e2e1a98
--- /dev/null
+++ b/plugins/go/go.plugin.zsh
@@ -0,0 +1 @@
+../golang/golang.plugin.zsh
\ No newline at end of file
diff --git a/plugins/golang/golang.plugin.zsh b/plugins/golang/golang.plugin.zsh
index e60c4afe48e0..18bcaaff284d 100644
--- a/plugins/golang/golang.plugin.zsh
+++ b/plugins/golang/golang.plugin.zsh
@@ -1,9 +1,10 @@
-# From : http://golang.org/misc/zsh/go?m=text
+# install in /etc/zsh/zshrc or your personal .zshrc
+
 # gc
 prefixes=(5 6 8)
 for p in $prefixes; do
-    compctl -g "*.${p}" ${p}l
-    compctl -g "*.go" ${p}g
+	compctl -g "*.${p}" ${p}l
+	compctl -g "*.go" ${p}g
 done
 
 # standard go tools
@@ -19,6 +20,7 @@ __go_tool_complete() {
     'build[compile packages and dependencies]'
     'clean[remove object files]'
     'doc[run godoc on package sources]'
+    'env[print Go environment information]'
     'fix[run go tool fix on packages]'
     'fmt[run gofmt on package sources]'
     'get[download and install packages and dependencies]'
@@ -39,12 +41,17 @@ __go_tool_complete() {
   build_flags=(
     '-a[force reinstallation of packages that are already up-to-date]'
     '-n[print the commands but do not run them]'
-    "-p[number of parallel builds]:number"
+    '-p[number of parallel builds]:number'
+    '-race[enable data race detection]'
     '-x[print the commands]'
-    "-work[print temporary directory name and keep it]"
-    "-gcflags[flags for 5g/6g/8g]:flags"
-    "-ldflags[flags for 5l/6l/8l]:flags"
-    "-gccgoflags[flags for gccgo]:flags"
+    '-work[print temporary directory name and keep it]'
+    '-ccflags[flags for 5c/6c/8c]:flags'
+    '-gcflags[flags for 5g/6g/8g]:flags'
+    '-ldflags[flags for 5l/6l/8l]:flags'
+    '-gccgoflags[flags for gccgo]:flags'
+    '-compiler[name of compiler to use]:name'
+    '-installsuffix[suffix to add to package directory]:suffix'
+    '-tags[list of build tags to consider satisfied]:tags'
   )
   __go_list() {
       local expl importpaths
@@ -62,7 +69,7 @@ __go_tool_complete() {
   install)
       _arguments -s -w : ${build_flags[@]} \
         "-v[show package names]" \
-    '*:importpaths:__go_list'
+        '*:importpaths:__go_list'
       ;;
   get)
       _arguments -s -w : \
@@ -87,7 +94,10 @@ __go_tool_complete() {
         "-cpu[values of GOMAXPROCS to use]:number list" \
         "-run[run tests and examples matching regexp]:regexp" \
         "-bench[run benchmarks matching regexp]:regexp" \
-        "-benchtime[run each benchmark during n seconds]:duration" \
+        "-benchmem[print memory allocation stats]" \
+        "-benchtime[run each benchmark until taking this long]:duration" \
+        "-blockprofile[write goroutine blocking profile to file]:file" \
+        "-blockprofilerate[set sampling rate of goroutine blocking profile]:number" \
         "-timeout[kill test after that duration]:duration" \
         "-cpuprofile[write CPU profile to file]:file:_files" \
         "-memprofile[write heap profile to file]:file:_files" \
@@ -97,7 +107,7 @@ __go_tool_complete() {
   help)
       _values "${commands[@]}" \
         'gopath[GOPATH environment variable]' \
-        'importpath[description of import paths]' \
+        'packages[description of package lists]' \
         'remote[remote import path syntax]' \
         'testflag[description of testing flags]' \
         'testfunc[description of testing functions]'
@@ -147,4 +157,4 @@ __go_tool_complete() {
   esac
 }
 
-compdef __go_tool_complete go
\ No newline at end of file
+compdef __go_tool_complete go
diff --git a/plugins/gpg-agent/gpg-agent.plugin.zsh b/plugins/gpg-agent/gpg-agent.plugin.zsh
index 109af44c8d5d..3e6a34f425f3 100644
--- a/plugins/gpg-agent/gpg-agent.plugin.zsh
+++ b/plugins/gpg-agent/gpg-agent.plugin.zsh
@@ -14,16 +14,27 @@ function start_agent_withssh {
     export SSH_AGENT_PID
 }
 
-# source settings of old agent, if applicable
-if [ -f "${GPG_ENV}" ]; then
-  . ${GPG_ENV} > /dev/null
-fi
+# check if another agent is running
+if ! gpg-connect-agent --quiet /bye > /dev/null 2> /dev/null; then
+    # source settings of old agent, if applicable
+    if [ -f "${GPG_ENV}" ]; then
+        . ${GPG_ENV} > /dev/null
+        export GPG_AGENT_INFO
+        export SSH_AUTH_SOCK
+        export SSH_AGENT_PID
+    fi
 
-# check for existing ssh-agent
-if ssh-add -l > /dev/null 2> /dev/null; then
-    start_agent_nossh;
-else
-    start_agent_withssh;
+    # check again if another agent is running using the newly sourced settings
+    if ! gpg-connect-agent --quiet /bye > /dev/null 2> /dev/null; then
+        # check for existing ssh-agent
+        if ssh-add -l > /dev/null 2> /dev/null; then
+            # ssh-agent running, start gpg-agent without ssh support
+            start_agent_nossh;
+        else
+            # otherwise start gpg-agent with ssh support
+            start_agent_withssh;
+        fi
+    fi
 fi
 
 GPG_TTY=$(tty)
diff --git a/plugins/heroku/_heroku b/plugins/heroku/_heroku
index a95c38647f9b..46663303ac8e 100644
--- a/plugins/heroku/_heroku
+++ b/plugins/heroku/_heroku
@@ -23,8 +23,10 @@ _1st_arguments=(
   "auth\:login":"log in with your heroku credentials"
   "auth\:logout":"clear local authentication credentials"
   "config":"display the config vars for an app"
-  "config\:add":"add one or more config vars"
-  "config\:remove":"remove a config var"
+  "config\:pull":"pull heroku config vars down to the local environment"
+  "config\:push":"push local config vars to heroku"
+  "config\:set":"set one or more config vars"
+  "config\:unset":"unset one or more config vars"
   "db\:push":"push local data up to your app"
   "db\:pull":"pull heroku data down into your local database"
   "domains":"list custom domains for an app"
diff --git a/plugins/iwhois/iwhois.plugin.zsh b/plugins/iwhois/iwhois.plugin.zsh
new file mode 100644
index 000000000000..38790bf28ad0
--- /dev/null
+++ b/plugins/iwhois/iwhois.plugin.zsh
@@ -0,0 +1,8 @@
+# provide a whois command with a more accurate and up to date list of whois
+# servers using CNAMES via whois.geek.nz
+
+function iwhois() {
+    resolver="whois.geek.nz"
+    tld=`echo ${@: -1} | awk -F "." '{print $NF}'`
+    whois -h ${tld}.${resolver} "$@" ;
+}
diff --git a/plugins/jira/jira.plugin.zsh b/plugins/jira/jira.plugin.zsh
index bea726a54d9c..739ee7142f69 100644
--- a/plugins/jira/jira.plugin.zsh
+++ b/plugins/jira/jira.plugin.zsh
@@ -3,7 +3,7 @@
 #         .jira-url in the current directory takes precedence
 #
 # If you use Rapid Board, set:
-#JIRA_RAPID_BOARD="yes"
+#JIRA_RAPID_BOARD="true"
 # in you .zshrc
 #
 # Setup: cd to/my/project
@@ -31,10 +31,10 @@ open_jira_issue () {
 
   if [ -z "$1" ]; then
     echo "Opening new issue"
-    `open $jira_url/secure/CreateIssue!default.jspa`
+    $open_cmd "$jira_url/secure/CreateIssue!default.jspa"
   else
     echo "Opening issue #$1"
-    if [[ "x$JIRA_RAPID_BOARD" = "yes" ]]; then
+    if [[ "x$JIRA_RAPID_BOARD" = "xtrue" ]]; then
       $open_cmd  "$jira_url/issues/$1"
     else
       $open_cmd  "$jira_url/browse/$1"
diff --git a/plugins/jump/jump.plugin.zsh b/plugins/jump/jump.plugin.zsh
new file mode 100644
index 000000000000..5096879d8dde
--- /dev/null
+++ b/plugins/jump/jump.plugin.zsh
@@ -0,0 +1,58 @@
+# Easily jump around the file system by manually adding marks
+# marks are stored as symbolic links in the directory $MARKPATH (default $HOME/.marks)
+#
+# jump FOO: jump to a mark named FOO
+# mark FOO: create a mark named FOO
+# unmark FOO: delete a mark
+# marks: lists all marks
+#
+export MARKPATH=$HOME/.marks
+
+jump() {
+	cd -P "$MARKPATH/$1" 2>/dev/null || echo "No such mark: $1"
+}
+
+mark() {
+	if (( $# == 0 )); then
+		MARK=$(basename "$(pwd)")
+	else
+		MARK="$1"
+	fi
+	if read -q \?"Mark $(pwd) as ${MARK}? (y/n) "; then
+		mkdir -p "$MARKPATH"; ln -s "$(pwd)" "$MARKPATH/$MARK"
+	fi
+}
+
+unmark() {
+	rm -i "$MARKPATH/$1"
+}
+
+autoload colors
+marks() {
+	for link in $MARKPATH/*(@); do
+		local markname="$fg[cyan]${link:t}$reset_color"
+		local markpath="$fg[blue]$(readlink $link)$reset_color"
+		printf "%s\t" $markname
+		printf "-> %s \t\n" $markpath
+	done
+}
+
+_completemarks() {
+	if [[ $(ls "${MARKPATH}" | wc -l) -gt 1 ]]; then
+		reply=($(ls $MARKPATH/**/*(-) | grep : | sed -E 's/(.*)\/([_\da-zA-Z\-]*):$/\2/g'))
+	else
+		if readlink -e "${MARKPATH}"/* &>/dev/null; then
+			reply=($(ls "${MARKPATH}"))
+		fi
+	fi
+}
+compctl -K _completemarks jump
+compctl -K _completemarks unmark
+
+_mark_expansion() {
+	setopt extendedglob
+	autoload -U modify-current-argument
+	modify-current-argument '$(readlink "$MARKPATH/$ARG")'
+}
+zle -N _mark_expansion
+bindkey "^g" _mark_expansion
diff --git a/plugins/knife_ssh/knife_ssh.plugin.zsh b/plugins/knife_ssh/knife_ssh.plugin.zsh
new file mode 100644
index 000000000000..7fdd42a1ebb3
--- /dev/null
+++ b/plugins/knife_ssh/knife_ssh.plugin.zsh
@@ -0,0 +1,18 @@
+function knife_ssh() {
+  grep -q $1 ~/.knife_comp~ 2> /dev/null || rm -f ~/.knife_comp~;
+  ssh $(knife node show $1 | awk '/IP:/{print $2}')
+}
+
+_knife_ssh() {
+  if hash knife 2>/dev/null; then
+    if [[ ! -f ~/.knife_comp~ ]]; then
+      echo "\nGenerating ~/.knife_comp~..." >/dev/stderr
+      knife node list > ~/.knife_comp~
+    fi
+    compadd $(<~/.knife_comp~)
+  else
+    echo "Could not find knife" > /dev/stderr;
+  fi
+}
+
+compdef _knife_ssh knife_ssh
diff --git a/plugins/mercurial/mercurial.plugin.zsh b/plugins/mercurial/mercurial.plugin.zsh
index 9aa2d167aa6f..d2db89d04501 100644
--- a/plugins/mercurial/mercurial.plugin.zsh
+++ b/plugins/mercurial/mercurial.plugin.zsh
@@ -1,4 +1,3 @@
-
 # Mercurial
 alias hgc='hg commit'
 alias hgb='hg branch'
@@ -14,11 +13,52 @@ alias hglr='hg pull --rebase'
 alias hgo='hg outgoing'
 alias hgp='hg push'
 alias hgs='hg status'
+alias hgsl='log --limit 20 --template "{node|short} | {date|isodatesec} | {author|user}: {desc|strip|firstline}\n" '
 # this is the 'git commit --amend' equivalent
 alias hgca='hg qimport -r tip ; hg qrefresh -e ; hg qfinish tip'
 
-function hg_current_branch() {
-  if [ -d .hg ]; then
-    echo hg:$(hg branch)
+function in_hg() {
+  if [[ -d .hg ]] || $(hg summary > /dev/null 2>&1); then
+    echo 1
+  fi
+}
+
+function hg_get_branch_name() {
+  if [ $(in_hg) ]; then
+    echo $(hg branch)
+  fi
+}
+
+function hg_prompt_info {
+  if [ $(in_hg) ]; then
+    _DISPLAY=$(hg_get_branch_name)
+    echo "$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_HG_PROMPT_PREFIX\
+$ZSH_THEME_REPO_NAME_COLOR$_DISPLAY$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_HG_PROMPT_SUFFIX$ZSH_PROMPT_BASE_COLOR$(hg_dirty)$ZSH_PROMPT_BASE_COLOR"
+    unset _DISPLAY
+  fi
+}
+
+function hg_dirty_choose {
+  if [ $(in_hg) ]; then
+    hg status 2> /dev/null | grep -Eq '^\s*[ACDIM!?L]'
+    if [ $pipestatus[-1] -eq 0 ]; then
+      # Grep exits with 0 when "One or more lines were selected", return "dirty".
+      echo $1
+    else
+      # Otherwise, no lines were found, or an error occurred. Return clean.
+      echo $2
+    fi
   fi
 }
+
+function hg_dirty {
+  hg_dirty_choose $ZSH_THEME_HG_PROMPT_DIRTY $ZSH_THEME_HG_PROMPT_CLEAN
+}
+
+function hgic() {
+    hg incoming "$@" | grep "changeset" | wc -l
+}
+
+function hgoc() {
+    hg outgoing "$@" | grep "changeset" | wc -l
+}
diff --git a/plugins/mix/_mix b/plugins/mix/_mix
new file mode 100644
index 000000000000..602f5ffa0a94
--- /dev/null
+++ b/plugins/mix/_mix
@@ -0,0 +1,63 @@
+#compdef mix 
+#autoload
+
+# Elixir mix zsh completion
+
+local -a _1st_arguments
+_1st_arguments=(
+    'archive:Archive this project into a .ez file'
+    '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'
+    'escriptize:Generates an escript for the project'
+    'help:Print help information for 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'
+    'new:Creates a new Elixir project'
+    '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' \
+    '*::options:->options'
+
+case $state in
+  (command)
+      _describe -t commands "mix subcommand" _1st_arguments
+      return
+  ;;
+
+  (options)
+    case $line[1] in
+      (help)
+         _arguments ':feature:__task_list' 
+    esac
+  ;;
+esac
+
diff --git a/plugins/mosh/mosh.plugin.zsh b/plugins/mosh/mosh.plugin.zsh
new file mode 100644
index 000000000000..ea36b7ee9698
--- /dev/null
+++ b/plugins/mosh/mosh.plugin.zsh
@@ -0,0 +1,2 @@
+# Allow SSH tab completion for mosh hostnames
+compdef mosh=ssh
diff --git a/plugins/mvn/mvn.plugin.zsh b/plugins/mvn/mvn.plugin.zsh
index 799f6fc8c551..0c914190762b 100644
--- a/plugins/mvn/mvn.plugin.zsh
+++ b/plugins/mvn/mvn.plugin.zsh
@@ -24,16 +24,18 @@ export RESET_FORMATTING=`tput sgr0`
 # Wrapper function for Maven's mvn command.
 mvn-color()
 {
-  # Filter mvn output using sed
-  mvn $@ | sed -e "s/\(\[INFO\]\ \-.*\)/${TEXT_BLUE}${BOLD}\1/g" \
-               -e "s/\(\[INFO\]\ \[.*\)/${RESET_FORMATTING}${BOLD}\1${RESET_FORMATTING}/g" \
+  (
+  # Filter mvn output using sed. Before filtering set the locale to C, so invalid characters won't break some sed implementations
+  unset LANG
+  LC_CTYPE=C mvn $@ | sed -e "s/\(\[INFO\]\)\(.*\)/${TEXT_BLUE}${BOLD}\1${RESET_FORMATTING}\2/g" \
                -e "s/\(\[INFO\]\ BUILD SUCCESSFUL\)/${BOLD}${TEXT_GREEN}\1${RESET_FORMATTING}/g" \
-               -e "s/\(\[WARNING\].*\)/${BOLD}${TEXT_YELLOW}\1${RESET_FORMATTING}/g" \
-               -e "s/\(\[ERROR\].*\)/${BOLD}${TEXT_RED}\1${RESET_FORMATTING}/g" \
+               -e "s/\(\[WARNING\]\)\(.*\)/${BOLD}${TEXT_YELLOW}\1${RESET_FORMATTING}\2/g" \
+               -e "s/\(\[ERROR\]\)\(.*\)/${BOLD}${TEXT_RED}\1${RESET_FORMATTING}\2/g" \
                -e "s/Tests run: \([^,]*\), Failures: \([^,]*\), Errors: \([^,]*\), Skipped: \([^,]*\)/${BOLD}${TEXT_GREEN}Tests run: \1${RESET_FORMATTING}, Failures: ${BOLD}${TEXT_RED}\2${RESET_FORMATTING}, Errors: ${BOLD}${TEXT_RED}\3${RESET_FORMATTING}, Skipped: ${BOLD}${TEXT_YELLOW}\4${RESET_FORMATTING}/g"
  
   # Make sure formatting is reset
   echo -ne ${RESET_FORMATTING}
+  )
 }
  
 # Override the mvn command with the colorized one.
diff --git a/plugins/node/node.plugin.zsh b/plugins/node/node.plugin.zsh
index 3bbed6f04c5a..2d78f2b4c45a 100644
--- a/plugins/node/node.plugin.zsh
+++ b/plugins/node/node.plugin.zsh
@@ -1,5 +1,13 @@
 # Open the node api for your current version to the optional section.
 # TODO: Make the section part easier to use.
 function node-docs {
-	open "http://nodejs.org/docs/$(node --version)/api/all.html#all_$1"
+  # get the open command
+  local open_cmd
+  if [[ $(uname -s) == 'Darwin' ]]; then
+    open_cmd='open'
+  else
+    open_cmd='xdg-open'
+  fi
+
+  $open_cmd "http://nodejs.org/docs/$(node --version)/api/all.html#all_$1"
 }
diff --git a/plugins/nvm/_nvm b/plugins/nvm/_nvm
new file mode 100644
index 000000000000..a95c9e3753e5
--- /dev/null
+++ b/plugins/nvm/_nvm
@@ -0,0 +1,26 @@
+#compdef nvm
+#autoload
+
+[[ -s ~/.nvm/nvm.sh ]] || return 0
+
+local -a _1st_arguments
+_1st_arguments=(
+  'help:show help'
+  'install:download and install a version'
+  'uninstall:uninstall a version'
+  'use:modify PATH to use version'
+  'run:run version with given arguments'
+  'ls:list installed versions or versions matching a given description'
+  'ls-remote:list remote versions available for install'
+  'deactivate:undo effects of NVM on current shell'
+  'alias:show or set aliases'
+  'unalias:deletes an alias'
+  'copy-packages:install global NPM packages to current version'
+)
+
+_arguments -C '*:: :->subcmds' && return 0
+
+if (( CURRENT == 1 )); then
+  _describe -t commands "nvm subcommand" _1st_arguments
+  return
+fi
\ No newline at end of file
diff --git a/plugins/nvm/nvm.plugin.zsh b/plugins/nvm/nvm.plugin.zsh
new file mode 100644
index 000000000000..9709719fefb4
--- /dev/null
+++ b/plugins/nvm/nvm.plugin.zsh
@@ -0,0 +1,3 @@
+# The addition 'nvm install' attempts in ~/.profile
+
+[[ -s ~/.nvm/nvm.sh ]] && . ~/.nvm/nvm.sh
diff --git a/plugins/nyan/nyan.plugin.zsh b/plugins/nyan/nyan.plugin.zsh
index 6321e5f5a02c..ac9d0017e528 100644
--- a/plugins/nyan/nyan.plugin.zsh
+++ b/plugins/nyan/nyan.plugin.zsh
@@ -1,5 +1,5 @@
 if [[ -x `which nc` ]]; then
-  alias nyan='nc -v miku.acm.uiuc.edu 23' # nyan cat
+  alias nyan='nc -v nyancat.dakko.us 23' # nyan cat
 fi
 
 
diff --git a/plugins/osx/osx.plugin.zsh b/plugins/osx/osx.plugin.zsh
index 51cd7c143436..608ec378944d 100644
--- a/plugins/osx/osx.plugin.zsh
+++ b/plugins/osx/osx.plugin.zsh
@@ -6,7 +6,7 @@
 # ------------------------------------------------------------------------------
 
 function tab() {
-  local command="cd \\\"$PWD\\\""
+  local command="cd \\\"$PWD\\\"; clear; "
   (( $# > 0 )) && command="${command}; $*"
 
   the_app=$(
@@ -34,7 +34,7 @@ EOF
           launch session "Default Session"
           set current_session to current session
           tell current_session
-            write text "${command}; clear;"
+            write text "${command}"
           end tell
         end tell
       end tell
@@ -157,3 +157,37 @@ function trash() {
 function vncviewer() {
   open vnc://$@
 }
+
+# iTunes control function
+function itunes() {
+	local opt=$1
+	shift
+	case "$opt" in
+		launch|play|pause|stop|rewind|resume|quit)
+			;;
+		mute)
+			opt="set mute to true"
+			;;
+		unmute)
+			opt="set mute to false"
+			;;
+		next|previous)
+			opt="$opt track"
+			;;
+		""|-h|--help)
+			echo "Usage: itunes