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
mogensen committed Dec 4, 2012
2 parents 70aaa0d + b204ce8 commit 7efd825
Show file tree
Hide file tree
Showing 75 changed files with 4,712 additions and 353 deletions.
11 changes: 7 additions & 4 deletions README.textile
Expand Up @@ -26,17 +26,20 @@ h3. The manual way

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

2. Create a new zsh config by copying the zsh template we've provided.
2. *OPTIONAL* Backup your existing ~/.zshrc file

*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.
@cp ~/.zshrc ~/.zshrc.orig@

3. Create a new zsh config by copying the zsh template we've provided.

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

3. Set zsh as your default shell:

4. Set zsh as your default shell:

@chsh -s /bin/zsh@

4. Start / restart zsh (open a new terminal is easy enough...)
5. Start / restart zsh (open a new terminal is easy enough...)

h3. Problems?

Expand Down
4 changes: 3 additions & 1 deletion lib/aliases.zsh
Expand Up @@ -8,6 +8,7 @@ alias -- -='cd -'

# Super user
alias _='sudo'
alias please='sudo'

#alias g='grep -in'

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

# List direcory contents
alias lsa='ls -lah'
alias l='ls -la'
alias l='ls -lA1'
alias ll='ls -l'
alias la='ls -lA'
alias sl=ls # often screw this up

alias afind='ack-grep -il'
Expand Down
2 changes: 1 addition & 1 deletion lib/completion.zsh
Expand Up @@ -32,7 +32,7 @@ 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 /etc/ssh/ssh_known_hosts ] && _global_ssh_hosts=(${${${${(f)"$(</etc/ssh/ssh_known_hosts)"}:#[\|]*}%%\ *}%%,*}) || _global_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=(
Expand Down
5 changes: 0 additions & 5 deletions lib/directories.zsh
Expand Up @@ -37,8 +37,3 @@ cd () {
alias md='mkdir -p'
alias rd=rmdir
alias d='dirs -v | head -10'

# mkdir & cd to it
function mcd() {
mkdir -p "$1" && cd "$1";
}
2 changes: 1 addition & 1 deletion lib/functions.zsh
@@ -1,5 +1,5 @@
function zsh_stats() {
history | awk '{print $2}' | sort | uniq -c | sort -rn | head
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
}

function uninstall_oh_my_zsh() {
Expand Down
22 changes: 21 additions & 1 deletion lib/git.zsh
@@ -1,6 +1,7 @@
# get the name of the branch we are on
function git_prompt_info() {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
ref=$(git symbolic-ref HEAD 2> /dev/null) || \
ref=$(git rev-parse --short HEAD 2> /dev/null) || return
echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_SUFFIX"
}

Expand All @@ -18,6 +19,25 @@ parse_git_dirty() {
fi
}

# get the difference between the local and remote branches
git_remote_status() {
remote=${$(git rev-parse --verify ${hook_com[branch]}@{upstream} --symbolic-full-name 2>/dev/null)/refs\/remotes\/}
if [[ -n ${remote} ]] ; then
ahead=$(git rev-list ${hook_com[branch]}@{upstream}..HEAD 2>/dev/null | wc -l)
behind=$(git rev-list HEAD..${hook_com[branch]}@{upstream} 2>/dev/null | wc -l)

if [ $ahead -eq 0 ] && [ $behind -gt 0 ]
then
echo "$ZSH_THEME_GIT_PROMPT_BEHIND_REMOTE"
elif [ $ahead -gt 0 ] && [ $behind -eq 0 ]
then
echo "$ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE"
elif [ $ahead -gt 0 ] && [ $behind -gt 0 ]
then
echo "$ZSH_THEME_GIT_PROMPT_DIVERGED_REMOTE"
fi
fi
}

# Checks if there are commits ahead from remote
function git_prompt_ahead() {
Expand Down
4 changes: 3 additions & 1 deletion lib/misc.zsh
Expand Up @@ -9,5 +9,7 @@ bindkey "^[m" copy-prev-shell-word
setopt long_list_jobs

## pager
export PAGER="less -R"
export PAGER="less"
export LESS="-R"

export LC_CTYPE=$LANG
9 changes: 6 additions & 3 deletions lib/rvm.zsh
@@ -1,5 +1,8 @@
# get the name of the branch we are on
# get the name of the ruby version
function rvm_prompt_info() {
ruby_version=$(~/.rvm/bin/rvm-prompt 2> /dev/null) || return
[[ ! -z $ruby_version ]] && echo "($ruby_version)"
[ -f $HOME/.rvm/bin/rvm-prompt ] || return
local rvm_prompt
rvm_prompt=$($HOME/.rvm/bin/rvm-prompt ${ZSH_THEME_RVM_PROMPT_OPTIONS} 2>/dev/null)
[[ "${rvm_prompt}x" == "x" ]] && return
echo "${ZSH_THEME_RVM_PROMPT_PREFIX:=(}${rvm_prompt}${ZSH_THEME_RVM_PROMPT_SUFFIX:=)}"
}
4 changes: 2 additions & 2 deletions lib/termsupport.zsh
Expand Up @@ -26,8 +26,8 @@ function omz_termsupport_precmd {
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%<<"
local CMD=${1[(wr)^(*=*|sudo|ssh|rake|-*)]} #cmd name only, or if this is sudo or ssh, the next cmd
title "$CMD" "%100>...>${2:gs/%/%%}%<<"
}

autoload -U add-zsh-hook
Expand Down
8 changes: 6 additions & 2 deletions oh-my-zsh.sh
Expand Up @@ -11,7 +11,9 @@ fpath=($ZSH/functions $ZSH/completions $fpath)

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

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

# Load all of your custom configurations from custom/
for config_file ($ZSH_CUSTOM/*.zsh(N)) source $config_file
for config_file ($ZSH_CUSTOM/*.zsh(N)); do
source $config_file
done

# Load the theme
if [ "$ZSH_THEME" = "random" ]
Expand Down
20 changes: 18 additions & 2 deletions plugins/archlinux/archlinux.plugin.zsh
Expand Up @@ -11,7 +11,7 @@ if [[ -x `which yaourt` ]]; then
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 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
alias yarem='yaourt -Rns' # Remove the specified package(s), its configuration(s) and unneeded dependencies
alias yarep='yaourt -Si' # Display information about a given package in the repositories
Expand All @@ -35,7 +35,7 @@ fi
# Pacman - https://wiki.archlinux.org/index.php/Pacman_Tips
alias pacupg='sudo pacman -Syu' # Synchronize with repositories before upgrading packages that are out of date on the local system.
alias pacin='sudo pacman -S' # Install specific package(s) from the repositories
alias pacins='sudo pacman -U' # Install specific package not from the repositories but from a file
alias pacins='sudo pacman -U' # Install specific package not from the repositories but from a file
alias pacre='sudo pacman -R' # Remove the specified package(s), retaining its configuration(s) and required dependencies
alias pacrem='sudo pacman -Rns' # Remove the specified package(s), its configuration(s) and unneeded dependencies
alias pacrep='pacman -Si' # Display information about a given package in the repositories
Expand Down Expand Up @@ -75,3 +75,19 @@ pacdisowned() {

comm -23 "$fs" "$db"
}

pacmanallkeys() {
# Get all keys for developers and trusted users
curl https://www.archlinux.org/{developers,trustedusers}/ |
awk -F\" '(/pgp.mit.edu/) {sub(/.*search=0x/,"");print $1}' |
xargs sudo pacman-key --recv-keys
}

pacmansignkeys() {
for key in $*; do
sudo pacman-key --recv-keys $key
sudo pacman-key --lsign-key $key
printf 'trust\n3\n' | sudo gpg --homedir /etc/pacman.d/gnupg \
--no-permission-warning --command-fd 0 --edit-key $key
done
}
6 changes: 4 additions & 2 deletions plugins/autojump/autojump.plugin.zsh
Expand Up @@ -3,9 +3,11 @@ if [ $commands[autojump] ]; then # check if autojump is installed
. /usr/share/autojump/autojump.zsh
elif [ -f /etc/profile.d/autojump.zsh ]; then # manual installation
. /etc/profile.d/autojump.zsh
elif [ -f $HOME/.autojump/etc/profile.d/autojump.zsh ]; then # manual user-local installation
. $HOME/.autojump/etc/profile.d/autojump.zsh
elif [ -f /opt/local/etc/profile.d/autojump.zsh ]; then # mac os x with ports
. /opt/local/etc/profile.d/autojump.zsh
elif [ $commands[brew] -a -f `brew --prefix`/etc/autojump ]; then # mac os x with brew
. `brew --prefix`/etc/autojump
elif [ $commands[brew] -a -f `brew --prefix`/etc/autojump.zsh ]; then # mac os x with brew
. `brew --prefix`/etc/autojump.zsh
fi
fi
83 changes: 67 additions & 16 deletions plugins/battery/battery.plugin.zsh
@@ -1,20 +1,71 @@
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'
###########################################
# Battery plugin for oh-my-zsh #
# Original Author: Peter hoeg (peterhoeg) #
# Email: peter@speartail.com #
###########################################
# Author: Sean Jones (neuralsandwich) #
# Email: neuralsandwich@gmail.com #
# Modified to add support for Apple Mac #
###########################################

if [[ $(uname) == "Darwin" ]] ; then

function battery_pct_remaining() {
if [[ $(ioreg -rc AppleSmartBattery | grep -c '^.*"ExternalConnected"\ =\ No') -eq 1 ]] ; then
typeset -F maxcapacity=$(ioreg -rc "AppleSmartBattery"| grep '^.*"MaxCapacity"\ =\ ' | sed -e 's/^.*"MaxCapacity"\ =\ //')
typeset -F currentcapacity=$(ioreg -rc "AppleSmartBattery"| grep '^.*"CurrentCapacity"\ =\ ' | sed -e 's/^.*CurrentCapacity"\ =\ //')
integer i=$(((currentcapacity/maxcapacity) * 100))
echo $i
else
color='red'
echo "External Power"
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 '' }

function battery_time_remaining() {
if [[ $(ioreg -rc AppleSmartBattery | grep -c '^.*"ExternalConnected"\ =\ No') -eq 1 ]] ; then
timeremaining=$(ioreg -rc "AppleSmartBattery"| grep '^.*"AvgTimeToEmpty"\ =\ ' | sed -e 's/^.*"AvgTimeToEmpty"\ =\ //')
echo "~$((timeremaining / 60)):$((timeremaining % 60))"
else
echo ""
fi
}

function battery_pct_prompt () {
if [[ $(ioreg -rc AppleSmartBattery | grep -c '^.*"ExternalConnected"\ =\ No') -eq 1 ]] ; then
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
echo ""
fi
}

elif [[ $(uname) == "Linux" ]] ; then

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
fi
41 changes: 0 additions & 41 deletions plugins/cap/cap.plugin.zsh

This file was deleted.

10 changes: 10 additions & 0 deletions plugins/capistrano/_capistrano
@@ -0,0 +1,10 @@
#compdef cap
#autoload

if [ -f config/deploy.rb ]; then
if [[ ! -f .cap_tasks~ || config/deploy.rb -nt .cap_tasks~ ]]; then
echo "\nGenerating .cap_tasks~..." > /dev/stderr
cap --tasks | grep '#' | cut -d " " -f 2 > .cap_tasks~
fi
compadd `cat .cap_tasks~`
fi

0 comments on commit 7efd825

Please sign in to comment.