diff options
-rw-r--r-- | MIT-LICENSE.txt | 2 | ||||
-rw-r--r-- | README.textile | 19 | ||||
-rw-r--r-- | plugins/battery/battery.plugin.zsh | 10 | ||||
-rw-r--r-- | plugins/brew/_brew | 75 | ||||
-rw-r--r-- | plugins/emacs/emacs.plugin.zsh | 56 | ||||
-rwxr-xr-x | plugins/emacs/emacsclient.sh | 12 | ||||
-rw-r--r-- | plugins/lol/lol.plugin.zsh | 12 | ||||
-rw-r--r-- | plugins/rails/rails.plugin.zsh | 8 | ||||
-rw-r--r-- | templates/zshrc.zsh-template | 11 | ||||
-rw-r--r-- | themes/bureau.zsh-theme | 6 | ||||
-rwxr-xr-x | tools/install.sh | 21 |
11 files changed, 187 insertions, 45 deletions
diff --git a/MIT-LICENSE.txt b/MIT-LICENSE.txt index f6edab65b..6eb8aab34 100644 --- a/MIT-LICENSE.txt +++ b/MIT-LICENSE.txt @@ -1,6 +1,6 @@ The MIT License -Copyright (c) 2009-2013 Robby Russell and contributors (see https://github.com/robbyrussell/oh-my-zsh/contributors) +Copyright (c) 2009-2014 Robby Russell and contributors (see https://github.com/robbyrussell/oh-my-zsh/contributors) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.textile b/README.textile index 810569486..c808fb5d7 100644 --- a/README.textile +++ b/README.textile @@ -14,15 +14,25 @@ You can install this via the command line with either `curl` or `wget`. h4. via `curl` -@curl -L https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh | sh@ +@curl -L http://install.ohmyz.sh | sh@ h4. via `wget` -@wget --no-check-certificate https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O - | sh@ +@wget --no-check-certificate http://install.ohmyz.sh -O - | sh@ -h3. The manual way +h4. Optional: change the install directory + +The default location is `~/.oh-my-zsh` (hidden in your home directory). + +You can change the install directory with the ZSH environment variable, either +by running `export ZSH=/your/path` before installing, or setting it before the +end of the install pipeline like this: + +@curl -L https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh | ZSH=~/.dotfiles/zsh sh@ +h3. The manual way + 1. Clone the repository @git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh@ @@ -35,7 +45,6 @@ h3. The manual way @cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc@ - 4. Set zsh as your default shell: @chsh -s /bin/zsh@ @@ -46,6 +55,8 @@ h3. Problems? You _might_ need to modify your PATH in ~/.zshrc if you're not able to find some commands after switching to _Oh My Zsh_. +If you installed manually or changed the install location, check ZSH in ~/.zshrc + h2. Usage * enable the plugins you want in your @~/.zshrc@ (take a look at @plugins/@ to see what's possible) 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/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/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/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/templates/zshrc.zsh-template b/templates/zshrc.zsh-template index b2cad20e8..c2254d055 100644 --- a/templates/zshrc.zsh-template +++ b/templates/zshrc.zsh-template @@ -11,13 +11,13 @@ ZSH_THEME="robbyrussell" # alias zshconfig="mate ~/.zshrc" # alias ohmyzsh="mate ~/.oh-my-zsh" -# Set to this to use case-sensitive completion +# Set this to use case-sensitive completion # CASE_SENSITIVE="true" # Uncomment this to disable bi-weekly auto-update checks # DISABLE_AUTO_UPDATE="true" -# Uncomment to change how often before auto-updates occur? (in days) +# Uncomment to change how often to auto-update? (in days) # export UPDATE_ZSH_DAYS=13 # Uncomment following line if you want to disable colors in ls @@ -37,9 +37,9 @@ ZSH_THEME="robbyrussell" # much faster. # DISABLE_UNTRACKED_FILES_DIRTY="true" -# Uncomment following line if you want to shown in the command execution time stamp -# in the history command output. The optional three formats: "mm/dd/yyyy"|"dd.mm.yyyy"| -# yyyy-mm-dd +# Uncomment following line if you want to the command execution time stamp shown +# in the history command output. +# The optional three formats: "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd" # HIST_STAMPS="mm/dd/yyyy" # Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*) @@ -66,4 +66,3 @@ export PATH=$HOME/bin:/usr/local/bin:$PATH # ssh # export SSH_KEY_PATH="~/.ssh/dsa_id" - diff --git a/themes/bureau.zsh-theme b/themes/bureau.zsh-theme index 1d88f54d0..4d9cae0cc 100644 --- a/themes/bureau.zsh-theme +++ b/themes/bureau.zsh-theme @@ -101,12 +101,12 @@ _1RIGHT="[%*] " bureau_precmd () { _1SPACES=`get_space $_1LEFT $_1RIGHT` - echo + print + print -rP "$_1LEFT$_1SPACES$_1RIGHT" } setopt prompt_subst -PROMPT='$_1LEFT$_1SPACES$_1RIGHT -> $_LIBERTY ' +PROMPT='> $_LIBERTY ' RPROMPT='$(nvm_prompt_info) $(bureau_git_prompt)' autoload -U add-zsh-hook diff --git a/tools/install.sh b/tools/install.sh index b24bb4ad3..343f251ae 100755 --- a/tools/install.sh +++ b/tools/install.sh @@ -1,16 +1,18 @@ -ZSH=`/usr/bin/env|grep 'ZSH='|cut -d '=' -f 2` -if [ -d "$ZSH" ] +set -e + +if [ ! -n $ZSH ] then - echo "\033[0;33mYou already have Oh My Zsh installed.\033[0m You'll need to remove $ZSH if you want to install" - exit -elif [ -d ~/.oh-my-zsh ] + ZSH=~/.oh-my-zsh +fi + +if [ -d $ZSH ] then - echo "\033[0;33mYou already have One Oh My Zsh Directory.\033[0m You'll need to remove ~/.oh-my-zsh if you want to clone" + echo "\033[0;33mYou already have Oh My Zsh installed.\033[0m You'll need to remove $ZSH if you want to install" exit fi echo "\033[0;34mCloning Oh My Zsh...\033[0m" -hash git >/dev/null && /usr/bin/env git clone https://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh || { +hash git >/dev/null && /usr/bin/env git clone https://github.com/robbyrussell/oh-my-zsh.git $ZSH || { echo "git not installed" exit } @@ -23,7 +25,10 @@ then fi echo "\033[0;34mUsing the Oh My Zsh template file and adding it to ~/.zshrc\033[0m" -cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc +cp $ZSH/templates/zshrc.zsh-template ~/.zshrc +sed -i -e "/^ZSH=/ c\\ +ZSH=$ZSH +" ~/.zshrc echo "\033[0;34mCopying your current PATH and adding it to the end of ~/.zshrc for you.\033[0m" sed -i -e "/export PATH=/ c\\ |