summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/autojump/autojump.plugin.zsh4
-rw-r--r--plugins/battery/battery.plugin.zsh20
-rw-r--r--plugins/bundler/bundler.plugin.zsh2
-rw-r--r--plugins/debian/debian.plugin.zsh42
-rw-r--r--plugins/git/git.plugin.zsh1
-rw-r--r--plugins/jake-node/jake-node.plugin.zsh14
-rw-r--r--plugins/knife/_knife21
-rw-r--r--plugins/nyan/nyan.plugin.zsh5
-rw-r--r--plugins/pip/_pip64
-rw-r--r--plugins/rails3/rails3.plugin.zsh2
-rw-r--r--plugins/sprunge/sprunge.plugin.zsh64
-rw-r--r--plugins/symfony2/symfony2.plugin.zsh13
-rw-r--r--plugins/wakeonlan/README29
-rw-r--r--plugins/wakeonlan/_wake4
-rw-r--r--plugins/wakeonlan/wakeonlan.plugin.zsh14
15 files changed, 267 insertions, 32 deletions
diff --git a/plugins/autojump/autojump.plugin.zsh b/plugins/autojump/autojump.plugin.zsh
index da0a12765..6f9b80bff 100644
--- a/plugins/autojump/autojump.plugin.zsh
+++ b/plugins/autojump/autojump.plugin.zsh
@@ -1,3 +1,5 @@
-if [ -f `brew --prefix`/etc/autojump ]; then
+if [ -f /opt/local/etc/profile.d/autojump.sh ]; then
+ . /opt/local/etc/profile.d/autojump.sh
+elif [ -f `brew --prefix`/etc/autojump ]; then
. `brew --prefix`/etc/autojump
fi
diff --git a/plugins/battery/battery.plugin.zsh b/plugins/battery/battery.plugin.zsh
new file mode 100644
index 000000000..bc75c5cf9
--- /dev/null
+++ b/plugins/battery/battery.plugin.zsh
@@ -0,0 +1,20 @@
+if [[ $(acpi 2&>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]] ; then
+ function battery_pct_remaining() { echo "$(acpi | cut -f2 -d ',' | tr -cd '[:digit:]')" }
+ function battery_time_remaining() { echo $(acpi | cut -f3 -d ',') }
+ function battery_pct_prompt() {
+ b=$(battery_pct_remaining)
+ if [ $b -gt 50 ] ; then
+ color='green'
+ elif [ $b -gt 20 ] ; then
+ color='yellow'
+ else
+ color='red'
+ fi
+ echo "%{$fg[$color]%}[$(battery_pct_remaining)%%]%{$reset_color%}"
+ }
+else
+ error_msg='no battery'
+ function battery_pct_remaining() { echo $error_msg }
+ function battery_time_remaining() { echo $error_msg }
+ function battery_pct_prompt() { echo '' }
+fi
diff --git a/plugins/bundler/bundler.plugin.zsh b/plugins/bundler/bundler.plugin.zsh
index 3c96b8da9..89f62232b 100644
--- a/plugins/bundler/bundler.plugin.zsh
+++ b/plugins/bundler/bundler.plugin.zsh
@@ -41,6 +41,6 @@ for cmd in $bundled_commands; do
alias $cmd=bundled_$cmd
if which _$cmd > /dev/null 2>&1; then
- compdef _$cmd bundled_$cmd
+ compdef _$cmd bundled_$cmd=$cmd
fi
done
diff --git a/plugins/debian/debian.plugin.zsh b/plugins/debian/debian.plugin.zsh
index 09771881d..16a5d54ca 100644
--- a/plugins/debian/debian.plugin.zsh
+++ b/plugins/debian/debian.plugin.zsh
@@ -54,7 +54,7 @@ if [[ $use_sudo -eq 1 ]]; then
# apt-get only
alias ads="sudo $apt_pref dselect-upgrade"
-
+
# Install all .deb files in the current directory.
# Warning: you will need to put the glob in single quotes if you use:
# glob_subst
@@ -113,9 +113,6 @@ alias allpkgs='aptitude search -F "%p" --disable-columns ~i'
alias mydeb='time dpkg-buildpackage -rfakeroot -us -uc'
-
-
-
# Functions #################################################################
# create a simple script that can be used to 'duplicate' a system
apt-copy() {
@@ -132,11 +129,46 @@ apt-copy() {
chmod +x apt-copy.sh
}
+# Prints apt history
+# Usage:
+# apt-history install
+# apt-history upgrade
+# apt-history remove
+# apt-history rollback
+# apt-history list
+# Based On: http://linuxcommando.blogspot.com/2008/08/how-to-show-apt-log-history.html
+apt-history () {
+ case "$1" in
+ install)
+ zgrep --no-filename 'install ' $(ls -rt /var/log/dpkg*)
+ ;;
+ upgrade|remove)
+ zgrep --no-filename $1 $(ls -rt /var/log/dpkg*)
+ ;;
+ rollback)
+ zgrep --no-filename upgrade $(ls -rt /var/log/dpkg*) | \
+ grep "$2" -A10000000 | \
+ grep "$3" -B10000000 | \
+ awk '{print $4"="$5}'
+ ;;
+ list)
+ zcat $(ls -rt /var/log/dpkg*)
+ ;;
+ *)
+ echo "Parameters:"
+ echo " install - Lists all packages that have been installed."
+ echo " upgrade - Lists all packages that have been upgraded."
+ echo " remove - Lists all packages that have been removed."
+ echo " rollback - Lists rollback information."
+ echo " list - Lists all contains of dpkg logs."
+ ;;
+ esac
+}
# Kernel-package building shortcut
kerndeb () {
# temporarily unset MAKEFLAGS ( '-j3' will fail )
- MAKEFLAGS=$( print - $MAKEFLAGS | perl -pe 's/-j\s*[\d]+//g' )
+ MAKEFLAGS=$( print - $MAKEFLAGS | perl -pe 's/-j\s*[\d]+//g' )
print '$MAKEFLAGS set to '"'$MAKEFLAGS'"
appendage='-custom' # this shows up in $ (uname -r )
revision=$(date +"%Y%m%d") # this shows up in the .deb file name
diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh
index 183c56c1c..c1b382b2c 100644
--- a/plugins/git/git.plugin.zsh
+++ b/plugins/git/git.plugin.zsh
@@ -17,6 +17,7 @@ alias gca='git commit -v -a'
compdef _git gca=git-commit
alias gco='git checkout'
compdef _git gco=git-checkout
+alias gcm='git checkout master'
alias gb='git branch'
compdef _git gb=git-branch
alias gba='git branch -a'
diff --git a/plugins/jake-node/jake-node.plugin.zsh b/plugins/jake-node/jake-node.plugin.zsh
new file mode 100644
index 000000000..a9eef4029
--- /dev/null
+++ b/plugins/jake-node/jake-node.plugin.zsh
@@ -0,0 +1,14 @@
+#---oh-my-zsh plugin : task Autocomplete for Jake tool---
+# Jake : https://github.com/mde/jake
+# Warning : Jakefile should have the right case : Jakefile or jakefile
+# Tested on : MacOSX 10.7 (Lion), Ubuntu 11.10
+# Author : Alexandre Lacheze (@al3xstrat)
+# Inspiration : http://weblog.rubyonrails.org/2006/3/9/fast-rake-task-completion-for-zsh
+
+function _jake () {
+ if [ -f Jakefile ]||[ -f jakefile ]; then
+ compadd `jake -T | cut -d " " -f 2 | sed -E "s/.\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g"`
+ fi
+}
+
+compdef _jake jake \ No newline at end of file
diff --git a/plugins/knife/_knife b/plugins/knife/_knife
index 7f8c95ee5..8453af5be 100644
--- a/plugins/knife/_knife
+++ b/plugins/knife/_knife
@@ -26,7 +26,7 @@ _knife() {
case $state in
knifecmd)
- compadd -Q "$@" bootstrap client configure cookbook "cookbook site" "data bag" exec index node recipe role search ssh status windows $cloudproviders
+ compadd -Q "$@" bootstrap client configure cookbook "cookbook site" "data bag" exec environment index node recipe role search ssh status windows $cloudproviders
;;
knifesubcmd)
case $words[2] in
@@ -42,6 +42,9 @@ _knife() {
cookbook)
compadd -Q "$@" test list create download delete "metadata from" show "bulk delete" metadata upload
;;
+ environment)
+ compadd -Q "$@" list create delete edit show "from file"
+ ;;
node)
compadd -Q "$@" "from file" create show edit delete list run_list "bulk delete"
;;
@@ -138,27 +141,31 @@ _knife_options3() {
# The chef_x_remote functions use knife to get a list of objects of type x on the server
_chef_roles_remote() {
- (knife role list | grep \" | awk '{print $1}' | awk -F"," '{print $1}' | awk -F"\"" '{print $2}')
+ (knife role list --format json | grep \" | awk '{print $1}' | awk -F"," '{print $1}' | awk -F"\"" '{print $2}')
}
_chef_clients_remote() {
- (knife client list | grep \" | awk '{print $1}' | awk -F"," '{print $1}' | awk -F"\"" '{print $2}')
+ (knife client list --format json | grep \" | awk '{print $1}' | awk -F"," '{print $1}' | awk -F"\"" '{print $2}')
}
_chef_nodes_remote() {
- (knife node list | grep \" | awk '{print $1}' | awk -F"," '{print $1}' | awk -F"\"" '{print $2}')
+ (knife node list --format json | grep \" | awk '{print $1}' | awk -F"," '{print $1}' | awk -F"\"" '{print $2}')
}
_chef_cookbooks_remote() {
- (knife cookbook list | grep \" | awk '{print $1}' | awk -F"," '{print $1}' | awk -F"\"" '{print $2}')
+ (knife cookbook list --format json | grep \" | awk '{print $1}' | awk -F"," '{print $1}' | awk -F"\"" '{print $2}')
}
_chef_sitecookbooks_remote() {
- (knife cookbook site list | grep \" | awk '{print $1}' | awk -F"," '{print $1}' | awk -F"\"" '{print $2}')
+ (knife cookbook site list --format json | grep \" | awk '{print $1}' | awk -F"," '{print $1}' | awk -F"\"" '{print $2}')
}
_chef_data_bags_remote() {
- (knife data bag list | grep \" | awk '{print $1}' | awk -F"," '{print $1}' | awk -F"\"" '{print $2}')
+ (knife data bag list --format json | grep \" | awk '{print $1}' | awk -F"," '{print $1}' | awk -F"\"" '{print $2}')
+}
+
+_chef_environments_remote() {
+ (knife environment list | awk '{print $1}')
}
# The chef_x_local functions use the knife config to find the paths of relevant objects x to be uploaded to the server
diff --git a/plugins/nyan/nyan.plugin.zsh b/plugins/nyan/nyan.plugin.zsh
new file mode 100644
index 000000000..6321e5f5a
--- /dev/null
+++ b/plugins/nyan/nyan.plugin.zsh
@@ -0,0 +1,5 @@
+if [[ -x `which nc` ]]; then
+ alias nyan='nc -v miku.acm.uiuc.edu 23' # nyan cat
+fi
+
+
diff --git a/plugins/pip/_pip b/plugins/pip/_pip
index b58010173..df53ba5ce 100644
--- a/plugins/pip/_pip
+++ b/plugins/pip/_pip
@@ -3,30 +3,43 @@
# pip zsh completion, based on homebrew completion
+_pip_all() {
+ # we cache the list of packages (originally from the macports plugin)
+ if (( ! $+piplist )); then
+ echo -n " (caching package index...)"
+ piplist=($(pip search * | cut -d ' ' -f 1 | tr '[A-Z]' '[a-z]'))
+ fi
+}
+
_pip_installed() {
- installed_pkgs=(`pip freeze`)
+ installed_pkgs=(`pip freeze | cut -d '=' -f 1`)
}
local -a _1st_arguments
_1st_arguments=(
- 'bundle:Create pybundles (archives containing multiple packages)'
- 'freeze:Output all currently installed packages (exact versions) to stdout'
- 'help:Show available commands'
- 'install:Install packages'
- 'search:Search PyPI'
- 'uninstall:Uninstall packages'
- 'unzip:Unzip individual packages'
- 'zip:Zip individual packages'
+ 'bundle:create pybundles (archives containing multiple packages)'
+ 'freeze:output all currently installed packages (exact versions) to stdout'
+ 'help:show available commands'
+ 'install:install packages'
+ 'search:search PyPI'
+ 'uninstall:uninstall packages'
+ 'unzip:unzip individual packages'
+ 'zip:zip individual packages'
)
local expl
-local -a pkgs installed_pkgs
+local -a all_pkgs installed_pkgs
_arguments \
- '(--version)--version[Show version number of program and exit]' \
- '(-v --verbose)'{-v,--verbose}'[Give more output]' \
- '(-q --quiet)'{-q,--quiet}'[Give less output]' \
- '(-h --help)'{-h,--help}'[Show help]' \
+ '(--version)--version[show version number of program and exit]' \
+ '(-h --help)'{-h,--help}'[show help]' \
+ '(-E --environment)'{-E,--environment}'[virtualenv environment to run pip in]' \
+ '(-s --enable-site-packages)'{-s,--enable-site-packages}'[include site-packages in virtualenv]' \
+ '(-v --verbose)'{-v,--verbose}'[give more output]' \
+ '(-q --quiet)'{-q,--quiet}'[give less output]' \
+ '(--log)--log[log file location]' \
+ '(--proxy)--proxy[proxy in form user:passwd@proxy.server:port]' \
+ '(--timeout)--timeout[socket timeout (default 15s)]' \
'*:: :->subcmds' && return 0
if (( CURRENT == 1 )); then
@@ -35,10 +48,25 @@ if (( CURRENT == 1 )); then
fi
case "$words[1]" in
- list)
- if [[ "$state" == forms ]]; then
- _pip_installed
- _requested installed_pkgs expl 'installed packages' compadd -a installed_pkgs
+ search)
+ _arguments \
+ '(--index)--index[base URL of Python Package Index]' ;;
+ freeze)
+ _arguments \
+ '(-l --local)'{-l,--local}'[report only virtualenv packages]' ;;
+ install)
+ _arguments \
+ '(-U --upgrade)'{-U,--upgrade}'[upgrade all packages to the newest available version]' \
+ '(-f --find-links)'{-f,--find-links}'[URL for finding packages]' \
+ '(--no-deps --no-dependencies)'{--no-deps,--no-dependencies}'[iIgnore package dependencies]' \
+ '(--no-install)--no-install[only download packages]' \
+ '(--no-download)--no-download[only install downloaded packages]' \
+ '(--install-option)--install-option[extra arguments to be supplied to the setup.py]' \
+ '1: :->packages' && return 0
+
+ if [[ "$state" == packages ]]; then
+ _pip_all
+ _wanted piplist expl 'packages' compadd -a piplist
fi ;;
uninstall)
_pip_installed
diff --git a/plugins/rails3/rails3.plugin.zsh b/plugins/rails3/rails3.plugin.zsh
index f4ee637e6..792cde2bd 100644
--- a/plugins/rails3/rails3.plugin.zsh
+++ b/plugins/rails3/rails3.plugin.zsh
@@ -17,3 +17,5 @@ alias rp='_rails_command plugin'
alias rs='_rails_command server'
alias rsd='_rails_command server --debugger'
alias devlog='tail -f log/development.log'
+alias rdm='rake db:migrate'
+alias rdr='rake db:rollback'
diff --git a/plugins/sprunge/sprunge.plugin.zsh b/plugins/sprunge/sprunge.plugin.zsh
new file mode 100644
index 000000000..9f9432ac8
--- /dev/null
+++ b/plugins/sprunge/sprunge.plugin.zsh
@@ -0,0 +1,64 @@
+# Contributed and SLIGHTLY modded by Matt Parnell/ilikenwf <parwok -at- gmail>
+# Created by the blogger at the URL below...I don't know where to find his/her name
+# Original found at http://www.shellperson.net/sprunge-pastebin-script/
+
+usage() {
+description | fmt -s >&2
+}
+
+description() {
+cat << HERE
+
+DESCRIPTION
+ Upload data and fetch URL from the pastebin http://sprunge.us
+
+USAGE
+ $0 filename.txt
+ $0 text string
+ $0 < filename.txt
+ piped_data | $0
+
+NOTES
+--------------------------------------------------------------------------
+* INPUT METHODS *
+$0 can accept piped data, STDIN redirection [<filename.txt], text strings following the command as arguments, or filenames as arguments. Only one of these methods can be used at a time, so please see the note on precedence. Also, note that using a pipe or STDIN redirection will treat tabs as spaces, or disregard them entirely (if they appear at the beginning of a line). So I suggest using a filename as an argument if tabs are important either to the function or readability of the code.
+
+* PRECEDENCE *
+STDIN redirection has precedence, then piped input, then a filename as an argument, and finally text strings as an arguments.
+
+ EXAMPLE:
+ echo piped | "$0" arguments.txt < stdin_redirection.txt
+
+In this example, the contents of file_as_stdin_redirection.txt would be uploaded. Both the piped_text and the file_as_argument.txt are ignored. If there is piped input and arguments, the arguments will be ignored, and the piped input uploaded.
+
+* FILENAMES *
+If a filename is misspelled or doesn't have the necessary path description, it will NOT generate an error, but will instead treat it as a text string and upload it.
+--------------------------------------------------------------------------
+
+HERE
+exit
+}
+
+sprunge() {
+ if [ -t 0 ]; then
+ echo Running interactively, checking for arguments... >&2
+ if [ "$*" ]; then
+ echo Arguments present... >&2
+ if [ -f "$*" ]; then
+ echo Uploading the contents of "$*"... >&2
+ cat "$*"
+ else
+ echo Uploading the text: \""$*"\"... >&2
+ echo "$*"
+ fi | curl -F 'sprunge=<-' http://sprunge.us
+ else
+ echo No arguments found, printing USAGE and exiting. >&2
+ usage
+ fi
+ else
+ echo Using input from a pipe or STDIN redirection... >&2
+ while read -r line ; do
+ echo $line
+ done | curl -F 'sprunge=<-' http://sprunge.us
+ fi
+}
diff --git a/plugins/symfony2/symfony2.plugin.zsh b/plugins/symfony2/symfony2.plugin.zsh
new file mode 100644
index 000000000..644266841
--- /dev/null
+++ b/plugins/symfony2/symfony2.plugin.zsh
@@ -0,0 +1,13 @@
+# Symfony2 basic command completion
+
+_symfony2_get_command_list () {
+ app/console --no-ansi | sed "1,/Available commands/d" | awk '/^ [a-z]+/ { print $1 }'
+}
+
+_symfony2 () {
+ if [ -f app/console ]; then
+ compadd `_symfony2_get_command_list`
+ fi
+}
+
+compdef _symfony2 app/console \ No newline at end of file
diff --git a/plugins/wakeonlan/README b/plugins/wakeonlan/README
new file mode 100644
index 000000000..16fdd4587
--- /dev/null
+++ b/plugins/wakeonlan/README
@@ -0,0 +1,29 @@
+This plugin provides a wrapper around the "wakeonlan" tool available from most
+distributions' package repositories, or from the following website:
+
+http://gsd.di.uminho.pt/jpo/software/wakeonlan/
+
+In order to use this wrapper, create the ~/.wakeonlan directory, and place in
+that directory one file for each device you would like to be able to wake. Give
+the file a name that describes the device, such as its hostname. Each file
+should contain a line with the mac address of the target device and the network
+broadcast address.
+
+For instance, there might be a file ~/.wakeonlan/leto with the following
+contents:
+
+00:11:22:33:44:55:66 192.168.0.255
+
+To wake that device, use the following command:
+
+# wake leto
+
+The available device names will be autocompleted, so:
+
+# wake <tab>
+
+...will suggest "leto", along with any other configuration files that were
+placed in the ~/.wakeonlan directory.
+
+For more information regarding the configuration file format, check the
+wakeonlan man page.
diff --git a/plugins/wakeonlan/_wake b/plugins/wakeonlan/_wake
new file mode 100644
index 000000000..4ab10d374
--- /dev/null
+++ b/plugins/wakeonlan/_wake
@@ -0,0 +1,4 @@
+#compdef wake
+#autoload
+
+_arguments "1:device to wake:_files -W '$HOME/.wakeonlan'" && return 0
diff --git a/plugins/wakeonlan/wakeonlan.plugin.zsh b/plugins/wakeonlan/wakeonlan.plugin.zsh
new file mode 100644
index 000000000..6cef7d44a
--- /dev/null
+++ b/plugins/wakeonlan/wakeonlan.plugin.zsh
@@ -0,0 +1,14 @@
+function wake() {
+ local config_file="$HOME/.wakeonlan/$1"
+ if [[ ! -f "$config_file" ]]; then
+ echo "ERROR: There is no configuration file at \"$config_file\"."
+ return 1
+ fi
+
+ if (( ! $+commands[wakeonlan] )); then
+ echo "ERROR: Can't find \"wakeonlan\". Are you sure it's installed?"
+ return 1
+ fi
+
+ wakeonlan -f "$config_file"
+}