Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Steve Jenson committed Feb 18, 2012
2 parents 0f4475b + 3629270 commit f63360b
Show file tree
Hide file tree
Showing 61 changed files with 832 additions and 233 deletions.
10 changes: 9 additions & 1 deletion README.textile
Expand Up @@ -8,6 +8,14 @@ h2. Setup

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

You can install this via the command line with either `curl` or `wget`.

h4. via `curl`

@curl -L https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh | sh@

h4. via `wget`

@wget --no-check-certificate https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | sh@

h3. The manual way
Expand Down Expand Up @@ -48,7 +56,7 @@ the "refcard":http://www.bash2zsh.com/zsh_refcard/refcard.pdf is pretty tasty fo
h3. Customization

If you want to override any of the default behavior, just add a new file (ending in @.zsh@) into the @custom/@ directory.
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.
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.
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/@.


Expand Down
4 changes: 3 additions & 1 deletion lib/completion.zsh
Expand Up @@ -32,12 +32,14 @@ zstyle ':completion:*:cd:*' tag-order local-directories directory-stack path-dir
cdpath=(.)

# use /etc/hosts and known_hosts for hostname completion
[ -r /etc/ssh/ssh_known_hosts ] && _global_ssh_hosts=(${${${${(f)"$(</etc/ssh/ssh_known_hosts)"}:#[\|]*}%%\ *}%%,*}) || _ssh_hosts=()
[ -r ~/.ssh/known_hosts ] && _ssh_hosts=(${${${${(f)"$(<$HOME/.ssh/known_hosts)"}:#[\|]*}%%\ *}%%,*}) || _ssh_hosts=()
[ -r /etc/hosts ] && : ${(A)_etc_hosts:=${(s: :)${(ps:\t:)${${(f)~~"$(</etc/hosts)"}%%\#*}##[:blank:]#[^[:blank:]]#}}} || _etc_hosts=()
hosts=(
"$_global_ssh_hosts[@]"
"$_ssh_hosts[@]"
"$_etc_hosts[@]"
`hostname`
"$HOST"
localhost
)
zstyle ':completion:*:hosts' hosts $hosts
Expand Down
4 changes: 2 additions & 2 deletions lib/functions.zsh
Expand Up @@ -3,11 +3,11 @@ function zsh_stats() {
}

function uninstall_oh_my_zsh() {
/bin/sh $ZSH/tools/uninstall.sh
/usr/bin/env ZSH=$ZSH /bin/sh $ZSH/tools/uninstall.sh
}

function upgrade_oh_my_zsh() {
/bin/sh $ZSH/tools/upgrade.sh
/usr/bin/env ZSH=$ZSH /bin/sh $ZSH/tools/upgrade.sh
}

function take() {
Expand Down
4 changes: 2 additions & 2 deletions lib/git.zsh
Expand Up @@ -6,7 +6,7 @@ function git_prompt_info() {

# Checks if working tree is dirty
parse_git_dirty() {
if [[ -n $(git status -s 2> /dev/null) ]]; then
if [[ -n $(git status -s --ignore-submodules=dirty 2> /dev/null) ]]; then
echo "$ZSH_THEME_GIT_PROMPT_DIRTY"
else
echo "$ZSH_THEME_GIT_PROMPT_CLEAN"
Expand Down Expand Up @@ -61,4 +61,4 @@ git_prompt_status() {
STATUS="$ZSH_THEME_GIT_PROMPT_UNMERGED$STATUS"
fi
echo $STATUS
}
}
13 changes: 5 additions & 8 deletions lib/history.zsh
Expand Up @@ -3,14 +3,11 @@ HISTFILE=$HOME/.zsh_history
HISTSIZE=10000
SAVEHIST=10000

setopt hist_ignore_dups # ignore duplication command history list
setopt share_history # share command history data

setopt hist_verify
setopt inc_append_history
setopt append_history
setopt extended_history
setopt hist_expire_dups_first
setopt hist_ignore_dups # ignore duplication command history list
setopt hist_ignore_space

setopt SHARE_HISTORY
setopt APPEND_HISTORY
setopt hist_verify
setopt inc_append_history
setopt share_history # share command history data
10 changes: 7 additions & 3 deletions lib/termsupport.zsh
Expand Up @@ -4,7 +4,7 @@
#Limited support for Apple Terminal (Terminal can't set window or tab separately)
function title {
[ "$DISABLE_AUTO_TITLE" != "true" ] || return
if [[ "$TERM" == screen* ]]; then
if [[ "$TERM" == screen* ]]; then
print -Pn "\ek$1:q\e\\" #set screen hardstatus, usually truncated at 20 chars
elif [[ "$TERM" == xterm* ]] || [[ $TERM == rxvt* ]] || [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then
print -Pn "\e]2;$2:q\a" #set window name
Expand All @@ -16,14 +16,18 @@ ZSH_THEME_TERM_TAB_TITLE_IDLE="%15<..<%~%<<" #15 char left truncated PWD
ZSH_THEME_TERM_TITLE_IDLE="%n@%m: %~"

#Appears when you have the prompt
function precmd {
function omz_termsupport_precmd {
title $ZSH_THEME_TERM_TAB_TITLE_IDLE $ZSH_THEME_TERM_TITLE_IDLE
}

#Appears at the beginning of (and during) of command execution
function preexec {
function omz_termsupport_preexec {
emulate -L zsh
setopt extended_glob
local CMD=${1[(wr)^(*=*|sudo|ssh|-*)]} #cmd name only, or if this is sudo or ssh, the next cmd
title "$CMD" "%100>...>$2%<<"
}

autoload -U add-zsh-hook
add-zsh-hook precmd omz_termsupport_precmd
add-zsh-hook preexec omz_termsupport_preexec
38 changes: 28 additions & 10 deletions oh-my-zsh.sh
Expand Up @@ -13,20 +13,33 @@ fpath=($ZSH/functions $ZSH/completions $fpath)
# TIP: Add files you don't want in git to .gitignore
for config_file ($ZSH/lib/*.zsh) source $config_file

# Add all defined plugins to fpath
plugin=${plugin:=()}
for plugin ($plugins) fpath=($ZSH/plugins/$plugin $fpath)
# Set ZSH_CUSTOM to the path where your custom config files
# and plugins exists, or else we will use the default custom/
if [[ -z "$ZSH_CUSTOM" ]]; then
ZSH_CUSTOM="$ZSH/custom"
fi


is_plugin() {
local base_dir=$1
local name=$2
test -f $base_dir/plugins/$name/$name.plugin.zsh \
|| test -f $base_dir/plugins/$name/_$name
}
# Add all defined plugins to fpath. This must be done
# before running compinit.
for plugin ($plugins); do
if is_plugin $ZSH_CUSTOM $plugin; then
fpath=($ZSH_CUSTOM/plugins/$plugin $fpath)
elif is_plugin $ZSH $plugin; then
fpath=($ZSH/plugins/$plugin $fpath)
fi
done

# Load and run compinit
autoload -U compinit
compinit -i

# Set ZSH_CUSTOM to the path where your custom config files
# and plugins exists, or else we will use the default custom/
if [ "$ZSH_CUSTOM" = "" ]
then
ZSH_CUSTOM="$ZSH/custom"
fi

# Load all of the plugins that were defined in ~/.zshrc
for plugin ($plugins); do
Expand All @@ -52,7 +65,12 @@ then
else
if [ ! "$ZSH_THEME" = "" ]
then
source "$ZSH/themes/$ZSH_THEME.zsh-theme"
if [ -f "$ZSH/custom/$ZSH_THEME.zsh-theme" ]
then
source "$ZSH/custom/$ZSH_THEME.zsh-theme"
else
source "$ZSH/themes/$ZSH_THEME.zsh-theme"
fi
fi
fi

1 change: 1 addition & 0 deletions plugins/archlinux/archlinux.plugin.zsh
Expand Up @@ -9,6 +9,7 @@ if [[ -x `which yaourt` ]]; then
alias yaconf='yaourt -C' # Fix all configuration files with vimdiff
# Pacman - https://wiki.archlinux.org/index.php/Pacman_Tips
alias yaupg='yaourt -Syu' # Synchronize with repositories before upgrading packages that are out of date on the local system.
alias yasu='yaourt --sucre' # Same as yaupg, but without confirmation
alias yain='yaourt -S' # Install specific package(s) from the repositories
alias yains='yaourt -U' # Install specific package not from the repositories but from a file
alias yare='yaourt -R' # Remove the specified package(s), retaining its configuration(s) and required dependencies
Expand Down
10 changes: 8 additions & 2 deletions plugins/autojump/autojump.plugin.zsh
@@ -1,3 +1,9 @@
if [ -f `brew --prefix`/etc/autojump ]; then
. `brew --prefix`/etc/autojump
if [ $commands[autojump] ]; then # check if autojump is installed
if [ -f /usr/share/autojump/autojump.zsh ]; then # debian and ubuntu package
. /usr/share/autojump/autojump.zsh
elif [ -f /etc/profile.d/autojump.zsh ]; then # manual installation
. /etc/profile.d/autojump.zsh
elif [ $commands[brew] -a -f `brew --prefix`/etc/autojump ]; then # mac os x with brew
. `brew --prefix`/etc/autojump
fi
fi
20 changes: 20 additions & 0 deletions plugins/battery/battery.plugin.zsh
@@ -0,0 +1,20 @@
if [[ $(acpi 2&>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]] ; then
function battery_pct_remaining() { echo "$(acpi | cut -f2 -d ',' | tr -cd '[:digit:]')" }
function battery_time_remaining() { echo $(acpi | cut -f3 -d ',') }
function battery_pct_prompt() {
b=$(battery_pct_remaining)
if [ $b -gt 50 ] ; then
color='green'
elif [ $b -gt 20 ] ; then
color='yellow'
else
color='red'
fi
echo "%{$fg[$color]%}[$(battery_pct_remaining)%%]%{$reset_color%}"
}
else
error_msg='no battery'
function battery_pct_remaining() { echo $error_msg }
function battery_time_remaining() { echo $error_msg }
function battery_pct_prompt() { echo '' }
fi
10 changes: 3 additions & 7 deletions plugins/bundler/bundler.plugin.zsh
@@ -1,7 +1,3 @@
fpath=($ZSH/plugins/bundler $fpath)
autoload -U compinit
compinit -i

alias be="bundle exec"
alias bi="bundle install"
alias bl="bundle list"
Expand All @@ -10,7 +6,7 @@ alias bu="bundle update"

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

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

## Functions

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

_within-bundled-project() {
local check_dir=$PWD
while [ "$(dirname $check_dir)" != "/" ]; do
while [ $check_dir != "/" ]; do
[ -f "$check_dir/Gemfile" ] && return
check_dir="$(dirname $check_dir)"
done
Expand All @@ -41,6 +37,6 @@ for cmd in $bundled_commands; do
alias $cmd=bundled_$cmd

if which _$cmd > /dev/null 2>&1; then
compdef _$cmd bundled_$cmd
compdef _$cmd bundled_$cmd=$cmd
fi
done
42 changes: 37 additions & 5 deletions plugins/debian/debian.plugin.zsh
Expand Up @@ -54,7 +54,7 @@ if [[ $use_sudo -eq 1 ]]; then

# apt-get only
alias ads="sudo $apt_pref dselect-upgrade"

# Install all .deb files in the current directory.
# Warning: you will need to put the glob in single quotes if you use:
# glob_subst
Expand Down Expand Up @@ -113,9 +113,6 @@ alias allpkgs='aptitude search -F "%p" --disable-columns ~i'
alias mydeb='time dpkg-buildpackage -rfakeroot -us -uc'





# Functions #################################################################
# create a simple script that can be used to 'duplicate' a system
apt-copy() {
Expand All @@ -132,11 +129,46 @@ apt-copy() {
chmod +x apt-copy.sh
}

# Prints apt history
# Usage:
# apt-history install
# apt-history upgrade
# apt-history remove
# apt-history rollback
# apt-history list
# Based On: http://linuxcommando.blogspot.com/2008/08/how-to-show-apt-log-history.html
apt-history () {
case "$1" in
install)
zgrep --no-filename 'install ' $(ls -rt /var/log/dpkg*)
;;
upgrade|remove)
zgrep --no-filename $1 $(ls -rt /var/log/dpkg*)
;;
rollback)
zgrep --no-filename upgrade $(ls -rt /var/log/dpkg*) | \
grep "$2" -A10000000 | \
grep "$3" -B10000000 | \
awk '{print $4"="$5}'
;;
list)
zcat $(ls -rt /var/log/dpkg*)
;;
*)
echo "Parameters:"
echo " install - Lists all packages that have been installed."
echo " upgrade - Lists all packages that have been upgraded."
echo " remove - Lists all packages that have been removed."
echo " rollback - Lists rollback information."
echo " list - Lists all contains of dpkg logs."
;;
esac
}

# Kernel-package building shortcut
kerndeb () {
# temporarily unset MAKEFLAGS ( '-j3' will fail )
MAKEFLAGS=$( print - $MAKEFLAGS | perl -pe 's/-j\s*[\d]+//g' )
MAKEFLAGS=$( print - $MAKEFLAGS | perl -pe 's/-j\s*[\d]+//g' )
print '$MAKEFLAGS set to '"'$MAKEFLAGS'"
appendage='-custom' # this shows up in $ (uname -r )
revision=$(date +"%Y%m%d") # this shows up in the .deb file name
Expand Down
1 change: 1 addition & 0 deletions plugins/django/django.plugin.zsh
Expand Up @@ -220,3 +220,4 @@ _managepy() {

compdef _managepy manage.py
compdef _managepy django
compdef _managepy django-manage
5 changes: 0 additions & 5 deletions plugins/extract/extract.plugin.zsh
Expand Up @@ -78,8 +78,3 @@ function extract() {

alias x=extract

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

7 changes: 5 additions & 2 deletions plugins/git/git.plugin.zsh
Expand Up @@ -9,14 +9,15 @@ alias gup='git fetch && git rebase'
compdef _git gup=git-fetch
alias gp='git push'
compdef _git gp=git-push
gdv() { git-diff -w "$@" | view - }
gdv() { git diff -w "$@" | view - }
compdef _git gdv=git-diff
alias gc='git commit -v'
compdef _git gc=git-commit
alias gca='git commit -v -a'
compdef _git gca=git-commit
alias gco='git checkout'
compdef _git gco=git-checkout
alias gcm='git checkout master'
alias gb='git branch'
compdef _git gb=git-branch
alias gba='git branch -a'
Expand All @@ -35,6 +36,8 @@ alias ga='git add'
compdef _git ga=git-add
alias gm='git merge'
compdef _git gm=git-merge
alias grh='git reset HEAD'
alias grhh='git reset HEAD --hard'

# Git and svn mix
alias git-svn-dcommit-push='git svn dcommit && git push github master:svntrunk'
Expand All @@ -57,4 +60,4 @@ compdef ggpull=git
alias ggpush='git push origin $(current_branch)'
compdef ggpush=git
alias ggpnp='git pull origin $(current_branch) && git push origin $(current_branch)'
compdef ggpnp=git
compdef ggpnp=git
12 changes: 11 additions & 1 deletion plugins/github/github.plugin.zsh
@@ -1,7 +1,17 @@
# Setup hub function for git, if it is available; http://github.com/defunkt/hub
if [ "$commands[(I)hub]" ] && [ "$commands[(I)ruby]" ]; then
# eval `hub alias -s zsh`
function git(){hub "$@"}
function git(){
if ! (( $+_has_working_hub )); then
hub --version &> /dev/null
_has_working_hub=$(($? == 0))
fi
if (( $_has_working_hub )) ; then
hub "$@"
else
command git "$@"
fi
}
fi

# Functions #################################################################
Expand Down

0 comments on commit f63360b

Please sign in to comment.