Skip to content

Commit dce4148

Browse files
committed
Merge branch 'master' of git://github.com/robbyrussell/oh-my-zsh
2 parents fe1ed11 + 1120f97 commit dce4148

36 files changed

+393
-161
lines changed

README.textile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ the "refcard":http://www.bash2zsh.com/zsh_refcard/refcard.pdf is pretty tasty fo
5656
h3. Customization
5757

5858
If you want to override any of the default behavior, just add a new file (ending in @.zsh@) into the @custom/@ directory.
59-
If you have many functions which go good together you can put them as a *.plugin.zsh file in the @custom/plugins/@ directory and then enable this plugin.
59+
If you have many functions which go well together you can put them as a *.plugin.zsh file in the @custom/plugins/@ directory and then enable this plugin.
6060
If you would like to override the functionality of a plugin distributed with oh-my-zsh, create a plugin of the same name in the @custom/plugins/@ directory and it will be loaded instead of the one in @plugins/@.
6161

6262

lib/git.zsh

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,21 @@ function git_prompt_info() {
44
echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_SUFFIX"
55
}
66

7+
78
# Checks if working tree is dirty
89
parse_git_dirty() {
9-
if [[ -n $(git status -s --ignore-submodules=dirty 2> /dev/null) ]]; then
10+
local SUBMODULE_SYNTAX=''
11+
if [[ $POST_1_7_2_GIT -gt 0 ]]; then
12+
SUBMODULE_SYNTAX="--ignore-submodules=dirty"
13+
fi
14+
if [[ -n $(git status -s ${SUBMODULE_SYNTAX} 2> /dev/null) ]]; then
1015
echo "$ZSH_THEME_GIT_PROMPT_DIRTY"
1116
else
1217
echo "$ZSH_THEME_GIT_PROMPT_CLEAN"
1318
fi
1419
}
1520

21+
1622
# Checks if there are commits ahead from remote
1723
function git_prompt_ahead() {
1824
if $(echo "$(git log origin/$(current_branch)..HEAD 2> /dev/null)" | grep '^commit' &> /dev/null); then
@@ -62,3 +68,29 @@ git_prompt_status() {
6268
fi
6369
echo $STATUS
6470
}
71+
72+
#compare the provided version of git to the version installed and on path
73+
#prints 1 if input version <= installed version
74+
#prints -1 otherwise
75+
function git_compare_version() {
76+
local INPUT_GIT_VERSION=$1;
77+
local INSTALLED_GIT_VERSION
78+
INPUT_GIT_VERSION=(${(s/./)INPUT_GIT_VERSION});
79+
INSTALLED_GIT_VERSION=($(git --version));
80+
INSTALLED_GIT_VERSION=(${(s/./)INSTALLED_GIT_VERSION[3]});
81+
82+
for i in {1..3}; do
83+
if [[ $INSTALLED_GIT_VERSION[$i] -lt $INPUT_GIT_VERSION[$i] ]]; then
84+
echo -1
85+
return 0
86+
fi
87+
done
88+
echo 1
89+
}
90+
91+
#this is unlikely to change so make it all statically assigned
92+
POST_1_7_2_GIT=$(git_compare_version "1.7.2")
93+
#clean up the namespace slightly by removing the checker function
94+
unset -f git_compare_version
95+
96+

oh-my-zsh.sh

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,19 @@ if [[ -z "$ZSH_CUSTOM" ]]; then
1919
ZSH_CUSTOM="$ZSH/custom"
2020
fi
2121

22+
23+
is_plugin() {
24+
local base_dir=$1
25+
local name=$2
26+
test -f $base_dir/plugins/$name/$name.plugin.zsh \
27+
|| test -f $base_dir/plugins/$name/_$name
28+
}
2229
# Add all defined plugins to fpath. This must be done
2330
# before running compinit.
24-
plugin=${plugin:=()}
2531
for plugin ($plugins); do
26-
if [ -f $ZSH_CUSTOM/plugins/$plugin/$plugin.plugin.zsh ]; then
32+
if is_plugin $ZSH_CUSTOM $plugin; then
2733
fpath=($ZSH_CUSTOM/plugins/$plugin $fpath)
28-
elif [ -f $ZSH/plugins/$plugin/$plugin.plugin.zsh ]; then
34+
elif is_plugin $ZSH $plugin; then
2935
fpath=($ZSH/plugins/$plugin $fpath)
3036
fi
3137
done

plugins/autojump/autojump.plugin.zsh

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
if [ -f /opt/local/etc/profile.d/autojump.sh ]; then
2-
. /opt/local/etc/profile.d/autojump.sh
3-
elif [ -f `brew --prefix`/etc/autojump ]; then
4-
. `brew --prefix`/etc/autojump
1+
if [ $commands[autojump] ]; then # check if autojump is installed
2+
if [ -f /usr/share/autojump/autojump.zsh ]; then # debian and ubuntu package
3+
. /usr/share/autojump/autojump.zsh
4+
elif [ -f /etc/profile.d/autojump.zsh ]; then # manual installation
5+
. /etc/profile.d/autojump.zsh
6+
elif [ $commands[brew] -a -f `brew --prefix`/etc/autojump ]; then # mac os x with brew
7+
. `brew --prefix`/etc/autojump
8+
fi
59
fi

plugins/bundler/bundler.plugin.zsh

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
fpath=($ZSH/plugins/bundler $fpath)
2-
autoload -U compinit
3-
compinit -i
4-
51
alias be="bundle exec"
62
alias bi="bundle install"
73
alias bl="bundle list"
@@ -10,7 +6,7 @@ alias bu="bundle update"
106

117
# The following is based on https://github.com/gma/bundler-exec
128

13-
bundled_commands=(annotate cap capify cucumber foreman guard heroku nanoc rackup rainbows rake rspec ruby shotgun spec spork thin unicorn unicorn_rails)
9+
bundled_commands=(annotate cap capify cucumber ey foreman guard heroku middleman nanoc rackup rainbows rails rake rspec ruby shotgun spec spork thin thor unicorn unicorn_rails)
1410

1511
## Functions
1612

@@ -20,7 +16,7 @@ _bundler-installed() {
2016

2117
_within-bundled-project() {
2218
local check_dir=$PWD
23-
while [ "$(dirname $check_dir)" != "/" ]; do
19+
while [ $check_dir != "/" ]; do
2420
[ -f "$check_dir/Gemfile" ] && return
2521
check_dir="$(dirname $check_dir)"
2622
done

plugins/django/django.plugin.zsh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,3 +220,4 @@ _managepy() {
220220

221221
compdef _managepy manage.py
222222
compdef _managepy django
223+
compdef _managepy django-manage

plugins/extract/extract.plugin.zsh

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,3 @@ function extract() {
7878

7979
alias x=extract
8080

81-
# add extract completion function to path
82-
fpath=($ZSH/plugins/extract $fpath)
83-
autoload -U compinit
84-
compinit -i
85-

plugins/git/git.plugin.zsh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ alias gup='git fetch && git rebase'
99
compdef _git gup=git-fetch
1010
alias gp='git push'
1111
compdef _git gp=git-push
12-
gdv() { git-diff -w "$@" | view - }
12+
gdv() { git diff -w "$@" | view - }
1313
compdef _git gdv=git-diff
1414
alias gc='git commit -v'
1515
compdef _git gc=git-commit
@@ -36,6 +36,8 @@ alias ga='git add'
3636
compdef _git ga=git-add
3737
alias gm='git merge'
3838
compdef _git gm=git-merge
39+
alias grh='git reset HEAD'
40+
alias grhh='git reset HEAD --hard'
3941

4042
# Git and svn mix
4143
alias git-svn-dcommit-push='git svn dcommit && git push github master:svntrunk'
@@ -58,4 +60,4 @@ compdef ggpull=git
5860
alias ggpush='git push origin $(current_branch)'
5961
compdef ggpush=git
6062
alias ggpnp='git pull origin $(current_branch) && git push origin $(current_branch)'
61-
compdef ggpnp=git
63+
compdef ggpnp=git

plugins/github/github.plugin.zsh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
11
# Setup hub function for git, if it is available; http://github.com/defunkt/hub
22
if [ "$commands[(I)hub]" ] && [ "$commands[(I)ruby]" ]; then
33
# eval `hub alias -s zsh`
4-
function git(){hub "$@"}
4+
function git(){
5+
if ! (( $+_has_working_hub )); then
6+
hub --version &> /dev/null
7+
_has_working_hub=$(($? == 0))
8+
fi
9+
if (( $_has_working_hub )) ; then
10+
hub "$@"
11+
else
12+
command git "$@"
13+
fi
14+
}
515
fi
616

717
# Functions #################################################################
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11

22
# Mercurial
3-
alias hgc='hg commit -v'
4-
alias hgb='hg branch -v'
3+
alias hgc='hg commit'
4+
alias hgb='hg branch'
55
alias hgba='hg branches'
66
alias hgco='hg checkout'
77
alias hgd='hg diff'
88
alias hged='hg diffmerge'
99
# pull and update
10-
alias hgl='hg pull -u -v'
11-
alias hgp='hg push -v'
12-
alias hgs='hg status -v'
10+
alias hgl='hg pull -u'
11+
alias hgp='hg push'
12+
alias hgs='hg status'
1313
# this is the 'git commit --amend' equivalent
1414
alias hgca='hg qimport -r tip ; hg qrefresh -e ; hg qfinish tip'

plugins/pow/pow.plugin.zsh

Lines changed: 63 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,66 @@
1-
# Thanks to Christopher Sexton
2-
# https://gist.github.com/965032
3-
function kapow {
4-
touch ~/.pow/$1/tmp/restart.txt
5-
if [ $? -eq 0 ]; then
6-
echo "$fg[yellow]Pow restarting $1...$reset_color"
7-
fi
1+
# Restart a rack app running under pow
2+
# http://pow.cx/
3+
#
4+
# Adds a kapow command that will restart an app
5+
#
6+
# $ kapow myapp
7+
#
8+
# Supports command completion.
9+
#
10+
# If you are not already using completion you might need to enable it with
11+
#
12+
# autoload -U compinit compinit
13+
#
14+
# Changes:
15+
#
16+
# Defaults to the current application, and will walk up the tree to find
17+
# a config.ru file and restart the corresponding app
18+
#
19+
# Will Detect if a app does not exist in pow and print a (slightly) helpful
20+
# error message
21+
22+
rack_root_detect(){
23+
setopt chaselinks
24+
local orgdir=$(pwd)
25+
local basedir=$(pwd)
26+
27+
while [[ $basedir != '/' ]]; do
28+
test -e "$basedir/config.ru" && break
29+
builtin cd ".." 2>/dev/null
30+
basedir="$(pwd)"
31+
done
32+
33+
builtin cd $orgdir 2>/dev/null
34+
[[ ${basedir} == "/" ]] && return 1
35+
echo `basename $basedir | sed -E "s/.(com|net|org)//"`
836
}
937

38+
kapow(){
39+
local vhost=$1
40+
[ ! -n "$vhost" ] && vhost=$(rack_root_detect)
41+
if [ ! -h ~/.pow/$vhost ]
42+
then
43+
echo "pow: This domain isn’t set up yet. Symlink your application to ${vhost} first."
44+
return 1
45+
fi
46+
47+
[ ! -d ~/.pow/${vhost}/tmp ] && mkdir -p ~/.pow/$vhost/tmp
48+
touch ~/.pow/$vhost/tmp/restart.txt;
49+
[ $? -eq 0 ] && echo "pow: restarting $vhost.dev"
50+
}
1051
compctl -W ~/.pow -/ kapow
52+
53+
powit(){
54+
local basedir=$(pwd)
55+
local vhost=$1
56+
[ ! -n "$vhost" ] && vhost=$(rack_root_detect)
57+
if [ ! -h ~/.pow/$vhost ]
58+
then
59+
echo "pow: Symlinking your app with pow. ${vhost}"
60+
[ ! -d ~/.pow/${vhost} ] && ln -s $basedir ~/.pow/$vhost
61+
return 1
62+
fi
63+
}
64+
65+
# View the standard out (puts) from any pow app
66+
alias kaput="tail -f ~/Library/Logs/Pow/apps/*"

plugins/rails/rails.plugin.zsh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ alias ss='thin --stats "/thin/stats" start'
22
alias sg='ruby script/generate'
33
alias sd='ruby script/destroy'
44
alias sp='ruby script/plugin'
5+
alias sr='ruby script/runner'
56
alias ssp='ruby script/spec'
67
alias rdbm='rake db:migrate'
78
alias sc='ruby script/console'

plugins/rails3/rails3.plugin.zsh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ alias rdb='_rails_command dbconsole'
1414
alias rdbm='rake db:migrate db:test:clone'
1515
alias rg='_rails_command generate'
1616
alias rp='_rails_command plugin'
17+
alias ru='_rails_command runner'
1718
alias rs='_rails_command server'
1819
alias rsd='_rails_command server --debugger'
1920
alias devlog='tail -f log/development.log'

plugins/rake/rake.plugin.zsh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
alias rake="noglob rake" # allows square brackts for rake task invocation
2+
alias brake='noglob bundle exec rake' # execute the bundled rake gem
3+
alias srake='noglob sudo rake' # noglob must come before sudo
4+
alias sbrake='noglob sudo bundle exec rake' # altogether now ...
5+
6+

plugins/rvm/rvm.plugin.zsh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ function gems {
3737
local current_gemset=`rvm-prompt g`
3838

3939
gem list $@ | sed \
40-
-Ee "s/\([0-9\.]+( .+)?\)/$fg[blue]&$reset_color/g" \
40+
-Ee "s/\([0-9, \.]+( .+)?\)/$fg[blue]&$reset_color/g" \
4141
-Ee "s|$(echo $rvm_path)|$fg[magenta]\$rvm_path$reset_color|g" \
4242
-Ee "s/$current_ruby@global/$fg[yellow]&$reset_color/g" \
4343
-Ee "s/$current_ruby$current_gemset$/$fg[green]&$reset_color/g"

0 commit comments

Comments
 (0)