Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
balkian committed Jun 17, 2013
2 parents 9de171c + b88b5b2 commit e85128f
Show file tree
Hide file tree
Showing 111 changed files with 3,169 additions and 363 deletions.
18 changes: 13 additions & 5 deletions README.textile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
A handful of functions, auto-complete helpers, and stuff that makes you shout...

oh-my-zsh is an open source, community-driven framework for managing your ZSH configuration. It comes bundled with a ton of helpful functions, helpers, plugins, themes, and few things that make you shout...

bq. "OH MY ZSHELL!"

Expand Down Expand Up @@ -63,6 +62,17 @@ If you want to override any of the default behavior, just add a new file (ending
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/@.

h3. Updates

By default you will be prompted to check for updates. If you would like oh-my-zsh to automatically update itself without prompting you, set the following in your ~/.zshrc

@DISABLE_UPDATE_PROMPT=true@

To disable updates entirely, put this in your ~/.zshrc

@DISABLE_AUTO_UPDATE=true@

To upgrade directly from the command line, just run @upgrade_oh_my_zsh@

h3. Uninstalling

Expand All @@ -76,9 +86,7 @@ h3. (Don't) Send us your theme! (for now)

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

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.


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.

h2. Contributors

Expand Down
2 changes: 1 addition & 1 deletion lib/aliases.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ alias history='fc -l 1'

# List direcory contents
alias lsa='ls -lah'
alias l='ls -lA1'
#alias l='ls -la'
alias ll='ls -l'
alias la='ls -lA'
alias sl=ls # often screw this up
Expand Down
3 changes: 3 additions & 0 deletions lib/completion.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,18 @@ 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)"}:#[\|]*}%%\ *}%%,*}) || _global_ssh_hosts=()
[ -r ~/.ssh/known_hosts ] && _ssh_hosts=(${${${${(f)"$(<$HOME/.ssh/known_hosts)"}:#[\|]*}%%\ *}%%,*}) || _ssh_hosts=()
[ -r ~/.ssh/config ] && _ssh_config=($(cat ~/.ssh/config | sed -ne 's/Host[=\t ]//p')) || _ssh_config=()
[ -r /etc/hosts ] && : ${(A)_etc_hosts:=${(s: :)${(ps:\t:)${${(f)~~"$(</etc/hosts)"}%%\#*}##[:blank:]#[^[:blank:]]#}}} || _etc_hosts=()
hosts=(
"$_ssh_config[@]"
"$_global_ssh_hosts[@]"
"$_ssh_hosts[@]"
"$_etc_hosts[@]"
"$HOST"
localhost
)
zstyle ':completion:*:hosts' hosts $hosts
zstyle ':completion:*' users off

# Use caching so that commands like apt and dpkg complete are useable
zstyle ':completion::complete:*' use-cache 1
Expand Down
24 changes: 14 additions & 10 deletions lib/correction.zsh
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
setopt correct_all

alias man='nocorrect man'
alias mv='nocorrect mv'
alias mysql='nocorrect mysql'
alias mkdir='nocorrect mkdir'
alias gist='nocorrect gist'
alias heroku='nocorrect heroku'
alias ebuild='nocorrect ebuild'
alias hpodder='nocorrect hpodder'
if [[ "$DISABLE_CORRECTION" == "true" ]]; then
return
else
setopt correct_all
alias man='nocorrect man'
alias mv='nocorrect mv'
alias mysql='nocorrect mysql'
alias mkdir='nocorrect mkdir'
alias gist='nocorrect gist'
alias heroku='nocorrect heroku'
alias ebuild='nocorrect ebuild'
alias hpodder='nocorrect hpodder'
alias sudo='nocorrect sudo'
fi
20 changes: 12 additions & 8 deletions lib/directories.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
setopt auto_name_dirs
setopt auto_pushd
setopt pushd_ignore_dups
setopt pushdminus

alias ..='cd ..'
alias cd..='cd ..'
Expand All @@ -11,14 +12,14 @@ alias cd.....='cd ../../../..'
alias cd/='cd /'

alias 1='cd -'
alias 2='cd +2'
alias 3='cd +3'
alias 4='cd +4'
alias 5='cd +5'
alias 6='cd +6'
alias 7='cd +7'
alias 8='cd +8'
alias 9='cd +9'
alias 2='cd -2'
alias 3='cd -3'
alias 4='cd -4'
alias 5='cd -5'
alias 6='cd -6'
alias 7='cd -7'
alias 8='cd -8'
alias 9='cd -9'

cd () {
if [[ "x$*" == "x..." ]]; then
Expand All @@ -29,6 +30,9 @@ cd () {
cd ../../../..
elif [[ "x$*" == "x......" ]]; then
cd ../../../../..
elif [ -d ~/.autoenv ]; then
source ~/.autoenv/activate.sh
autoenv_cd "$@"
else
builtin cd "$@"
fi
Expand Down
15 changes: 12 additions & 3 deletions lib/git.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,24 @@ function git_prompt_info() {
# Checks if working tree is dirty
parse_git_dirty() {
local SUBMODULE_SYNTAX=''
local GIT_STATUS=''
local CLEAN_MESSAGE='nothing to commit (working directory clean)'
if [[ "$(git config --get oh-my-zsh.hide-status)" != "1" ]]; then
if [[ $POST_1_7_2_GIT -gt 0 ]]; then
SUBMODULE_SYNTAX="--ignore-submodules=dirty"
fi
if [[ -n $(git status -s ${SUBMODULE_SYNTAX} 2> /dev/null) ]]; then
if [[ "$DISABLE_UNTRACKED_FILES_DIRTY" == "true" ]]; then
GIT_STATUS=$(git status -s ${SUBMODULE_SYNTAX} -uno 2> /dev/null | tail -n1)
else
GIT_STATUS=$(git status -s ${SUBMODULE_SYNTAX} 2> /dev/null | tail -n1)
fi
if [[ -n $GIT_STATUS ]]; then
echo "$ZSH_THEME_GIT_PROMPT_DIRTY"
else
echo "$ZSH_THEME_GIT_PROMPT_CLEAN"
fi
else
echo "$ZSH_THEME_GIT_PROMPT_CLEAN"
fi
}

Expand Down Expand Up @@ -62,7 +71,7 @@ function git_prompt_long_sha() {
git_prompt_status() {
INDEX=$(git status --porcelain -b 2> /dev/null)
STATUS=""
if $(echo "$INDEX" | grep '^?? ' &> /dev/null); then
if $(echo "$INDEX" | grep -E '^\?\? ' &> /dev/null); then
STATUS="$ZSH_THEME_GIT_PROMPT_UNTRACKED$STATUS"
fi
if $(echo "$INDEX" | grep '^A ' &> /dev/null); then
Expand Down Expand Up @@ -112,7 +121,7 @@ function git_compare_version() {
local INPUT_GIT_VERSION=$1;
local INSTALLED_GIT_VERSION
INPUT_GIT_VERSION=(${(s/./)INPUT_GIT_VERSION});
INSTALLED_GIT_VERSION=($(git --version));
INSTALLED_GIT_VERSION=($(git --version 2>/dev/null));
INSTALLED_GIT_VERSION=(${(s/./)INSTALLED_GIT_VERSION[3]});

for i in {1..3}; do
Expand Down
4 changes: 3 additions & 1 deletion lib/history.zsh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## Command history configuration
HISTFILE=$HOME/.zsh_history
if [ -z $HISTFILE ]; then
HISTFILE=$HOME/.zsh_history
fi
HISTSIZE=10000
SAVEHIST=10000

Expand Down
2 changes: 2 additions & 0 deletions lib/rbenv.zsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# using the rbenv plugin will override this with a real implementation
function rbenv_prompt_info() {}
6 changes: 4 additions & 2 deletions lib/termsupport.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function title {
fi
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
elif [[ "$TERM" == xterm* ]] || [[ $TERM == rxvt* ]] || [[ $TERM == ansi ]] || [[ "$TERM_PROGRAM" == "iTerm.app" ]]; then
print -Pn "\e]2;$2:q\a" #set window name
print -Pn "\e]1;$1:q\a" #set icon (=tab) name (will override window name on broken terminal)
fi
Expand All @@ -27,7 +27,9 @@ function omz_termsupport_preexec {
emulate -L zsh
setopt extended_glob
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/%/%%}%<<"
local LINE="${2:gs/$/\\$}"
LINE="${LINE:gs/%/%%}"
title "$CMD" "%100>...>$LINE%<<"
}

autoload -U add-zsh-hook
Expand Down
8 changes: 7 additions & 1 deletion lib/theme-and-appearance.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ export LSCOLORS="Gxfxcxdxbxegedabagacad"
if [ "$DISABLE_LS_COLORS" != "true" ]
then
# Find the option for using colors in ls, depending on the version: Linux or BSD
ls --color -d . &>/dev/null 2>&1 && alias ls='ls --color=tty' || alias ls='ls -G'
if [[ "$(uname -s)" == "NetBSD" ]]; then
# On NetBSD, test if "gls" (GNU ls) is installed (this one supports colors);
# otherwise, leave ls as is, because NetBSD's ls doesn't support -G
gls --color -d . &>/dev/null 2>&1 && alias ls='gls --color=tty'
else
ls --color -d . &>/dev/null 2>&1 && alias ls='ls --color=tty' || alias ls='ls -G'
fi
fi

#setopt no_beep
Expand Down
5 changes: 4 additions & 1 deletion oh-my-zsh.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Check for updates on initial load...
if [ "$DISABLE_AUTO_UPDATE" != "true" ]
then
/usr/bin/env ZSH=$ZSH zsh $ZSH/tools/check_for_upgrade.sh
/usr/bin/env ZSH=$ZSH DISABLE_UPDATE_PROMPT=$DISABLE_UPDATE_PROMPT zsh $ZSH/tools/check_for_upgrade.sh
fi

# Initializes Oh My Zsh
Expand Down Expand Up @@ -73,6 +73,9 @@ else
if [ -f "$ZSH_CUSTOM/$ZSH_THEME.zsh-theme" ]
then
source "$ZSH_CUSTOM/$ZSH_THEME.zsh-theme"
elif [ -f "$ZSH_CUSTOM/themes/$ZSH_THEME.zsh-theme" ]
then
source "$ZSH_CUSTOM/themes/$ZSH_THEME.zsh-theme"
else
source "$ZSH/themes/$ZSH_THEME.zsh-theme"
fi
Expand Down
16 changes: 3 additions & 13 deletions plugins/ant/ant.plugin.zsh
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
stat -f%m . > /dev/null 2>&1
if [ "$?" = 0 ]; then
stat_cmd=(stat -f%m)
else
stat_cmd=(stat -L --format=%Y)
fi

_ant_does_target_list_need_generating () {
if [ ! -f .ant_targets ]; then return 0;
else
accurate=$($stat_cmd .ant_targets)
changed=$($stat_cmd build.xml)
return $(expr $accurate '>=' $changed)
fi
[ ! -f .ant_targets ] && return 0;
[ .ant_targets -nt build.xml ] && return 0;
return 1;
}

_ant () {
Expand Down
4 changes: 3 additions & 1 deletion plugins/archlinux/archlinux.plugin.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,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 yaupg='yaourt -Syua' # Synchronize with repositories before upgrading packages (AUR packages too) 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
Expand All @@ -18,6 +18,8 @@ if [[ -x `which yaourt` ]]; then
alias yareps='yaourt -Ss' # Search for package(s) in the repositories
alias yaloc='yaourt -Qi' # Display information about a given package in the local database
alias yalocs='yaourt -Qs' # Search for package(s) in the local database
alias yalst='yaourt -Qe' # List installed packages, even those installed from AUR (they're tagged as "local")
alias yaorph='yaourt -Qtd' # Remove orphans using yaourt
# Additional yaourt alias examples
if [[ -x `which abs` ]]; then
alias yaupd='yaourt -Sy && sudo abs' # Update and refresh the local package and ABS databases against repositories
Expand Down
18 changes: 18 additions & 0 deletions plugins/autoenv/autoenv.plugin.zsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# The use_env call below is a reusable command to activate/create a new Python
# virtualenv, requiring only a single declarative line of code in your .env files.
# It only performs an action if the requested virtualenv is not the current one.
use_env() {
typeset venv
venv="$1"
if [[ "${VIRTUAL_ENV:t}" != "$venv" ]]; then
if workon | grep -q "$venv"; then
workon "$venv"
else
echo -n "Create virtualenv $venv now? (Yn) "
read answer
if [[ "$answer" == "Y" ]]; then
mkvirtualenv "$venv"
fi
fi
fi
}
2 changes: 2 additions & 0 deletions plugins/autojump/autojump.plugin.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ 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 /etc/profile.d/autojump.sh ]; then # gentoo installation
. /etc/profile.d/autojump.sh
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
Expand Down
45 changes: 28 additions & 17 deletions plugins/battery/battery.plugin.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,16 @@

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

function battery_pct() {
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
}

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
battery_pct
else
echo "External Power"
fi
Expand All @@ -42,17 +46,27 @@ if [[ $(uname) == "Darwin" ]] ; then
fi
echo "%{$fg[$color]%}[$(battery_pct_remaining)%%]%{$reset_color%}"
else
echo ""
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)
function battery_pct_remaining() {
if [[ $(acpi 2&>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]] ; then
echo "$(acpi | cut -f2 -d ',' | tr -cd '[:digit:]')"
fi
}

function battery_time_remaining() {
if [[ $(acpi 2&>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]] ; then
echo $(acpi | cut -f3 -d ',')
fi
}

function battery_pct_prompt() {
b=$(battery_pct_remaining)
if [[ $(acpi 2&>/dev/null | grep -c '^Battery.*Discharging') -gt 0 ]] ; then
if [ $b -gt 50 ] ; then
color='green'
elif [ $b -gt 20 ] ; then
Expand All @@ -61,11 +75,8 @@ elif [[ $(uname) == "Linux" ]] ; then
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
else
echo ""
fi
}
fi

0 comments on commit e85128f

Please sign in to comment.