Skip to content

Commit fe1ed11

Browse files
committed
Merge branch 'master' of git://github.com/robbyrussell/oh-my-zsh
Conflicts: lib/termsupport.zsh
2 parents 56bef52 + a11c814 commit fe1ed11

37 files changed

+487
-88
lines changed

README.textile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@ h2. Setup
88

99
h3. The automatic installer... (do you trust me?)
1010

11+
You can install this via the command line with either `curl` or `wget`.
12+
13+
h4. via `curl`
14+
15+
@curl -L https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh | sh@
16+
17+
h4. via `wget`
18+
1119
@wget --no-check-certificate https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | sh@
1220

1321
h3. The manual way

lib/completion.zsh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,14 @@ 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=()
3536
[ -r ~/.ssh/known_hosts ] && _ssh_hosts=(${${${${(f)"$(<$HOME/.ssh/known_hosts)"}:#[\|]*}%%\ *}%%,*}) || _ssh_hosts=()
3637
[ -r /etc/hosts ] && : ${(A)_etc_hosts:=${(s: :)${(ps:\t:)${${(f)~~"$(</etc/hosts)"}%%\#*}##[:blank:]#[^[:blank:]]#}}} || _etc_hosts=()
3738
hosts=(
39+
"$_global_ssh_hosts[@]"
3840
"$_ssh_hosts[@]"
3941
"$_etc_hosts[@]"
40-
`hostname`
42+
"$HOST"
4143
localhost
4244
)
4345
zstyle ':completion:*:hosts' hosts $hosts

lib/functions.zsh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ function zsh_stats() {
33
}
44

55
function uninstall_oh_my_zsh() {
6-
/bin/sh $ZSH/tools/uninstall.sh
6+
/usr/bin/env ZSH=$ZSH /bin/sh $ZSH/tools/uninstall.sh
77
}
88

99
function upgrade_oh_my_zsh() {
10-
/bin/sh $ZSH/tools/upgrade.sh
10+
/usr/bin/env ZSH=$ZSH /bin/sh $ZSH/tools/upgrade.sh
1111
}
1212

1313
function take() {

lib/git.zsh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ function git_prompt_info() {
66

77
# Checks if working tree is dirty
88
parse_git_dirty() {
9-
if [[ -n $(git status -s 2> /dev/null) ]]; then
9+
if [[ -n $(git status -s --ignore-submodules=dirty 2> /dev/null) ]]; then
1010
echo "$ZSH_THEME_GIT_PROMPT_DIRTY"
1111
else
1212
echo "$ZSH_THEME_GIT_PROMPT_CLEAN"

lib/history.zsh

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,11 @@ HISTFILE=$HOME/.zsh_history
33
HISTSIZE=10000
44
SAVEHIST=10000
55

6-
setopt hist_ignore_dups # ignore duplication command history list
7-
setopt share_history # share command history data
8-
9-
setopt hist_verify
10-
setopt inc_append_history
6+
setopt append_history
117
setopt extended_history
128
setopt hist_expire_dups_first
9+
setopt hist_ignore_dups # ignore duplication command history list
1310
setopt hist_ignore_space
14-
15-
setopt SHARE_HISTORY
16-
setopt APPEND_HISTORY
11+
setopt hist_verify
12+
setopt inc_append_history
13+
setopt share_history # share command history data

lib/termsupport.zsh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,18 @@ ZSH_THEME_TERM_TAB_TITLE_IDLE="%15<..<%~%<<" #15 char left truncated PWD
1616
ZSH_THEME_TERM_TITLE_IDLE="%n@%m: %~"
1717

1818
#Appears when you have the prompt
19-
function precmd {
19+
function omz_termsupport_precmd {
2020
title $ZSH_THEME_TERM_TAB_TITLE_IDLE $ZSH_THEME_TERM_TITLE_IDLE
2121
}
2222

2323
#Appears at the beginning of (and during) of command execution
24-
function preexec {
24+
function omz_termsupport_preexec {
2525
emulate -L zsh
2626
setopt extended_glob
2727
local CMD=${1[(wr)^(*=*|sudo|ssh|-*)]} #cmd name only, or if this is sudo or ssh, the next cmd
2828
title "$CMD" "%n@%m: %100>...>$2%<<"
2929
}
30+
31+
autoload -U add-zsh-hook
32+
add-zsh-hook precmd omz_termsupport_precmd
33+
add-zsh-hook preexec omz_termsupport_preexec

oh-my-zsh.sh

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,27 @@ fpath=($ZSH/functions $ZSH/completions $fpath)
1313
# TIP: Add files you don't want in git to .gitignore
1414
for config_file ($ZSH/lib/*.zsh) source $config_file
1515

16-
# Add all defined plugins to fpath
16+
# Set ZSH_CUSTOM to the path where your custom config files
17+
# and plugins exists, or else we will use the default custom/
18+
if [[ -z "$ZSH_CUSTOM" ]]; then
19+
ZSH_CUSTOM="$ZSH/custom"
20+
fi
21+
22+
# Add all defined plugins to fpath. This must be done
23+
# before running compinit.
1724
plugin=${plugin:=()}
18-
for plugin ($plugins) fpath=($ZSH/plugins/$plugin $fpath)
25+
for plugin ($plugins); do
26+
if [ -f $ZSH_CUSTOM/plugins/$plugin/$plugin.plugin.zsh ]; then
27+
fpath=($ZSH_CUSTOM/plugins/$plugin $fpath)
28+
elif [ -f $ZSH/plugins/$plugin/$plugin.plugin.zsh ]; then
29+
fpath=($ZSH/plugins/$plugin $fpath)
30+
fi
31+
done
1932

2033
# Load and run compinit
2134
autoload -U compinit
2235
compinit -i
2336

24-
# Set ZSH_CUSTOM to the path where your custom config files
25-
# and plugins exists, or else we will use the default custom/
26-
if [ "$ZSH_CUSTOM" = "" ]
27-
then
28-
ZSH_CUSTOM="$ZSH/custom"
29-
fi
3037

3138
# Load all of the plugins that were defined in ~/.zshrc
3239
for plugin ($plugins); do
@@ -52,7 +59,12 @@ then
5259
else
5360
if [ ! "$ZSH_THEME" = "" ]
5461
then
55-
source "$ZSH/themes/$ZSH_THEME.zsh-theme"
62+
if [ -f "$ZSH/custom/$ZSH_THEME.zsh-theme" ]
63+
then
64+
source "$ZSH/custom/$ZSH_THEME.zsh-theme"
65+
else
66+
source "$ZSH/themes/$ZSH_THEME.zsh-theme"
67+
fi
5668
fi
5769
fi
5870

plugins/archlinux/archlinux.plugin.zsh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ if [[ -x `which yaourt` ]]; then
99
alias yaconf='yaourt -C' # Fix all configuration files with vimdiff
1010
# Pacman - https://wiki.archlinux.org/index.php/Pacman_Tips
1111
alias yaupg='yaourt -Syu' # Synchronize with repositories before upgrading packages that are out of date on the local system.
12+
alias yasu='yaourt --sucre' # Same as yaupg, but without confirmation
1213
alias yain='yaourt -S' # Install specific package(s) from the repositories
1314
alias yains='yaourt -U' # Install specific package not from the repositories but from a file
1415
alias yare='yaourt -R' # Remove the specified package(s), retaining its configuration(s) and required dependencies

plugins/autojump/autojump.plugin.zsh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
if [ -f `brew --prefix`/etc/autojump ]; then
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
24
. `brew --prefix`/etc/autojump
35
fi

plugins/battery/battery.plugin.zsh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
if [[ $(acpi 2&>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]] ; then
2+
function battery_pct_remaining() { echo "$(acpi | cut -f2 -d ',' | tr -cd '[:digit:]')" }
3+
function battery_time_remaining() { echo $(acpi | cut -f3 -d ',') }
4+
function battery_pct_prompt() {
5+
b=$(battery_pct_remaining)
6+
if [ $b -gt 50 ] ; then
7+
color='green'
8+
elif [ $b -gt 20 ] ; then
9+
color='yellow'
10+
else
11+
color='red'
12+
fi
13+
echo "%{$fg[$color]%}[$(battery_pct_remaining)%%]%{$reset_color%}"
14+
}
15+
else
16+
error_msg='no battery'
17+
function battery_pct_remaining() { echo $error_msg }
18+
function battery_time_remaining() { echo $error_msg }
19+
function battery_pct_prompt() { echo '' }
20+
fi

plugins/bundler/bundler.plugin.zsh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ alias bu="bundle update"
1010

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

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

1515
## Functions
1616

@@ -41,6 +41,6 @@ for cmd in $bundled_commands; do
4141
alias $cmd=bundled_$cmd
4242

4343
if which _$cmd > /dev/null 2>&1; then
44-
compdef _$cmd bundled_$cmd
44+
compdef _$cmd bundled_$cmd=$cmd
4545
fi
4646
done

plugins/debian/debian.plugin.zsh

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ if [[ $use_sudo -eq 1 ]]; then
5454

5555
# apt-get only
5656
alias ads="sudo $apt_pref dselect-upgrade"
57-
57+
5858
# Install all .deb files in the current directory.
5959
# Warning: you will need to put the glob in single quotes if you use:
6060
# glob_subst
@@ -113,9 +113,6 @@ alias allpkgs='aptitude search -F "%p" --disable-columns ~i'
113113
alias mydeb='time dpkg-buildpackage -rfakeroot -us -uc'
114114

115115

116-
117-
118-
119116
# Functions #################################################################
120117
# create a simple script that can be used to 'duplicate' a system
121118
apt-copy() {
@@ -132,11 +129,46 @@ apt-copy() {
132129
chmod +x apt-copy.sh
133130
}
134131

132+
# Prints apt history
133+
# Usage:
134+
# apt-history install
135+
# apt-history upgrade
136+
# apt-history remove
137+
# apt-history rollback
138+
# apt-history list
139+
# Based On: http://linuxcommando.blogspot.com/2008/08/how-to-show-apt-log-history.html
140+
apt-history () {
141+
case "$1" in
142+
install)
143+
zgrep --no-filename 'install ' $(ls -rt /var/log/dpkg*)
144+
;;
145+
upgrade|remove)
146+
zgrep --no-filename $1 $(ls -rt /var/log/dpkg*)
147+
;;
148+
rollback)
149+
zgrep --no-filename upgrade $(ls -rt /var/log/dpkg*) | \
150+
grep "$2" -A10000000 | \
151+
grep "$3" -B10000000 | \
152+
awk '{print $4"="$5}'
153+
;;
154+
list)
155+
zcat $(ls -rt /var/log/dpkg*)
156+
;;
157+
*)
158+
echo "Parameters:"
159+
echo " install - Lists all packages that have been installed."
160+
echo " upgrade - Lists all packages that have been upgraded."
161+
echo " remove - Lists all packages that have been removed."
162+
echo " rollback - Lists rollback information."
163+
echo " list - Lists all contains of dpkg logs."
164+
;;
165+
esac
166+
}
135167

136168
# Kernel-package building shortcut
137169
kerndeb () {
138170
# temporarily unset MAKEFLAGS ( '-j3' will fail )
139-
MAKEFLAGS=$( print - $MAKEFLAGS | perl -pe 's/-j\s*[\d]+//g' )
171+
MAKEFLAGS=$( print - $MAKEFLAGS | perl -pe 's/-j\s*[\d]+//g' )
140172
print '$MAKEFLAGS set to '"'$MAKEFLAGS'"
141173
appendage='-custom' # this shows up in $ (uname -r )
142174
revision=$(date +"%Y%m%d") # this shows up in the .deb file name

plugins/git/git.plugin.zsh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ alias gca='git commit -v -a'
1717
compdef _git gca=git-commit
1818
alias gco='git checkout'
1919
compdef _git gco=git-checkout
20+
alias gcm='git checkout master'
2021
alias gb='git branch'
2122
compdef _git gb=git-branch
2223
alias gba='git branch -a'
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#---oh-my-zsh plugin : task Autocomplete for Jake tool---
2+
# Jake : https://github.com/mde/jake
3+
# Warning : Jakefile should have the right case : Jakefile or jakefile
4+
# Tested on : MacOSX 10.7 (Lion), Ubuntu 11.10
5+
# Author : Alexandre Lacheze (@al3xstrat)
6+
# Inspiration : http://weblog.rubyonrails.org/2006/3/9/fast-rake-task-completion-for-zsh
7+
8+
function _jake () {
9+
if [ -f Jakefile ]||[ -f jakefile ]; then
10+
compadd `jake -T | cut -d " " -f 2 | sed -E "s/.\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g"`
11+
fi
12+
}
13+
14+
compdef _jake jake

plugins/knife/_knife

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ _knife() {
2626

2727
case $state in
2828
knifecmd)
29-
compadd -Q "$@" bootstrap client configure cookbook "cookbook site" "data bag" exec index node recipe role search ssh status windows $cloudproviders
29+
compadd -Q "$@" bootstrap client configure cookbook "cookbook site" "data bag" exec environment index node recipe role search ssh status windows $cloudproviders
3030
;;
3131
knifesubcmd)
3232
case $words[2] in
@@ -42,6 +42,9 @@ _knife() {
4242
cookbook)
4343
compadd -Q "$@" test list create download delete "metadata from" show "bulk delete" metadata upload
4444
;;
45+
environment)
46+
compadd -Q "$@" list create delete edit show "from file"
47+
;;
4548
node)
4649
compadd -Q "$@" "from file" create show edit delete list run_list "bulk delete"
4750
;;
@@ -138,27 +141,31 @@ _knife_options3() {
138141

139142
# The chef_x_remote functions use knife to get a list of objects of type x on the server
140143
_chef_roles_remote() {
141-
(knife role list | grep \" | awk '{print $1}' | awk -F"," '{print $1}' | awk -F"\"" '{print $2}')
144+
(knife role list --format json | grep \" | awk '{print $1}' | awk -F"," '{print $1}' | awk -F"\"" '{print $2}')
142145
}
143146

144147
_chef_clients_remote() {
145-
(knife client list | grep \" | awk '{print $1}' | awk -F"," '{print $1}' | awk -F"\"" '{print $2}')
148+
(knife client list --format json | grep \" | awk '{print $1}' | awk -F"," '{print $1}' | awk -F"\"" '{print $2}')
146149
}
147150

148151
_chef_nodes_remote() {
149-
(knife node list | grep \" | awk '{print $1}' | awk -F"," '{print $1}' | awk -F"\"" '{print $2}')
152+
(knife node list --format json | grep \" | awk '{print $1}' | awk -F"," '{print $1}' | awk -F"\"" '{print $2}')
150153
}
151154

152155
_chef_cookbooks_remote() {
153-
(knife cookbook list | grep \" | awk '{print $1}' | awk -F"," '{print $1}' | awk -F"\"" '{print $2}')
156+
(knife cookbook list --format json | grep \" | awk '{print $1}' | awk -F"," '{print $1}' | awk -F"\"" '{print $2}')
154157
}
155158

156159
_chef_sitecookbooks_remote() {
157-
(knife cookbook site list | grep \" | awk '{print $1}' | awk -F"," '{print $1}' | awk -F"\"" '{print $2}')
160+
(knife cookbook site list --format json | grep \" | awk '{print $1}' | awk -F"," '{print $1}' | awk -F"\"" '{print $2}')
158161
}
159162

160163
_chef_data_bags_remote() {
161-
(knife data bag list | grep \" | awk '{print $1}' | awk -F"," '{print $1}' | awk -F"\"" '{print $2}')
164+
(knife data bag list --format json | grep \" | awk '{print $1}' | awk -F"," '{print $1}' | awk -F"\"" '{print $2}')
165+
}
166+
167+
_chef_environments_remote() {
168+
(knife environment list | awk '{print $1}')
162169
}
163170

164171
# The chef_x_local functions use the knife config to find the paths of relevant objects x to be uploaded to the server

plugins/nyan/nyan.plugin.zsh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
if [[ -x `which nc` ]]; then
2+
alias nyan='nc -v miku.acm.uiuc.edu 23' # nyan cat
3+
fi
4+
5+

0 commit comments

Comments
 (0)