Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
balkian committed Mar 8, 2014
2 parents e85128f + 48579eb commit 5663d3a
Show file tree
Hide file tree
Showing 152 changed files with 5,848 additions and 950 deletions.
6 changes: 4 additions & 2 deletions README.textile
@@ -1,3 +1,5 @@
!https://s3.amazonaws.com/ohmyzsh/oh-my-zsh-logo.png!

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 All @@ -12,11 +14,11 @@ 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@
@curl -L https://raw.github.com/robbyrussell/oh-my-zsh/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@
@wget --no-check-certificate https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O - | sh@

h3. The manual way

Expand Down
25 changes: 20 additions & 5 deletions lib/aliases.zsh
Expand Up @@ -6,20 +6,35 @@ alias po='popd'
alias ...='cd ../..'
alias -- -='cd -'

# Prevent headaches
alias cp='cp -v'
alias rm='rm -v'
alias mv='mv -v'

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

#alias g='grep -in'

# Show history
alias history='fc -l 1'

if [ "$HIST_STAMPS" = "mm/dd/yyyy" ]
then
alias history='fc -fl 1'
elif [ "$HIST_STAMPS" = "dd.mm.yyyy" ]
then
alias history='fc -El 1'
elif [ "$HIST_STAMPS" = "yyyy-mm-dd" ]
then
alias history='fc -il 1'
else
alias history='fc -l 1'
fi
# List direcory contents
alias lsa='ls -lah'
#alias l='ls -la'
alias ll='ls -l'
alias la='ls -lA'
alias l='ls -lah'
alias ll='ls -lh'
alias la='ls -lAh'
alias sl=ls # often screw this up

alias afind='ack-grep -il'
Expand Down
10 changes: 10 additions & 0 deletions lib/bzr.zsh
@@ -0,0 +1,10 @@
## Bazaar integration
## Just works with the GIT integration just add $(bzr_prompt_info) to the PROMPT
function bzr_prompt_info() {
BZR_CB=`bzr nick 2> /dev/null | grep -v "ERROR" | cut -d ":" -f2 | awk -F / '{print "bzr::"$1}'`
if [ -n "$BZR_CB" ]; then
BZR_DIRTY=""
[[ -n `bzr status` ]] && BZR_DIRTY=" %{$fg[red]%} * %{$fg[green]%}"
echo "$ZSH_THEME_SCM_PROMPT_PREFIX$BZR_CB$BZR_DIRTY$ZSH_THEME_GIT_PROMPT_SUFFIX"
fi
}
23 changes: 11 additions & 12 deletions lib/correction.zsh
@@ -1,14 +1,13 @@
if [[ "$DISABLE_CORRECTION" == "true" ]]; then
return
else
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'

if [[ "$ENABLE_CORRECTION" == "true" ]]; then
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
3 changes: 0 additions & 3 deletions lib/edit-command-line.zsh

This file was deleted.

58 changes: 58 additions & 0 deletions lib/functions.zsh
Expand Up @@ -15,3 +15,61 @@ function take() {
cd $1
}

#
# Get the value of an alias.
#
# Arguments:
# 1. alias - The alias to get its value from
# STDOUT:
# The value of alias $1 (if it has one).
# Return value:
# 0 if the alias was found,
# 1 if it does not exist
#
function alias_value() {
alias "$1" | sed "s/^$1='\(.*\)'$/\1/"
test $(alias "$1")
}

#
# Try to get the value of an alias,
# otherwise return the input.
#
# Arguments:
# 1. alias - The alias to get its value from
# STDOUT:
# The value of alias $1, or $1 if there is no alias $1.
# Return value:
# Always 0
#
function try_alias_value() {
alias_value "$1" || echo "$1"
}

#
# Set variable "$1" to default value "$2" if "$1" is not yet defined.
#
# Arguments:
# 1. name - The variable to set
# 2. val - The default value
# Return value:
# 0 if the variable exists, 3 if it was set
#
function default() {
test `typeset +m "$1"` && return 0
typeset -g "$1"="$2" && return 3
}

#
# Set enviroment variable "$1" to default value "$2" if "$1" is not yet defined.
#
# Arguments:
# 1. name - The env variable to set
# 2. val - The default value
# Return value:
# 0 if the env variable exists, 3 if it was set
#
function env_default() {
env | grep -q "^$1=" && return 0
export "$1=$2" && return 3
}
32 changes: 17 additions & 15 deletions lib/git.zsh
@@ -1,8 +1,10 @@
# get the name of the branch we are on
function git_prompt_info() {
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"
if [[ "$(git config --get oh-my-zsh.hide-status)" != "1" ]]; then
ref=$(command git symbolic-ref HEAD 2> /dev/null) || \
ref=$(command 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"
fi
}


Expand All @@ -11,14 +13,14 @@ 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 [[ "$(command 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 [[ "$DISABLE_UNTRACKED_FILES_DIRTY" == "true" ]]; then
GIT_STATUS=$(git status -s ${SUBMODULE_SYNTAX} -uno 2> /dev/null | tail -n1)
GIT_STATUS=$(command git status -s ${SUBMODULE_SYNTAX} -uno 2> /dev/null | tail -n1)
else
GIT_STATUS=$(git status -s ${SUBMODULE_SYNTAX} 2> /dev/null | tail -n1)
GIT_STATUS=$(command git status -s ${SUBMODULE_SYNTAX} 2> /dev/null | tail -n1)
fi
if [[ -n $GIT_STATUS ]]; then
echo "$ZSH_THEME_GIT_PROMPT_DIRTY"
Expand All @@ -32,10 +34,10 @@ parse_git_dirty() {

# 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\/}
remote=${$(command 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)
ahead=$(command git rev-list ${hook_com[branch]}@{upstream}..HEAD 2>/dev/null | wc -l)
behind=$(command git rev-list HEAD..${hook_com[branch]}@{upstream} 2>/dev/null | wc -l)

if [ $ahead -eq 0 ] && [ $behind -gt 0 ]
then
Expand All @@ -52,24 +54,24 @@ git_remote_status() {

# Checks if there are commits ahead from remote
function git_prompt_ahead() {
if $(echo "$(git log origin/$(current_branch)..HEAD 2> /dev/null)" | grep '^commit' &> /dev/null); then
if $(echo "$(command git log origin/$(current_branch)..HEAD 2> /dev/null)" | grep '^commit' &> /dev/null); then
echo "$ZSH_THEME_GIT_PROMPT_AHEAD"
fi
}

# Formats prompt string for current git commit short SHA
function git_prompt_short_sha() {
SHA=$(git rev-parse --short HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER"
SHA=$(command git rev-parse --short HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER"
}

# Formats prompt string for current git commit long SHA
function git_prompt_long_sha() {
SHA=$(git rev-parse HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER"
SHA=$(command git rev-parse HEAD 2> /dev/null) && echo "$ZSH_THEME_GIT_PROMPT_SHA_BEFORE$SHA$ZSH_THEME_GIT_PROMPT_SHA_AFTER"
}

# Get the status of the working tree
git_prompt_status() {
INDEX=$(git status --porcelain -b 2> /dev/null)
INDEX=$(command git status --porcelain -b 2> /dev/null)
STATUS=""
if $(echo "$INDEX" | grep -E '^\?\? ' &> /dev/null); then
STATUS="$ZSH_THEME_GIT_PROMPT_UNTRACKED$STATUS"
Expand All @@ -96,7 +98,7 @@ git_prompt_status() {
elif $(echo "$INDEX" | grep '^AD ' &> /dev/null); then
STATUS="$ZSH_THEME_GIT_PROMPT_DELETED$STATUS"
fi
if $(git rev-parse --verify refs/stash >/dev/null 2>&1); then
if $(command git rev-parse --verify refs/stash >/dev/null 2>&1); then
STATUS="$ZSH_THEME_GIT_PROMPT_STASHED$STATUS"
fi
if $(echo "$INDEX" | grep '^UU ' &> /dev/null); then
Expand All @@ -121,7 +123,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 2>/dev/null));
INSTALLED_GIT_VERSION=($(command git --version 2>/dev/null));
INSTALLED_GIT_VERSION=(${(s/./)INSTALLED_GIT_VERSION[3]});

for i in {1..3}; do
Expand Down
5 changes: 5 additions & 0 deletions lib/key-bindings.zsh
Expand Up @@ -30,6 +30,11 @@ bindkey "^[[3~" delete-char
bindkey "^[3;5~" delete-char
bindkey "\e[3~" delete-char

# Edit the current command line in $EDITOR
autoload -U edit-command-line
zle -N edit-command-line
bindkey '\C-x\C-e' edit-command-line

# consider emacs keybindings:

#bindkey -e ## emacs key bindings
Expand Down
9 changes: 9 additions & 0 deletions lib/nvm.zsh
@@ -0,0 +1,9 @@
# get the node.js version
function nvm_prompt_info() {
[ -f $HOME/.nvm/nvm.sh ] || return
local nvm_prompt
nvm_prompt=$(node -v 2>/dev/null)
[[ "${nvm_prompt}x" == "x" ]] && return
nvm_prompt=${nvm_prompt:1}
echo "${ZSH_THEME_NVM_PROMPT_PREFIX}${nvm_prompt}${ZSH_THEME_NVM_PROMPT_SUFFIX}"
}
33 changes: 33 additions & 0 deletions lib/prompt_info_functions.zsh
@@ -0,0 +1,33 @@
# *_prompt_info functions for usage in your prompt
#
# Plugin creators, please add your *_prompt_info function to the list
# of dummy implementations to help theme creators not receiving errors
# without the need of implementing conditional clauses.
#
# See also lib/bzr.zsh, lib/git.zsh and lib/nvm.zsh for
# git_prompt_info, bzr_prompt_info and nvm_prompt_info

# Dummy implementations that return false to prevent command_not_found
# errors with themes, that implement these functions
# Real implementations will be used when the respective plugins are loaded
function chruby_prompt_info hg_prompt_info pyenv_prompt_info \
rbenv_prompt_info svn_prompt_info vi_mode_prompt_info \
virtualenv_prompt_info {
return 1
}

# oh-my-zsh supports an rvm prompt by default
# get the name of the rvm ruby version
function rvm_prompt_info() {
[ -f $HOME/.rvm/bin/rvm-prompt ] || return 1
local rvm_prompt
rvm_prompt=$($HOME/.rvm/bin/rvm-prompt ${=ZSH_THEME_RVM_PROMPT_OPTIONS} 2>/dev/null)
[[ "${rvm_prompt}x" == "x" ]] && return 1
echo "${ZSH_THEME_RVM_PROMPT_PREFIX:=(}${rvm_prompt}${ZSH_THEME_RVM_PROMPT_SUFFIX:=)}"
}

# use this to enable users to see their ruby version, no matter which
# version management system they use
function ruby_prompt_info() {
echo $(rvm_prompt_info || rbenv_prompt_info || chruby_prompt_info)
}
2 changes: 0 additions & 2 deletions lib/rbenv.zsh

This file was deleted.

8 changes: 0 additions & 8 deletions lib/rvm.zsh

This file was deleted.

7 changes: 7 additions & 0 deletions lib/spectrum.zsh
Expand Up @@ -26,3 +26,10 @@ function spectrum_ls() {
done
}

# Show all 256 colors where the background is set to specific color
function spectrum_bls() {
for code in {000..255}; do
((cc = code + 1))
print -P -- "$BG[$code]$code: Test %{$reset_color%}"
done
}
5 changes: 2 additions & 3 deletions lib/termsupport.zsh
Expand Up @@ -27,9 +27,8 @@ 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
local LINE="${2:gs/$/\\$}"
LINE="${LINE:gs/%/%%}"
title "$CMD" "%100>...>$LINE%<<"
local LINE="${2:gs/%/%%}"
title '$CMD' '%100>...>$LINE%<<'
}

autoload -U add-zsh-hook
Expand Down
4 changes: 4 additions & 0 deletions lib/theme-and-appearance.zsh
Expand Up @@ -11,6 +11,10 @@ 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'
elif [[ "$(uname -s)" == "OpenBSD" ]]; then
# On OpenBSD, test if "colorls" is installed (this one supports colors);
# otherwise, leave ls as is, because OpenBSD's ls doesn't support -G
colorls -G -d . &>/dev/null 2>&1 && alias ls='colorls -G'
else
ls --color -d . &>/dev/null 2>&1 && alias ls='ls --color=tty' || alias ls='ls -G'
fi
Expand Down

0 comments on commit 5663d3a

Please sign in to comment.