Skip to content

Commit b332c6e

Browse files
committed
Merge branch 'master' of git://github.com/robbyrussell/oh-my-zsh
Conflicts: lib/termsupport.zsh
2 parents dce4148 + b8b241f commit b332c6e

File tree

134 files changed

+6731
-375
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

134 files changed

+6731
-375
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ projects.zsh
44
custom/*
55
!custom/example
66
!custom/example.zsh
7-
cache
87
*.swp
8+
!custom/example.zshcache
9+
cache/

MIT-LICENSE.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License
2+
3+
Copyright (c) 2009-2013 Robby Russell and contributors (see https://github.com/robbyrussell/oh-my-zsh/contributors)
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

README.textile

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
A handful of functions, auto-complete helpers, and stuff that makes you shout...
22

3+
34
bq. "OH MY ZSHELL!"
45

56
h2. Setup
@@ -25,17 +26,20 @@ h3. The manual way
2526

2627
@git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh@
2728

28-
2. Create a new zsh config by copying the zsh template we've provided.
29+
2. *OPTIONAL* Backup your existing ~/.zshrc file
30+
31+
@cp ~/.zshrc ~/.zshrc.orig@
2932

30-
*NOTE*: If you already have a ~/.zshrc file, you should back it up. @cp ~/.zshrc ~/.zshrc.orig@ in case you want to go back to your original settings.
33+
3. Create a new zsh config by copying the zsh template we've provided.
3134

3235
@cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc@
3336

34-
3. Set zsh as your default shell:
37+
38+
4. Set zsh as your default shell:
3539

3640
@chsh -s /bin/zsh@
3741

38-
4. Start / restart zsh (open a new terminal is easy enough...)
42+
5. Start / restart zsh (open a new terminal is easy enough...)
3943

4044
h3. Problems?
4145

@@ -68,9 +72,13 @@ h2. Help out!
6872

6973
I'm far from being a zsh-expert and suspect there are many ways to improve. If you have ideas on how to make the configuration easier to maintain (and faster), don't hesitate to fork and send pull requests!
7074

71-
h3. Send us your theme!
75+
h3. (Don't) Send us your theme! (for now)
76+
77+
-I'm hoping to collect a bunch of themes for our command prompts. You can see existing ones in the @themes/@ directory.-
78+
79+
We have enough themes for the time being. Please fork the project and add on in there, you can let people know how to grab it from there.
80+
7281

73-
I'm hoping to collect a bunch of themes for our command prompts. You can see existing ones in the @themes/@ directory.
7482

7583
h2. Contributors
7684

lib/aliases.zsh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ alias -- -='cd -'
88

99
# Super user
1010
alias _='sudo'
11+
alias please='sudo'
1112

1213
#alias g='grep -in'
1314

@@ -16,8 +17,9 @@ alias history='fc -l 1'
1617

1718
# List direcory contents
1819
alias lsa='ls -lah'
19-
alias l='ls -la'
20+
alias l='ls -lA1'
2021
alias ll='ls -l'
22+
alias la='ls -lA'
2123
alias sl=ls # often screw this up
2224

2325
alias afind='ack-grep -il'

lib/completion.zsh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ zstyle ':completion:*:cd:*' tag-order local-directories directory-stack path-dir
3232
cdpath=(.)
3333

3434
# use /etc/hosts and known_hosts for hostname completion
35-
[ -r /etc/ssh/ssh_known_hosts ] && _global_ssh_hosts=(${${${${(f)"$(</etc/ssh/ssh_known_hosts)"}:#[\|]*}%%\ *}%%,*}) || _ssh_hosts=()
35+
[ -r /etc/ssh/ssh_known_hosts ] && _global_ssh_hosts=(${${${${(f)"$(</etc/ssh/ssh_known_hosts)"}:#[\|]*}%%\ *}%%,*}) || _global_ssh_hosts=()
3636
[ -r ~/.ssh/known_hosts ] && _ssh_hosts=(${${${${(f)"$(<$HOME/.ssh/known_hosts)"}:#[\|]*}%%\ *}%%,*}) || _ssh_hosts=()
3737
[ -r /etc/hosts ] && : ${(A)_etc_hosts:=${(s: :)${(ps:\t:)${${(f)~~"$(</etc/hosts)"}%%\#*}##[:blank:]#[^[:blank:]]#}}} || _etc_hosts=()
3838
hosts=(
@@ -46,7 +46,7 @@ zstyle ':completion:*:hosts' hosts $hosts
4646

4747
# Use caching so that commands like apt and dpkg complete are useable
4848
zstyle ':completion::complete:*' use-cache 1
49-
zstyle ':completion::complete:*' cache-path ~/.oh-my-zsh/cache/
49+
zstyle ':completion::complete:*' cache-path $ZSH/cache/
5050

5151
# Don't complete uninteresting users
5252
zstyle ':completion:*:*:*:users' ignored-patterns \

lib/correction.zsh

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,2 @@
1-
setopt correct_all
2-
3-
alias man='nocorrect man'
4-
alias mv='nocorrect mv'
5-
alias mysql='nocorrect mysql'
6-
alias mkdir='nocorrect mkdir'
7-
alias gist='nocorrect gist'
8-
alias heroku='nocorrect heroku'
9-
alias ebuild='nocorrect ebuild'
10-
alias hpodder='nocorrect hpodder'
1+
# correct commands, but not any arguments (correct_all would do that)
2+
setopt correct

lib/directories.zsh

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,14 @@ cd () {
2626
elif [[ "x$*" == "x...." ]]; then
2727
cd ../../..
2828
elif [[ "x$*" == "x....." ]]; then
29-
cd ../../..
30-
elif [[ "x$*" == "x......" ]]; then
3129
cd ../../../..
30+
elif [[ "x$*" == "x......" ]]; then
31+
cd ../../../../..
3232
else
3333
builtin cd "$@"
3434
fi
3535
}
3636

3737
alias md='mkdir -p'
3838
alias rd=rmdir
39-
alias d='dirs -v'
40-
41-
# mkdir & cd to it
42-
function mcd() {
43-
mkdir -p "$1" && cd "$1";
44-
}
39+
alias d='dirs -v | head -10'

lib/functions.zsh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
function zsh_stats() {
2-
history | awk '{print $2}' | sort | uniq -c | sort -rn | head
2+
history | awk '{CMD[$2]++;count++;}END { for (a in CMD)print CMD[a] " " CMD[a]/count*100 "% " a;}' | grep -v "./" | column -c3 -s " " -t | sort -nr | nl | head -n20
33
}
44

55
function uninstall_oh_my_zsh() {

lib/git.zsh

Lines changed: 48 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,45 @@
11
# get the name of the branch we are on
22
function git_prompt_info() {
3-
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
3+
ref=$(git symbolic-ref HEAD 2> /dev/null) || \
4+
ref=$(git rev-parse --short HEAD 2> /dev/null) || return
45
echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_SUFFIX"
56
}
67

78

89
# Checks if working tree is dirty
910
parse_git_dirty() {
1011
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
15-
echo "$ZSH_THEME_GIT_PROMPT_DIRTY"
16-
else
17-
echo "$ZSH_THEME_GIT_PROMPT_CLEAN"
12+
if [[ "$(git config --get oh-my-zsh.hide-status)" != "1" ]]; then
13+
if [[ $POST_1_7_2_GIT -gt 0 ]]; then
14+
SUBMODULE_SYNTAX="--ignore-submodules=dirty"
15+
fi
16+
if [[ -n $(git status -s ${SUBMODULE_SYNTAX} 2> /dev/null) ]]; then
17+
echo "$ZSH_THEME_GIT_PROMPT_DIRTY"
18+
else
19+
echo "$ZSH_THEME_GIT_PROMPT_CLEAN"
20+
fi
1821
fi
1922
}
2023

24+
# get the difference between the local and remote branches
25+
git_remote_status() {
26+
remote=${$(git rev-parse --verify ${hook_com[branch]}@{upstream} --symbolic-full-name 2>/dev/null)/refs\/remotes\/}
27+
if [[ -n ${remote} ]] ; then
28+
ahead=$(git rev-list ${hook_com[branch]}@{upstream}..HEAD 2>/dev/null | wc -l)
29+
behind=$(git rev-list HEAD..${hook_com[branch]}@{upstream} 2>/dev/null | wc -l)
30+
31+
if [ $ahead -eq 0 ] && [ $behind -gt 0 ]
32+
then
33+
echo "$ZSH_THEME_GIT_PROMPT_BEHIND_REMOTE"
34+
elif [ $ahead -gt 0 ] && [ $behind -eq 0 ]
35+
then
36+
echo "$ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE"
37+
elif [ $ahead -gt 0 ] && [ $behind -gt 0 ]
38+
then
39+
echo "$ZSH_THEME_GIT_PROMPT_DIVERGED_REMOTE"
40+
fi
41+
fi
42+
}
2143

2244
# Checks if there are commits ahead from remote
2345
function git_prompt_ahead() {
@@ -38,9 +60,9 @@ function git_prompt_long_sha() {
3860

3961
# Get the status of the working tree
4062
git_prompt_status() {
41-
INDEX=$(git status --porcelain 2> /dev/null)
63+
INDEX=$(git status --porcelain -b 2> /dev/null)
4264
STATUS=""
43-
if $(echo "$INDEX" | grep '^?? ' &> /dev/null); then
65+
if $(echo "$INDEX" | grep '^\?\? ' &> /dev/null); then
4466
STATUS="$ZSH_THEME_GIT_PROMPT_UNTRACKED$STATUS"
4567
fi
4668
if $(echo "$INDEX" | grep '^A ' &> /dev/null); then
@@ -60,23 +82,37 @@ git_prompt_status() {
6082
fi
6183
if $(echo "$INDEX" | grep '^ D ' &> /dev/null); then
6284
STATUS="$ZSH_THEME_GIT_PROMPT_DELETED$STATUS"
85+
elif $(echo "$INDEX" | grep '^D ' &> /dev/null); then
86+
STATUS="$ZSH_THEME_GIT_PROMPT_DELETED$STATUS"
6387
elif $(echo "$INDEX" | grep '^AD ' &> /dev/null); then
6488
STATUS="$ZSH_THEME_GIT_PROMPT_DELETED$STATUS"
6589
fi
90+
if $(git rev-parse --verify refs/stash >/dev/null 2>&1); then
91+
STATUS="$ZSH_THEME_GIT_PROMPT_STASHED$STATUS"
92+
fi
6693
if $(echo "$INDEX" | grep '^UU ' &> /dev/null); then
6794
STATUS="$ZSH_THEME_GIT_PROMPT_UNMERGED$STATUS"
6895
fi
96+
if $(echo "$INDEX" | grep '^## .*ahead' &> /dev/null); then
97+
STATUS="$ZSH_THEME_GIT_PROMPT_AHEAD$STATUS"
98+
fi
99+
if $(echo "$INDEX" | grep '^## .*behind' &> /dev/null); then
100+
STATUS="$ZSH_THEME_GIT_PROMPT_BEHIND$STATUS"
101+
fi
102+
if $(echo "$INDEX" | grep '^## .*diverged' &> /dev/null); then
103+
STATUS="$ZSH_THEME_GIT_PROMPT_DIVERGED$STATUS"
104+
fi
69105
echo $STATUS
70106
}
71107

72108
#compare the provided version of git to the version installed and on path
73109
#prints 1 if input version <= installed version
74-
#prints -1 otherwise
110+
#prints -1 otherwise
75111
function git_compare_version() {
76112
local INPUT_GIT_VERSION=$1;
77113
local INSTALLED_GIT_VERSION
78114
INPUT_GIT_VERSION=(${(s/./)INPUT_GIT_VERSION});
79-
INSTALLED_GIT_VERSION=($(git --version));
115+
INSTALLED_GIT_VERSION=($(git --version 2>/dev/null));
80116
INSTALLED_GIT_VERSION=(${(s/./)INSTALLED_GIT_VERSION[3]});
81117

82118
for i in {1..3}; do

lib/history.zsh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
## Command history configuration
2-
HISTFILE=$HOME/.zsh_history
2+
if [ -z $HISTFILE ]; then
3+
HISTFILE=$HOME/.zsh_history
4+
fi
35
HISTSIZE=10000
46
SAVEHIST=10000
57

lib/key-bindings.zsh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
bindkey -e
44
bindkey '\ew' kill-region
55
bindkey -s '\el' "ls\n"
6-
bindkey -s '\e.' "..\n"
76
bindkey '^r' history-incremental-search-backward
87
bindkey "^[[5~" up-line-or-history
98
bindkey "^[[6~" down-line-or-history

lib/misc.zsh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,7 @@ bindkey "^[m" copy-prev-shell-word
99
setopt long_list_jobs
1010

1111
## pager
12-
export PAGER=less
12+
export PAGER="less"
13+
export LESS="-R"
14+
1315
export LC_CTYPE=$LANG

lib/rvm.zsh

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
# get the name of the branch we are on
1+
# get the name of the ruby version
22
function rvm_prompt_info() {
3-
ruby_version=$(~/.rvm/bin/rvm-prompt 2> /dev/null) || return
4-
echo "($ruby_version)"
3+
[ -f $HOME/.rvm/bin/rvm-prompt ] || return
4+
local rvm_prompt
5+
rvm_prompt=$($HOME/.rvm/bin/rvm-prompt ${ZSH_THEME_RVM_PROMPT_OPTIONS} 2>/dev/null)
6+
[[ "${rvm_prompt}x" == "x" ]] && return
7+
echo "${ZSH_THEME_RVM_PROMPT_PREFIX:=(}${rvm_prompt}${ZSH_THEME_RVM_PROMPT_SUFFIX:=)}"
58
}
6-
7-

lib/termsupport.zsh

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
#Fully support screen, iterm, and probably most modern xterm and rxvt
44
#Limited support for Apple Terminal (Terminal can't set window or tab separately)
55
function title {
6-
[ "$DISABLE_AUTO_TITLE" != "true" ] || return
7-
if [[ "$TERM" == screen* ]]; then
6+
if [[ "$DISABLE_AUTO_TITLE" == "true" ]] || [[ "$EMACS" == *term* ]]; then
7+
return
8+
fi
9+
if [[ "$TERM" == screen* ]]; then
810
print -Pn "\ek$2:q\e\\" #set screen hardstatus, usually truncated at 20 chars
911
elif [[ "$TERM" == xterm* ]] || [[ $TERM == rxvt* ]] || [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then
1012
print -Pn "\e]2;$2:q\a" #set window name
@@ -24,8 +26,8 @@ function omz_termsupport_precmd {
2426
function omz_termsupport_preexec {
2527
emulate -L zsh
2628
setopt extended_glob
27-
local CMD=${1[(wr)^(*=*|sudo|ssh|-*)]} #cmd name only, or if this is sudo or ssh, the next cmd
28-
title "$CMD" "%n@%m: %100>...>$2%<<"
29+
local CMD=${1[(wr)^(*=*|sudo|ssh|rake|-*)]} #cmd name only, or if this is sudo or ssh, the next cmd
30+
title "$CMD" "%n@%m: %100>...>${2:gs/%/%%}%<<"
2931
}
3032

3133
autoload -U add-zsh-hook

oh-my-zsh.sh

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ fpath=($ZSH/functions $ZSH/completions $fpath)
1111

1212
# Load all of the config files in ~/oh-my-zsh that end in .zsh
1313
# TIP: Add files you don't want in git to .gitignore
14-
for config_file ($ZSH/lib/*.zsh) source $config_file
14+
for config_file ($ZSH/lib/*.zsh); do
15+
source $config_file
16+
done
1517

1618
# Set ZSH_CUSTOM to the path where your custom config files
1719
# and plugins exists, or else we will use the default custom/
@@ -51,7 +53,10 @@ for plugin ($plugins); do
5153
done
5254

5355
# Load all of your custom configurations from custom/
54-
for config_file ($ZSH_CUSTOM/*.zsh) source $config_file
56+
for config_file ($ZSH_CUSTOM/*.zsh(N)); do
57+
source $config_file
58+
done
59+
unset config_file
5560

5661
# Load the theme
5762
if [ "$ZSH_THEME" = "random" ]
@@ -65,12 +70,11 @@ then
6570
else
6671
if [ ! "$ZSH_THEME" = "" ]
6772
then
68-
if [ -f "$ZSH/custom/$ZSH_THEME.zsh-theme" ]
73+
if [ -f "$ZSH_CUSTOM/$ZSH_THEME.zsh-theme" ]
6974
then
70-
source "$ZSH/custom/$ZSH_THEME.zsh-theme"
75+
source "$ZSH_CUSTOM/$ZSH_THEME.zsh-theme"
7176
else
7277
source "$ZSH/themes/$ZSH_THEME.zsh-theme"
7378
fi
7479
fi
7580
fi
76-

0 commit comments

Comments
 (0)