diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/aws/aws.plugin.zsh | 17 | ||||
-rw-r--r-- | plugins/battery/battery.plugin.zsh | 10 | ||||
-rw-r--r-- | plugins/brew/_brew | 75 | ||||
-rw-r--r-- | plugins/docker/_docker | 2 | ||||
-rw-r--r-- | plugins/emacs/emacs.plugin.zsh | 56 | ||||
-rwxr-xr-x | plugins/emacs/emacsclient.sh | 12 | ||||
-rw-r--r-- | plugins/github/github.plugin.zsh | 9 | ||||
-rw-r--r-- | plugins/lol/lol.plugin.zsh | 12 | ||||
-rw-r--r-- | plugins/mercurial/mercurial.plugin.zsh | 2 | ||||
-rw-r--r-- | plugins/meteor/_meteor | 48 | ||||
-rw-r--r-- | plugins/mvn/mvn.plugin.zsh | 5 | ||||
-rw-r--r-- | plugins/rails/rails.plugin.zsh | 8 | ||||
-rw-r--r-- | plugins/svn/svn.plugin.zsh | 21 |
13 files changed, 251 insertions, 26 deletions
diff --git a/plugins/aws/aws.plugin.zsh b/plugins/aws/aws.plugin.zsh new file mode 100644 index 000000000..3f7fb1995 --- /dev/null +++ b/plugins/aws/aws.plugin.zsh @@ -0,0 +1,17 @@ +export AWS_HOME=~/.aws + +function agp { + echo $AWS_DEFAULT_PROFILE + +} +function asp { + export AWS_DEFAULT_PROFILE=$1 + export RPROMPT="<aws:$AWS_DEFAULT_PROFILE>" + +} +function aws_profiles { + reply=($(grep profile $AWS_HOME/config|sed -e 's/.*profile \([a-zA-Z0-9_-]*\).*/\1/')) +} + +compctl -K aws_profiles asp +source `which aws_zsh_completer.sh` diff --git a/plugins/battery/battery.plugin.zsh b/plugins/battery/battery.plugin.zsh index 16ad3e651..e39cc5b8f 100644 --- a/plugins/battery/battery.plugin.zsh +++ b/plugins/battery/battery.plugin.zsh @@ -17,12 +17,16 @@ if [[ $(uname) == "Darwin" ]] ; then integer i=$(((currentcapacity/maxcapacity) * 100)) echo $i } + + function plugged_in() { + [ $(ioreg -rc AppleSmartBattery | grep -c '^.*"ExternalConnected"\ =\ Yes') -eq 1 ] + } function battery_pct_remaining() { - if [[ $(ioreg -rc AppleSmartBattery | grep -c '^.*"ExternalConnected"\ =\ No') -eq 1 ]] ; then - battery_pct - else + if plugged_in ; then echo "External Power" + else + battery_pct fi } diff --git a/plugins/brew/_brew b/plugins/brew/_brew index d4306f223..9eb3bb557 100644 --- a/plugins/brew/_brew +++ b/plugins/brew/_brew @@ -11,10 +11,25 @@ _brew_installed_formulae() { installed_formulae=(`brew list`) } +_brew_installed_taps() { + installed_taps=(`brew tap`) +} + +_brew_outdated_formulae() { + outdated_formulae=(`brew outdated`) +} + +_brew_running_services() { + running_services=(`brew services list | awk '{print $1}'`) +} + local -a _1st_arguments _1st_arguments=( + 'audit:check formulae for Homebrew coding style' + 'bundle:look for a Brewfile and run each line as a brew command' 'cat:display formula file for a formula' 'cleanup:uninstall unused and old versions of packages' + 'commands:show a list of commands' 'create:create a new formula' 'deps:list dependencies and dependants of a formula' 'doctor:audits your installation for common issues' @@ -22,27 +37,38 @@ _1st_arguments=( 'home:visit the homepage of a formula or the brew project' 'info:information about a formula' 'install:install a formula' + 'reinstall:install a formula anew; re-using its current options' 'link:link a formula' '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' + 'outdated:list formulae for which a newer version is available' + 'pin:pin specified formulae' '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' + 'services:small wrapper around `launchctl` for supported formulae' + 'tap:tap a new formula repository from GitHub, or list existing taps' 'unlink:unlink a formula' + 'unpin:unpin specified formulae' + 'untap:remove a tapped repository' 'update:freshen up links' 'upgrade:upgrade outdated formulae' - 'uses:show formulas which depend on a formula' - 'versions:show all available formula versions' + 'uses:show formulae which depend on a formula' +) + +local -a _service_arguments +_service_arguments=( + 'cleanup:get rid of stale services and unused plists' + 'list:list all services managed by `brew services`' + 'restart:gracefully restart selected service' + 'start:start selected service' + 'stop:stop selected service' ) local expl -local -a formulae installed_formulae +local -a formulae installed_formulae installed_taps outdated_formulae running_services _arguments \ '(-v)-v[verbose]' \ @@ -61,24 +87,41 @@ if (( CURRENT == 1 )); then fi case "$words[1]" in - search|-S) - _arguments \ - '(--macports)--macports[search the macports repository]' \ - '(--fink)--fink[search the fink repository]' ;; + install|reinstall|audit|home|homepage|log|info|abv|uses|cat|deps|edit|options) + _brew_all_formulae + _wanted formulae expl 'all formulae' compadd -a formulae ;; list|ls) _arguments \ '(--unbrewed)--unbrewed[files in brew --prefix not controlled by brew]' \ + '(--pinned)--pinned[list all versions of pinned formulae]' \ '(--versions)--versions[list all installed versions of a formula]' \ - '1: :->forms' && return 0 + '1: :->forms' && return 0 if [[ "$state" == forms ]]; then _brew_installed_formulae _wanted installed_formulae expl 'installed formulae' compadd -a installed_formulae fi ;; - install|home|homepage|log|info|abv|uses|cat|deps|edit|options|versions) - _brew_all_formulae - _wanted formulae expl 'all formulae' compadd -a formulae ;; - reinstall|remove|rm|uninstall|unlink|cleanup|link|ln) + remove|rm|uninstall|unlink|cleanup|link|ln|pin|unpin) _brew_installed_formulae _wanted installed_formulae expl 'installed formulae' compadd -a installed_formulae ;; + search|-S) + _arguments \ + '(--macports)--macports[search the macports repository]' \ + '(--fink)--fink[search the fink repository]' ;; + services) + if [[ -n "$words[2]" ]]; then + case "$words[2]" in + restart|start|stop) + _brew_running_services + _wanted running_services expl 'running services' compadd -a running_services ;; + esac + else + _describe -t commands "brew services subcommand" _service_arguments + fi ;; + untap) + _brew_installed_taps + _wanted installed_taps expl 'installed taps' compadd -a installed_tapsĀ ;; + upgrade) + _brew_outdated_formulae + _wanted outdated_formulae expl 'outdated formulae' compadd -a outdated_formulae ;; esac diff --git a/plugins/docker/_docker b/plugins/docker/_docker index f13f876cf..12eee7a15 100644 --- a/plugins/docker/_docker +++ b/plugins/docker/_docker @@ -111,7 +111,7 @@ __ps() { '-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]' \ + '-notrunc[Dont truncate output]' \ '-q[Only display numeric IDs]' \ '-s[Display sizes]' \ '-sinceId="[Show only containers created since Id, include non-running ones.]' diff --git a/plugins/emacs/emacs.plugin.zsh b/plugins/emacs/emacs.plugin.zsh new file mode 100644 index 000000000..a3f0085a8 --- /dev/null +++ b/plugins/emacs/emacs.plugin.zsh @@ -0,0 +1,56 @@ +# Emacs 23 daemon capability is a killing feature. +# One emacs process handles all your frames whether +# you use a frame opened in a terminal via a ssh connection or X frames +# opened on the same host. + +# Benefits are multiple +# - You don't have the cost of starting Emacs all the time anymore +# - Opening a file is as fast as Emacs does not have anything else to do. +# - You can share opened buffered across opened frames. +# - Configuration changes made at runtime are applied to all frames. + + +if "$ZSH/tools/require_tool.sh" emacs 23 2>/dev/null ; then + export EMACS_PLUGIN_LAUNCHER="$ZSH/plugins/emacs/emacsclient.sh" + + # set EDITOR if not already defined. + export EDITOR="${EDITOR:-${EMACS_PLUGIN_LAUNCHER}}" + + alias emacs="$EMACS_PLUGIN_LAUNCHER --no-wait" + alias e=emacs + + # same than M-x eval but from outside Emacs. + alias eeval="$EMACS_PLUGIN_LAUNCHER --eval" + # create a new X frame + alias eframe='emacsclient --alternate-editor "" --create-frame' + + # to code all night long + alias emasc=emacs + alias emcas=emacs + + # Write to standard output the path to the file + # opened in the current buffer. + function efile { + local cmd="(buffer-file-name (window-buffer))" + "$EMACS_PLUGIN_LAUNCHER" --eval "$cmd" | tr -d \" + } + + # Write to standard output the directory of the file + # opened in the the current buffer + function ecd { + local cmd="(let ((buf-name (buffer-file-name (window-buffer)))) + (if buf-name (file-name-directory buf-name)))" + + local dir="$($EMACS_PLUGIN_LAUNCHER --eval $cmd | tr -d \")" + if [ -n "$dir" ] ;then + echo "$dir" + else + echo "can not deduce current buffer filename." >/dev/stderr + return 1 + fi + } +fi + +## Local Variables: +## mode: sh +## End: diff --git a/plugins/emacs/emacsclient.sh b/plugins/emacs/emacsclient.sh new file mode 100755 index 000000000..38d419813 --- /dev/null +++ b/plugins/emacs/emacsclient.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +# get list of available X windows. +x=`emacsclient --alternate-editor '' --eval '(x-display-list)' 2>/dev/null` + +if [ -z "$x" ] ;then + # Create one if there is no X window yet. + emacsclient --alternate-editor "" --create-frame "$@" +else + # prevent creating another X frame if there is at least one present. + emacsclient --alternate-editor "" "$@" +fi diff --git a/plugins/github/github.plugin.zsh b/plugins/github/github.plugin.zsh index 66a10cfdb..25b1a1e1b 100644 --- a/plugins/github/github.plugin.zsh +++ b/plugins/github/github.plugin.zsh @@ -84,5 +84,14 @@ exist_gh() { # [DIRECTORY] git push -u origin master } +# git.io "GitHub URL" +# +# Shorten GitHub url, example: +# https://github.com/nvogel/dotzsh > http://git.io/8nU25w +# source: https://github.com/nvogel/dotzsh +# documentation: https://github.com/blog/985-git-io-github-url-shortener +# +git.io() {curl -i -s http://git.io -F "url=$1" | grep "Location" | cut -f 2 -d " "} + # End Functions ############################################################# diff --git a/plugins/lol/lol.plugin.zsh b/plugins/lol/lol.plugin.zsh index ae065c12f..1b32ec2e4 100644 --- a/plugins/lol/lol.plugin.zsh +++ b/plugins/lol/lol.plugin.zsh @@ -36,3 +36,15 @@ alias nomnom='killall' alias byes='exit' alias cya='reboot' alias kthxbai='halt' + +alias pwned='ssh' + +alias hackzor='git init' +alias rulz='git push' +alias bringz='git pull' +alias chicken='git add' +alias oanward='git commit -m' +alias ooanward='git commit -am' +alias letcat='git checkout' +alias violenz='git rebase' + diff --git a/plugins/mercurial/mercurial.plugin.zsh b/plugins/mercurial/mercurial.plugin.zsh index d2db89d04..2e99a12fb 100644 --- a/plugins/mercurial/mercurial.plugin.zsh +++ b/plugins/mercurial/mercurial.plugin.zsh @@ -13,7 +13,7 @@ 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" ' +alias hgsl='hg 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' diff --git a/plugins/meteor/_meteor b/plugins/meteor/_meteor new file mode 100644 index 000000000..cd7fc304f --- /dev/null +++ b/plugins/meteor/_meteor @@ -0,0 +1,48 @@ +#compdef meteor +#autoload + +# Meteor Autocomplete plugin for Oh-My-Zsh, based on homebrew completion +# Original author: Dimitri JORGE (https://github.com/jorge-d) + +_meteor_all_packages() { + packages=(`meteor list | cut -d" " -f1`) +} +_meteor_installed_packages() { + installed_packages=(`meteor list --using`) +} + +local -a _1st_arguments +_1st_arguments=( + 'run:[Default] Run this project in local development mode' + 'create:Create a new project' + 'update:Upgrade this project to the latest version of Meteor' + 'add:Add a package to this project' + 'remove:Remove a package from this project' + 'list:List available packages' + 'help:Display Meteor help' + 'bundle:Pack this project up into a tarball' + 'mongo:Connect to the Mongo database for the specified site' + 'deploy:Deploy this project to Meteor' + 'logs:Show logs for specified site' + 'reset:Reset the project state. Erases the local database.' + 'test-packages:Test one or more packages' +) + +local expl +local -a packages installed_packages + +if (( CURRENT == 2 )); then + _describe -t commands "meteor subcommand" _1st_arguments + return +fi + +case "$words[2]" in + help) + _describe -t commands "meteor subcommand" _1st_arguments ;; + remove) + _meteor_installed_packages + _wanted installed_packages expl 'installed packages' compadd -a installed_packages ;; + add) + _meteor_all_packages + _wanted packages expl 'all packages' compadd -a packages ;; +esac
\ No newline at end of file diff --git a/plugins/mvn/mvn.plugin.zsh b/plugins/mvn/mvn.plugin.zsh index 0c9141907..ed7968534 100644 --- a/plugins/mvn/mvn.plugin.zsh +++ b/plugins/mvn/mvn.plugin.zsh @@ -52,6 +52,11 @@ alias mvnc='mvn clean' alias mvncom='mvn compile' alias mvnt='mvn test' alias mvnag='mvn archetype:generate' +alias mvn-updates='mvn versions:display-dependency-updates' +alias mvntc7='mvn tomcat7:run' +alias mvntc='mvn tomcat:run' +alias mvnjetty='mvn jetty:run' + function listMavenCompletions { reply=( diff --git a/plugins/rails/rails.plugin.zsh b/plugins/rails/rails.plugin.zsh index 4a96754e4..fb46cdcf0 100644 --- a/plugins/rails/rails.plugin.zsh +++ b/plugins/rails/rails.plugin.zsh @@ -1,10 +1,10 @@ function _rails_command () { - if [ -e "script/server" ]; then - ruby script/$@ + if [ -e "bin/rails" ]; then + bin/rails $@ elif [ -e "script/rails" ]; then ruby script/rails $@ - elif [ -e "bin/rails" ]; then - bin/rails $@ + elif [ -e "script/server" ]; then + ruby script/$@ else rails $@ fi diff --git a/plugins/svn/svn.plugin.zsh b/plugins/svn/svn.plugin.zsh index 4f008ba4e..ef6da5bd3 100644 --- a/plugins/svn/svn.plugin.zsh +++ b/plugins/svn/svn.plugin.zsh @@ -9,7 +9,7 @@ function svn_prompt_info() { _DISPLAY=$(svn_get_repo_name) fi echo "$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_SVN_PROMPT_PREFIX\ -$ZSH_THEME_REPO_NAME_COLOR$_DISPLAY$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_SVN_PROMPT_SUFFIX$ZSH_PROMPT_BASE_COLOR$(svn_dirty)$ZSH_PROMPT_BASE_COLOR" +$ZSH_THEME_REPO_NAME_COLOR$_DISPLAY$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_SVN_PROMPT_SUFFIX$ZSH_PROMPT_BASE_COLOR$(svn_dirty)$(svn_dirty_pwd)$ZSH_PROMPT_BASE_COLOR" unset _DISPLAY fi } @@ -74,3 +74,22 @@ function svn_dirty_choose() { function svn_dirty() { svn_dirty_choose $ZSH_THEME_SVN_PROMPT_DIRTY $ZSH_THEME_SVN_PROMPT_CLEAN } + +function svn_dirty_choose_pwd () { + if in_svn; then + root=`pwd` + if $(svn status $root 2> /dev/null | grep -Eq '^\s*[ACDIM!?L]'); 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 svn_dirty_pwd () { + svn_dirty_choose_pwd $ZSH_THEME_SVN_PROMPT_DIRTY_PWD $ZSH_THEME_SVN_PROMPT_CLEAN_PWD +} + + |