Merge branch 'mergetest'

This commit is contained in:
Locojay 2011-06-05 20:42:07 -04:00
commit 500ce1d5ca
22 changed files with 973 additions and 597 deletions

View file

@ -46,9 +46,17 @@ alias print-libpath='echo -e ${LD_LIBRARY_PATH//:/\\n}'
alias lsbom='lsbom -f -l -s -pf' alias lsbom='lsbom -f -l -s -pf'
#alias t="$HOME/.local/bin/t --task-dir ~/.tasks --list todo.txt --delete-if-empty" #alias t="$HOME/.local/bin/t --task-dir ~/.tasks --list todo.txt --delete-if-empty"
<<<<<<< HEAD
#alias v.='vim .' #alias v.='vim .'
#alias v='vim ~/.vimrc' #alias v='vim ~/.vimrc'
#alias VS='vim -S Session.vim' #alias VS='vim -S Session.vim'
=======
alias v.='vim .'
alias v='vim ~/.vimrc'
alias VS='vim -S Session.vim'
alias z='vim -o ~/.zshenv ~/.oh-my-zsh/custom/aliases.zsh ~/.zshrc'
>>>>>>> ashleydev/master
alias zs='source ~/.zshrc' alias zs='source ~/.zshrc'

View file

@ -1,3 +1,9 @@
# Check for updates on initial load...
if [ "$DISABLE_AUTO_UPDATE" != "true" ]
then
/usr/bin/env zsh $ZSH/tools/check_for_upgrade.sh
fi
# Initializes Oh My Zsh # Initializes Oh My Zsh
# Disable colors on dumb terminals # Disable colors on dumb terminals
@ -30,7 +36,6 @@ for plugin ($plugins); do
done done
# Load the theme # Load the theme
# Check for updates on initial load...
if [ "$ZSH_THEME" = "random" ] if [ "$ZSH_THEME" = "random" ]
then then
themes=($ZSH/themes/*zsh-theme) themes=($ZSH/themes/*zsh-theme)
@ -43,18 +48,3 @@ else
source "$ZSH/themes/$ZSH_THEME.zsh-theme" source "$ZSH/themes/$ZSH_THEME.zsh-theme"
fi fi
# Load all of your custom configurations from custom/
for config_file ($ZSH/custom/*.zsh) source $config_file
# Compile zcompdump, if modified, to increase startup speed.
if [ "$HOME/.zcompdump" -nt "$HOME/.zcompdump.zwc" -o ! -e "$HOME/.zcompdump.zwc" ]; then
zcompile "$HOME/.zcompdump"
fi
# Check for updates on initial load...
if [ "$DISABLE_AUTO_UPDATE" = "true" ]
then
return
else
/usr/bin/env zsh $ZSH/tools/check_for_upgrade.sh
fi

View file

@ -2,14 +2,14 @@ stat -f%m . > /dev/null 2>&1
if [ "$?" = 0 ]; then if [ "$?" = 0 ]; then
stat_cmd=(stat -f%m) stat_cmd=(stat -f%m)
else else
stat_cmd=(stat -L --format=%y) stat_cmd=(stat -L --format=%Y)
fi fi
_ant_does_target_list_need_generating () { _ant_does_target_list_need_generating () {
if [ ! -f .ant_targets ]; then return 0; if [ ! -f .ant_targets ]; then return 0;
else else
accurate=$($stat_cmd -f%m .ant_targets) accurate=$($stat_cmd .ant_targets)
changed=$($stat_cmd -f%m build.xml) changed=$($stat_cmd build.xml)
return $(expr $accurate '>=' $changed) return $(expr $accurate '>=' $changed)
fi fi
} }

View file

@ -1,13 +1 @@
# Move /usr/local/bin (path where brews are linked) to the front of the path
# This will allow us to override system binaries like ruby with our brews
# TODO: Do this in a more compatible way.
# What if someone doesn't have /usr/bin in their path?
export PATH=`echo $PATH | sed -e 's|/usr/local/bin||' -e 's|::|:|g'` # Remove /usr/local/bin
export PATH=`echo $PATH | sed -e 's|/usr/bin|/usr/local/bin:&|'` # Add it in front of /usr/bin
export PATH=`echo $PATH | sed -e 's|/usr/bin|/usr/local/sbin:&|'` # Add /usr/local/sbin
alias brews='brew list -1' alias brews='brew list -1'
function brew-link-completion {
ln -s "$(brew --prefix)/Library/Contributions/brew_zsh_completion.zsh" "$ZSH/plugins/brew/_brew.official"
}

View file

@ -0,0 +1,60 @@
# Aliases
alias g='git' ; compdef g=git
alias ga='git add' ; compdef _git ga=git-add
alias gaa='git add --all' ; compdef _git gaa=git-add
alias gs='git status' ; compdef _git gs=git-status
alias gst='git status' ; compdef _git gst=git-status
# for `gsts "<message>"`
alias gsts='git stash save' ; compdef _git gsts=git-stash
alias gstp='git stash pop' ; compdef _git gstp=git-stash
alias gstl='git stash list' ; compdef _git gstl=git-stash
alias gstll='git stash show -p --stat' ; compdef _git gstll=git-stash
alias gl='git pull' ; compdef _git gl=git-pull
alias gup='git fetch && git rebase' ; compdef _git gup=git-fetch
alias gf='git fetch' ; compdef _git gf=git-fetch
alias gp='git push' ; compdef _git gp=git-push
alias gd='git diff --no-ext-diff -b' ; compdef _git gd=git-diff
alias gdd='git diff --no-ext-diff' ; compdef _git gdd=git-diff
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 gb='git branch' ; compdef _git gb=git-branch
alias gba='git branch -a' ; compdef _git gba=git-branch
alias gcount='git shortlog -sn' ; compdef gcount=git
alias gcp='git cherry-pick' ; compdef _git gcp=git-cherry-pick
alias gm='git merge' ; compdef _git gm=git-merge
alias glg='git log --stat --max-count=5'; compdef _git glg=git-log
# Git history (pretty)
local pretty_format_oneline='--pretty=format:"%C(yellow)%h %C(green)%cd %C(cyan)%an %C(bold cyan)%d%C(reset) %s" --date=short'
local pretty_format_medium='--pretty=format:"%C(yellow)commit %H %C(bold cyan)%d%C(reset)
%C(cyan)Author: %an <%ae>%C(reset)
%C(green)Date: %cd%C(reset)
%+s
%+b"'
alias gh="git log --graph $pretty_format_oneline" ; compdef _git gh=git-log
alias ghh="git log --graph $pretty_format_medium" ; compdef _git gh=git-log
alias ghhh="git log --graph --stat $pretty_format_medium" ; compdef _git gh=git-log
alias ghhhh="git log --graph --stat -p --full-diff $pretty_format_medium"; compdef _git gh=git-log
# Git and svn mix
alias git-svn-dcommit-push='git svn dcommit && git push github master:svntrunk'
compdef _git git-svn-dcommit-push=git
#
# Will return the current branch name
# Usage example: git pull origin $(current_branch)
#
function current_branch() {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
echo ${ref#refs/heads/}
}
# these aliases take advantage of the previous function
alias ggpull='git pull origin $(current_branch)'
compdef _git ggpull=git
alias ggpush='git push origin $(current_branch)'
compdef _git ggpush=git
alias ggpnp='git pull origin $(current_branch) && git push origin $(current_branch)'
compdef _git ggpnp=git

View file

@ -1,11 +1,21 @@
# get the name of the branch we are on # Renders the name of the current branch.
function git_prompt_info() { function git_prompt_info() {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return local branch=$(git_current_branch)
echo "$ZSH_THEME_GIT_PROMPT_PREFIX${ref#refs/heads/}$(parse_git_dirty)$ZSH_THEME_GIT_PROMPT_SUFFIX" if [[ -n "$branch" ]]; then
echo "${ZSH_THEME_GIT_PROMPT_PREFIX}${branch}$(parse_git_dirty)${ZSH_THEME_GIT_PROMPT_SUFFIX}"
fi
} }
# Checks if working tree is dirty # Gets the current branch.
parse_git_dirty() { function git_current_branch() {
local ref=$(git symbolic-ref HEAD 2> /dev/null)
if [[ -n "$ref" ]]; then
echo "${ref#refs/heads/}"
fi
}
# Checks if the working tree is dirty.
function parse_git_dirty() {
if [[ -n $(git status -s 2> /dev/null) ]]; then if [[ -n $(git status -s 2> /dev/null) ]]; then
echo "$ZSH_THEME_GIT_PROMPT_DIRTY" echo "$ZSH_THEME_GIT_PROMPT_DIRTY"
else else
@ -13,25 +23,31 @@ parse_git_dirty() {
fi fi
} }
# Checks if there are commits ahead from remote # Checks if there are commits ahead from remote.
function git_prompt_ahead() { function git_prompt_ahead() {
if $(echo "$(git log origin/$(current_branch)..HEAD 2> /dev/null)" | grep '^commit' &> /dev/null); then if $(echo "$(git log origin/$(git_current_branch)..HEAD 2> /dev/null)" | grep '^commit' &> /dev/null); then
echo "$ZSH_THEME_GIT_PROMPT_AHEAD" echo "$ZSH_THEME_GIT_PROMPT_AHEAD"
fi fi
} }
# Formats prompt string for current git commit short SHA # Formats the prompt string for current git commit short SHA.
function git_prompt_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" local sha=$(git rev-parse --short HEAD 2> /dev/null)
if [[ -n "$sha" ]]; then
echo "${ZSH_THEME_GIT_PROMPT_SHA_BEFORE}${sha}${ZSH_THEME_GIT_PROMPT_SHA_AFTER}"
fi
} }
# Formats prompt string for current git commit long SHA # Formats the prompt string for current git commit long SHA.
function git_prompt_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" local sha=$(git rev-parse HEAD 2> /dev/null)
if [[ -n "$sha" ]]; then
echo "${ZSH_THEME_GIT_PROMPT_SHA_BEFORE}${sha}${ZSH_THEME_GIT_PROMPT_SHA_AFTER}"
fi
} }
# Get the status of the working tree # Gets the status of the working tree.
git_prompt_status() { function git_prompt_status() {
local indicators line untracked added modified renamed deleted local indicators line untracked added modified renamed deleted
while IFS=$'\n' read line; do while IFS=$'\n' read line; do
if [[ "$line" =~ '^\?\? ' ]]; then if [[ "$line" =~ '^\?\? ' ]]; then
@ -61,3 +77,4 @@ git_prompt_status() {
done < <(git status --porcelain 2> /dev/null) done < <(git status --porcelain 2> /dev/null)
echo $indicators echo $indicators
} }

View file

@ -0,0 +1,602 @@
# ------------------------------------------------------------------------------
# FILE: git-prompt.plugin.zsh
# DESCRIPTION: oh-my-zsh git information for your PROMPT.
# AUTHOR: Ashley Dev (the.ashley.dev+git-prompt@gmail.com)
# VERSION: 2.1
# SCREENSHOT:
# ------------------------------------------------------------------------------
# USAGE:
#
# Add 'git' to your list of oh-my-zsh plugins (in your .zshrc) otherwise this
# git prompt info will not show up in your prompt.
#
# This example shows some of the things you can do with this plugin. This is
# how the author uses it:
# ---------------------- SAMPLE THEME FILE ------------------------
#
# # this is a simple example PROMPT with only git
# # info from this plugin in it:
# PROMPT='$__GIT_PROMPT_INFO# '
#
# # Set GIT_PROMPT_SHORTCIRCUIT='off' to turn the
# # short-circuit logic off. The short-circuit
# # logic will turn off the showing of dirty
# # state in your git prompt if ctrl-c is pressed
# # while the prompt is updating the dirty state
# # info. Gathering dirty-state info can take a
# # long time on large repositories, so if you
# # find that your prompt is taking for ever to
# # return, and you press ctrl-c, the short-
# # circuit logic will turn off the showing of
# # dirty state for this repository (locally) and
# # let you know, that way you won't be slowed
# # down waiting for your prompt in large git
# # repositories.
# #GIT_PROMPT_SHORTCIRCUIT='off'
#
# GIT_PROMPT_SHOWUPSTREAM="verbose"
# #GIT_PROMPT_SHOWREBASEINFO='off'
# #GIT_PROMPT_SHOWBRANCH='off'
# #GIT_PROMPT_SHOWSTASHSTATE='off'
# #GIT_PROMPT_SHORTCIRCUIT='off'
# #GIT_PROMPT_SHOWDIRTYSTATE='off'
#
# # Some color settings for my prompt format
# # '_C' for color:
# if [[ "$DISABLE_COLOR" != "true" ]]; then
# local _Cerror_="%{$fg[yellow]%}" # bad (empty) .git/ directory
# local _Cb_new_repo_="%{$fg_bold[default]%}" # branch color of new repo
# local _Cb_clean_="%{$fg_no_bold[green]%}" # branch color when clean
# local _Cb_dirty_="%{$fg_no_bold[red]%}" # branch color when dirty
# local _Cr_="%{$bold_color$fg[yellow]%}" # rebase info
# local _Ci_="%{$bold_color$fg[red]%}" # index info
# local _Cu_clean_="" # untracked files state when clean
# local _Cu_dirty_="%{$fg_bold[red]%}" # untracked files state when dirty
# local _Cp_="%{${fg[cyan]}%}" # upstream info
# local _Cs_="" # stash state
# # 'R'eset formating
# local R="%{$terminfo[sgr0]%}"
# fi
#
# # GIT_PROMPT_INFO_FUNC must be set to the
# # function that defines your prompt info
# # in order to turn this plugin on.
# # $GIT_PROMPT_INFO_FUNC to be called when the
# # git prompt info variable needs to be updated.
# GIT_PROMPT_INFO_FUNC='update__GIT_PROMPT_INFO'
#
# # update__GIT_PROMPT_INFO creates the format and
# # content of the git prompt info and puts the
# # result in $__GIT_PROMPT_INFO. Which you can
# # use in your $PROMPT (see above). This is an
# # example of some of the ways you can set up
# # your prompt with this plugin.
# #
# # NOTE: This function must set a global variable
# # (with the your git prompt format) that you
# # include in your PROMPT string.
# # It cannot echo this info as in:
# # PROMPT="$(update__GIT_PROMPT_INFO)"
# # or the short-circuit logic will not work.
# #
# local __GIT_PROMPT_INFO=''
# update__GIT_PROMPT_INFO ()
# {
# local g="$(_git_promt__git_dir)"
# # short circuit if we're not in a git repo:
# if [ -z "$g" ]; then
# __GIT_PROMPT_INFO=''
# return
# fi
#
# _git_prompt__stash
# local s=$GIT_PROMPT_STASH_STATE_DIRTY
#
# _git_prompt__upstream
# local p=$GIT_PROMPT_UPSTREAM_STATE
#
# _git_prompt__branch
# local b=$GIT_PROMPT_BRANCH
#
# _git_prompt__rebase_info
# local r=$GIT_PROMPT_REBASE_INFO
#
# _git_prompt__dirty_state
# local w=$GIT_PROMPT_DIRTY_STATE_WORKTREE_DIRTY
# local i=$GIT_PROMPT_DIRTY_STATE_INDEX_DIRTY
# local u=$GIT_PROMPT_DIRTY_STATE_WORKTREE_UNTRACKED
# local f=$GIT_PROMPT_DIRTY_STATE_FRESH_REPO
#
# if [ -z "$b$i$w$u" ]; then
# if [ -n "$g" ]; then
# __GIT_PROMPT_INFO="$R$_Cerror_(Error: bad ./$g dir)$R"
# return
# fi
# fi
#
# if [ "$s" = 'yes' ]; then
# s="$_Cs_\$$R"
# else
# s=""
# fi
#
# if [ -n "$p" ]; then
# p="$_Cp_$p$R"
# fi
#
# if [ "$i" = "yes" ]; then
# i="$_Ci_+$R"
# else
# i=""
# fi
#
# if [ -n "$b" ]; then
# if [ "$f" = "yes" ]; then
# # this is a fresh repo, nothing here...
# b="$_Cb_new_repo_$b$R"
# elif [ "$w" = 'yes' ]; then
# b="$_Cb_dirty_$b$R"
# elif [ "$w" = 'no' ]; then
# b="$_Cb_clean_$b$R"
# fi
# fi
#
# if [ -n "$r" ]; then
# r="$_Cr_$r$R"
# fi
#
# local _prompt="$b$r$i$s$p"
# # add ( ) around _prompt:
# if [ "$u" = "yes" ]; then
# _prompt="$_Cu_dirty_($_prompt$_Cu_dirty_)"
# elif [ "$u" = "no" ]; then
# _prompt="$_Cu_clean_($_prompt$_Cu_clean_)"
# else
# fi
#
# __GIT_PROMPT_INFO="$R$_prompt$R"
# }
# -----------------------------------------------------------------
#
#
#------------------ git information utils ------------------
# For some of the following functions, I borrowed some from:
# https://github.com/git/git/blob/master/contrib/completion/git-completion.bash
#
# _git_promt__git_dir accepts 0 or 1 arguments (i.e., location)
# echos the location of .git repo.
# Useful for quickly figuring out if cwd is under a git repo.
_git_promt__git_dir ()
{
if [ -z "${1-}" ]; then
if [ -d .git ]; then
echo .git
else
git rev-parse --git-dir 2>/dev/null
fi
elif [ -d "$1/.git" ]; then
echo "$1/.git"
else
echo "$1"
fi
}
# sets GIT_PROMPT_UPSTREAM_STATE
#
# output format:
# A "<" indicates you are behind, ">" indicates you are ahead, "<>"
# indicates you have diverged, "=" indicates no divergence, and "" indicates
# there is no upstream or this feature is turned 'off' (see below).
#
# You can control behaviour by setting GIT_PROMPT_SHOWUPSTREAM to a
# space-separated list of values:
# off no output
# verbose show number of commits ahead/behind (+/-) upstream instead
# of using "<" and ">".
# legacy don't use the '--count' option available in recent
# versions of git-rev-list
# git always compare HEAD to @{upstream}
# svn always compare HEAD to your SVN upstream
# By default, _git_prompt__upstream will compare HEAD to your SVN upstream
# if it can find one, or @{upstream} otherwise. Once you have
# set GIT_PROMPT_SHOWUPSTREAM, you can override it on a
# per-repository basis by setting the prompt.showUpstream config
# variable (i.e. `git config prompt.showUpstream 'verbose legacy'`).
#
# _git_prompt__upstream accepts 0 or 1 arguments. If an argument is given, it
# must be a string of the form specified above for GIT_PROMPT_SHOWUPSTREAM.
# Setting this argument will override any value set for GIT_PROMPT_SHOWUPSTREAM
# or in the .git/config.
_git_prompt__upstream ()
{
GIT_PROMPT_UPSTREAM_STATE=''
if [ "true" != "$(git rev-parse --is-inside-work-tree 2>/dev/null)" ]; then
return
fi
local key value
local svn_remote svn_url_pattern count n
local upstream=git legacy="" verbose=""
local p
# get some config options from git-config
while read key value; do
case "$key" in
prompt.showupstream*)
GIT_PROMPT_SHOWUPSTREAM="$value"
;;
svn-remote.*.url)
svn_remote=( "${svn_remote[@]}" $value )
svn_url_pattern="$svn_url_pattern\\|$value"
upstream=svn+git # default upstream is SVN if available, else git
;;
esac
done < <(git config --get-regexp '^(svn-remote\..*\.url|prompt\.showupstream)' 2>/dev/null)
if [ -n "${1-}" ]; then
GIT_PROMPT_SHOWUPSTREAM=$1
fi
# parse configuration values
for option in ${GIT_PROMPT_SHOWUPSTREAM}; do
case "$option" in
off) return ;;
git|svn) upstream="$option" ;;
verbose) verbose=1 ;;
legacy) legacy=1 ;;
esac
done
# Find our upstream
case "$upstream" in
git) upstream="@{upstream}" ;;
svn*)
# get the upstream from the "git-svn-id: ..." in a commit message
# (git-svn uses essentially the same procedure internally)
local svn_upstream=$(git log --first-parent -1 --grep="^git-svn-id: \(${svn_url_pattern#??}\)" 2>/dev/null | awk '/commit / { print $2 }')
if [[ 0 -ne ${#svn_upstream[@]} ]]; then
if [[ -z "$svn_upstream" ]]; then
# default branch name for checkouts with no layout:
upstream='git-svn'
else
upstream=${svn_upstream#/}
fi
elif [[ "svn+git" = "$upstream" ]]; then
upstream="@{upstream}"
fi
;;
esac
# Find how many commits we are ahead/behind our upstream
# produce equivalent output to --count for older versions of git
local ahead behind
if git rev-list --left-right "$upstream"...HEAD >/dev/null 2>&1; then
behind="$(git rev-list --left-right "$upstream"...HEAD 2>/dev/null | grep '^<' | wc -l | tr -d ' ' 2>/dev/null)"
ahead="$(git rev-list --left-right "$upstream"...HEAD 2>/dev/null | grep '^[^<]' | wc -l | tr -d ' ' 2>/dev/null)"
count="$behind $ahead"
fi
# calculate the result
if [[ -z "$verbose" ]]; then
case "$count" in
"") # no upstream
p="" ;;
"0 0") # equal to upstream
p="=" ;;
"0 "*) # ahead of upstream
p=">" ;;
*" 0") # behind upstream
p="<" ;;
*) # diverged from upstream
p="<>" ;;
esac
else
case "$count" in
"") # no upstream
p="" ;;
"0 0") # equal to upstream
p="=" ;;
"0 "*) # ahead of upstream
p="+${count#0 }" ;;
*" 0") # behind upstream
p="-${count% 0}" ;;
*) # diverged from upstream
p="-${count% *}+${count#* }" ;;
esac
fi
GIT_PROMPT_UPSTREAM_STATE=$p
}
_git_prompt__rebase_info ()
{
GIT_PROMPT_REBASE_INFO=''
if [ "true" != "$(git rev-parse --is-inside-work-tree 2>/dev/null)" ]; then
return
fi
if [ "$GIT_PROMPT_SHOWREBASEINFO" = 'off' ]; then
return
fi
if [ "$(git config --bool prompt.showRebaseInfo)" = "false" ]; then
return
fi
local r=""
local g="$(_git_promt__git_dir)"
if [ -n "$g" ]; then
if [ -f "$g/rebase-merge/interactive" ]; then
r="|REBASE-i"
elif [ -d "$g/rebase-merge" ]; then
r="|REBASE-m"
else
if [ -d "$g/rebase-apply" ]; then
if [ -f "$g/rebase-apply/rebasing" ]; then
r="|REBASE"
elif [ -f "$g/rebase-apply/applying" ]; then
r="|AM"
else
r="|AM/REBASE"
fi
elif [ -f "$g/MERGE_HEAD" ]; then
r="|MERGING"
elif [ -f "$g/CHERRY_PICK_HEAD" ]; then
r="|CHERRY-PICKING"
elif [ -f "$g/BISECT_LOG" ]; then
r="|BISECTING"
fi
fi
fi
GIT_PROMPT_REBASE_INFO=$r
}
_git_prompt__branch ()
{
GIT_PROMPT_BRANCH=''
if [ "true" != "$(git rev-parse --is-inside-work-tree 2>/dev/null)" ]; then
return
fi
if [ "$GIT_PROMPT_SHOWBRANCH" = 'off' ]; then
return
fi
if [ "$(git config --bool prompt.showBranch)" = "false" ]; then
return
fi
local b=""
local g="$(_git_promt__git_dir)"
if [ -n "$g" ]; then
if [ -f "$g/rebase-merge/interactive" ]; then
b="$(cat "$g/rebase-merge/head-name")"
elif [ -d "$g/rebase-merge" ]; then
b="$(cat "$g/rebase-merge/head-name")"
else
b="$(git symbolic-ref HEAD 2>/dev/null)" || {
b="$(
case "${GIT_PROMPT_DESCRIBE_STYLE-}" in
(contains)
git describe --contains HEAD ;;
(branch)
git describe --contains --all HEAD ;;
(describe)
git describe HEAD ;;
(* | default)
git describe --tags --exact-match HEAD ;;
esac 2>/dev/null)" ||
b="$(cut -c1-7 "$g/HEAD" 2>/dev/null)" ||
b="$b"
}
fi
b=${b##refs/heads/}
if [ "true" = "$(git rev-parse --is-inside-git-dir 2>/dev/null)" ]; then
if [ "true" = "$(git rev-parse --is-bare-repository 2>/dev/null)" ]; then
b="BARE:$b"
else
b="GIT_DIR!"
fi
fi
fi
GIT_PROMPT_BRANCH=$b
}
_git_prompt__stash ()
{
GIT_PROMPT_STASH_STATE_DIRTY=''
if [ "true" != "$(git rev-parse --is-inside-work-tree 2>/dev/null)" ]; then
return
fi
if [ "$GIT_PROMPT_SHOWSTASHSTATE" = 'off' ]; then
return
fi
if [ "$(git config --bool prompt.showStashState)" = "false" ]; then
return
fi
if git rev-parse --verify refs/stash >/dev/null 2>&1; then
GIT_PROMPT_STASH_STATE_DIRTY='yes'
else
GIT_PROMPT_STASH_STATE_DIRTY='no'
fi
}
# This is the short-circuit logic:
local _big_repo='init'
__git_prompt_shortcircuit ()
{
if [[ "$_big_repo" == 'yes' ]]; then
_big_repo=''
if [ "$GIT_PROMPT_SHORTCIRCUIT" != 'off' ]; then
echo "$fg[red]" > /dev/stderr
echo "${bold_color}SHELL PROMPT$fg_no_bold[red]: Looks like you hit ctrl-c." > /dev/stderr
echo "${bold_color}SHELL PROMPT$fg_no_bold[red]: So for this repo I'm setting:" > /dev/stderr
echo "${bold_color}SHELL PROMPT$fg_no_bold[red]: git config prompt.showDirtyState false" > /dev/stderr
echo "${bold_color}SHELL PROMPT$fg_no_bold[red]: On big git repos it takes a long time to get info for your prompt." > /dev/stderr
echo "${bold_color}SHELL PROMPT$fg_no_bold[red]: To revert it, run:" > /dev/stderr
echo "${bold_color}SHELL PROMPT$fg_no_bold[red]:$reset_color git config prompt.showDirtyState true" > /dev/stderr
echo '' > /dev/stderr
git config prompt.showDirtyState 'false'
$GIT_PROMPT_INFO_FUNC
fi
fi
}
TRAPINT ()
{
__git_prompt_shortcircuit
return $(( 128 + $1 ))
}
_git_prompt__dirty_state ()
{
GIT_PROMPT_DIRTY_STATE_FRESH_REPO=''
GIT_PROMPT_DIRTY_STATE_INDEX_ADDED=''
GIT_PROMPT_DIRTY_STATE_INDEX_COPIED=''
GIT_PROMPT_DIRTY_STATE_INDEX_DELETED=''
GIT_PROMPT_DIRTY_STATE_INDEX_DIRTY=''
GIT_PROMPT_DIRTY_STATE_INDEX_MODIFIED=''
GIT_PROMPT_DIRTY_STATE_INDEX_RENAMED=''
GIT_PROMPT_DIRTY_STATE_INDEX_UNMERGED=''
GIT_PROMPT_DIRTY_STATE_WORKTREE_DELETED=''
GIT_PROMPT_DIRTY_STATE_WORKTREE_DIRTY=''
GIT_PROMPT_DIRTY_STATE_WORKTREE_MODIFIED=''
GIT_PROMPT_DIRTY_STATE_WORKTREE_UNTRACKED=''
if [ "true" != "$(git rev-parse --is-inside-work-tree 2>/dev/null)" ]; then
return
fi
local g="$(_git_promt__git_dir)"
if [ -z "$g" ]; then
return
fi
if [ "$GIT_PROMPT_SHOWDIRTYSTATE" = 'off' ]; then
return
fi
if [ "$(git config --bool prompt.showDirtyState)" = "false" ]; then
return
fi
GIT_PROMPT_DIRTY_STATE_FRESH_REPO='no'
GIT_PROMPT_DIRTY_STATE_INDEX_ADDED='no'
GIT_PROMPT_DIRTY_STATE_INDEX_COPIED='no'
GIT_PROMPT_DIRTY_STATE_INDEX_DELETED='no'
GIT_PROMPT_DIRTY_STATE_INDEX_DIRTY='no'
GIT_PROMPT_DIRTY_STATE_INDEX_MODIFIED='no'
GIT_PROMPT_DIRTY_STATE_INDEX_RENAMED='no'
GIT_PROMPT_DIRTY_STATE_INDEX_UNMERGED='no'
GIT_PROMPT_DIRTY_STATE_WORKTREE_DELETED='no'
GIT_PROMPT_DIRTY_STATE_WORKTREE_DIRTY='no'
GIT_PROMPT_DIRTY_STATE_WORKTREE_MODIFIED='no'
GIT_PROMPT_DIRTY_STATE_WORKTREE_UNTRACKED='no'
if git rev-parse --quiet --verify HEAD >/dev/null; then
else
GIT_PROMPT_DIRTY_STATE_FRESH_REPO='yes'
fi
_big_repo='yes'
local line
while IFS=$'\n' read line; do
if [[ "$line" = M* ]]; then
GIT_PROMPT_DIRTY_STATE_INDEX_MODIFIED='yes'
GIT_PROMPT_DIRTY_STATE_INDEX_DIRTY='yes'
fi
if [[ "$line" = A* ]]; then
GIT_PROMPT_DIRTY_STATE_INDEX_ADDED='yes'
GIT_PROMPT_DIRTY_STATE_INDEX_DIRTY='yes'
fi
if [[ "$line" = R* ]]; then
GIT_PROMPT_DIRTY_STATE_INDEX_RENAMED='yes'
GIT_PROMPT_DIRTY_STATE_INDEX_DIRTY='yes'
fi
if [[ "$line" = C* ]]; then
GIT_PROMPT_DIRTY_STATE_INDEX_COPIED='yes'
GIT_PROMPT_DIRTY_STATE_INDEX_DIRTY='yes'
fi
if [[ "$line" = D* ]]; then
GIT_PROMPT_DIRTY_STATE_INDEX_DELETED='yes'
GIT_PROMPT_DIRTY_STATE_INDEX_DIRTY='yes'
fi
if [[ "$line" = \?\?* ]]; then
GIT_PROMPT_DIRTY_STATE_WORKTREE_UNTRACKED='yes'
fi
if [[ "$line" = ?M* ]]; then
GIT_PROMPT_DIRTY_STATE_WORKTREE_MODIFIED='yes'
GIT_PROMPT_DIRTY_STATE_WORKTREE_DIRTY='yes'
fi
if [[ "$line" = ?D* ]]; then
GIT_PROMPT_DIRTY_STATE_WORKTREE_DELETED='yes'
GIT_PROMPT_DIRTY_STATE_WORKTREE_DIRTY='yes'
fi
if [[ "$line" = UU* ]]; then
GIT_PROMPT_DIRTY_STATE_INDEX_UNMERGED='yes'
GIT_PROMPT_DIRTY_STATE_INDEX_DIRTY='yes'
fi
done < <(git status --porcelain 2> /dev/null)
_big_repo=''
}
#------------------ Fast Prompt ------------------
# This section sets up some functions that get called infrequently as possible
# and therefore don't slow your prompt down as you are using zsh.
#
# I borrowed from: http://sebastiancelis.com/2009/nov/16/zsh-prompt-git-users/
# Enable auto-execution of functions.
typeset -Uga preexec_functions
typeset -Uga precmd_functions
typeset -Uga chpwd_functions
typeset -Uga periodic_functions
# Append git functions needed for prompt.
preexec_functions+='_git_prompt__preexec_update_git_vars'
precmd_functions+='_git_prompt__precmd_update_git_vars'
chpwd_functions+="_git_prompt_info"
PERIOD=15
periodic_functions+="_git_prompt_info"
_git_prompt_info () { $GIT_PROMPT_INFO_FUNC }
_git_prompt_info
_git_prompt__precmd_update_git_vars()
{
if [[ $ZSH_VERSION = *\ 4.2* ]]; then
# some older versions of zsh don't have periodic_functions, so do the
# slow path if that's the case:
$GIT_PROMPT_INFO_FUNC
elif [ -n "$__EXECUTED_GIT_COMMAND" ]; then
$GIT_PROMPT_INFO_FUNC
unset __EXECUTED_GIT_COMMAND
fi
}
_git_prompt__preexec_update_git_vars ()
{
case "$1" in
$EDITOR*) __EXECUTED_GIT_COMMAND=1 ;;
g*) __EXECUTED_GIT_COMMAND=1 ;;
rm*) __EXECUTED_GIT_COMMAND=1 ;;
touch*) __EXECUTED_GIT_COMMAND=1 ;;
mkdir*) __EXECUTED_GIT_COMMAND=1 ;;
esac
}
#--------------------------------------------------

View file

@ -1,60 +1,3 @@
# Aliases source $ZSH/plugins/git/git-aliases.plugin.zsh
alias g='git' ; compdef g=git source $ZSH/plugins/git/git-prompt-old.plugin.zsh
alias ga='git add' ; compdef _git ga=git-add source $ZSH/plugins/git/git-prompt.plugin.zsh
alias gaa='git add --all' ; compdef _git gaa=git-add
alias gs='git status' ; compdef _git gs=git-status
alias gst='git status' ; compdef _git gst=git-status
# for `gsts "<message>"`
alias gsts='git stash save' ; compdef _git gsts=git-stash
alias gstp='git stash pop' ; compdef _git gstp=git-stash
alias gstl='git stash list' ; compdef _git gstl=git-stash
alias gstll='git stash show -p --stat' ; compdef _git gstll=git-stash
alias gl='git pull' ; compdef _git gl=git-pull
alias gup='git fetch && git rebase' ; compdef _git gup=git-fetch
alias gf='git fetch' ; compdef _git gf=git-fetch
alias gp='git push' ; compdef _git gp=git-push
alias gd='git diff --no-ext-diff -b' ; compdef _git gd=git-diff
alias gdd='git diff --no-ext-diff' ; compdef _git gdd=git-diff
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 gb='git branch' ; compdef _git gb=git-branch
alias gba='git branch -a' ; compdef _git gba=git-branch
alias gcount='git shortlog -sn' ; compdef gcount=git
alias gcp='git cherry-pick' ; compdef _git gcp=git-cherry-pick
alias gm='git merge' ; compdef _git gm=git-merge
alias glg='git log --stat --max-count=5'; compdef _git glg=git-log
# Git history (pretty)
local pretty_format_oneline='--pretty=format:"%C(yellow)%h %C(green)%cd %C(cyan)%an %C(bold cyan)%d%C(reset) %s" --date=short'
local pretty_format_medium='--pretty=format:"%C(yellow)commit %H %C(bold cyan)%d%C(reset)
%C(cyan)Author: %an <%ae>%C(reset)
%C(green)Date: %cd%C(reset)
%+s
%+b"'
alias gh="git log --graph $pretty_format_oneline" ; compdef _git gh=git-log
alias ghh="git log --graph $pretty_format_medium" ; compdef _git gh=git-log
alias ghhh="git log --graph --stat $pretty_format_medium" ; compdef _git gh=git-log
alias ghhhh="git log --graph --stat -p --full-diff $pretty_format_medium"; compdef _git gh=git-log
# Git and svn mix
alias git-svn-dcommit-push='git svn dcommit && git push github master:svntrunk'
compdef git-svn-dcommit-push=git
#
# Will return the current branch name
# Usage example: git pull origin $(current_branch)
#
function current_branch() {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
echo ${ref#refs/heads/}
}
# these aliases take advantage of the previous function
alias ggpull='git pull origin $(current_branch)'
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

View file

@ -1,8 +1,5 @@
# This works if you installed node via homebrew.
export NODE_PATH="/usr/local/lib/node"
# Open the node api for your current version to the optional section. # Open the node api for your current version to the optional section.
# TODO: Make the section part easier to use. # TODO: Make the section part easier to use.
function node-api { function node-docs {
open "http://nodejs.org/docs/$(node --version)/api/all.html#$1" open "http://nodejs.org/docs/$(node --version)/api/all.html#$1"
} }

View file

@ -1,2 +0,0 @@
# TODO: Don't do this in such a weird way.
export PATH=`echo $PATH | sed -e 's|/usr/bin|/usr/local/share/npm/bin:&|'`

View file

@ -1,7 +1,3 @@
fpath=($ZSH/plugins/rvm $fpath)
autoload -U compinit
compinit -i
alias rubies='rvm list rubies' alias rubies='rvm list rubies'
alias gemsets='rvm gemset list' alias gemsets='rvm gemset list'
@ -35,10 +31,6 @@ function rvm-update {
rvm reload # TODO: Reload rvm completion? rvm reload # TODO: Reload rvm completion?
} }
function rvm-link-completion {
ln -s "$rvm_path/scripts/zsh/Completion/_rvm" "$ZSH/plugins/rvm/_rvm.official"
}
# TODO: Make this usable w/o rvm. # TODO: Make this usable w/o rvm.
function gems { function gems {
local current_ruby=`rvm-prompt i v p` local current_ruby=`rvm-prompt i v p`

View file

@ -13,7 +13,7 @@ function in_svn() {
} }
function svn_get_repo_name { function svn_get_repo_name {
if [ is_svn ]; then if [ in_svn ]; then
svn info | sed -n 's/Repository\ Root:\ .*\///p' | read SVN_ROOT svn info | sed -n 's/Repository\ Root:\ .*\///p' | read SVN_ROOT
svn info | sed -n "s/URL:\ .*$SVN_ROOT\///p" | sed "s/\/.*$//" svn info | sed -n "s/URL:\ .*$SVN_ROOT\///p" | sed "s/\/.*$//"
@ -21,13 +21,13 @@ function svn_get_repo_name {
} }
function svn_get_rev_nr { function svn_get_rev_nr {
if [ is_svn ]; then if [ in_svn ]; then
svn info 2> /dev/null | sed -n s/Revision:\ //p svn info 2> /dev/null | sed -n s/Revision:\ //p
fi fi
} }
function svn_dirty_choose { function svn_dirty_choose {
if [ is_svn ]; then if [ in_svn ]; then
s=$(svn status 2>/dev/null) s=$(svn status 2>/dev/null)
if [ $s ]; then if [ $s ]; then
echo $1 echo $1

View file

@ -14,10 +14,6 @@ if [[ "$MODE_INDICATOR" == "" ]]; then
MODE_INDICATOR="%{$fg_bold[red]%}<%{$reset_color%}%{$fg[red]%}<<%{$reset_color%}" MODE_INDICATOR="%{$fg_bold[red]%}<%{$reset_color%}%{$fg[red]%}<<%{$reset_color%}"
fi fi
function zle-line-init zle-keymap-select {
zle reset-prompt
}
# If I am using vi keys, I want to know what mode I'm currently using. # If I am using vi keys, I want to know what mode I'm currently using.
# zle-keymap-select is executed every time KEYMAP changes. # zle-keymap-select is executed every time KEYMAP changes.
# From http://zshwiki.org/home/examples/zlewidgets # From http://zshwiki.org/home/examples/zlewidgets

View file

@ -0,0 +1,22 @@
local user='%{$fg[magenta]%}%n@%{$fg[magenta]%}%m%{$reset_color%}'
local pwd='%{$fg[blue]%}%~%{$reset_color%}'
local rvm='%{$fg[green]%}$(rvm-prompt i v g)%{$reset_color%}'
local return_code='%(?..%{$fg[red]%}%? ↵%{$reset_color%})'
local git_branch='$(git_prompt_status)%{$reset_color%}$(git_prompt_info)%{$reset_color%}'
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[green]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DIRTY=""
ZSH_THEME_GIT_PROMPT_CLEAN=""
ZSH_THEME_GIT_PROMPT_ADDED="%{$fg[green]%} ✚"
ZSH_THEME_GIT_PROMPT_MODIFIED="%{$fg[blue]%} ✹"
ZSH_THEME_GIT_PROMPT_DELETED="%{$fg[red]%} ✖"
ZSH_THEME_GIT_PROMPT_RENAMED="%{$fg[magenta]%} ➜"
ZSH_THEME_GIT_PROMPT_UNMERGED="%{$fg[yellow]%} ═"
ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[cyan]%} ✭"
PROMPT="${user} ${pwd}$ "
RPROMPT="${return_code} ${git_branch} ${rvm}"

View file

@ -1,427 +1,142 @@
#-------------------- PROMPT definition: ---------------------- # NOTE: make sure to add 'git' to your list of oh-my-zsh plugins (in your
# Set the prompt. # ~/.zshrc), otherwise the git prompt info will not be shown.
# 'R'eset formats #-------------------- Colors ----------------------
local R="%{$terminfo[sgr0]%}" # Colors ('_C' for color):
if [[ "$DISABLE_COLOR" != "true" ]]; then
# git prompt info colors:
local _Cerror_="%{$fg[yellow]%}" # bad (empty) .git/ directory
local _Cb_new_repo_="%{$fg_bold[default]%}" # branch color of new repo
local _Cb_clean_="%{$fg_no_bold[green]%}" # branch color when clean
local _Cb_dirty_="%{$fg_no_bold[red]%}" # branch color when dirty
local _Cr_="%{$bold_color$fg[yellow]%}" # rebase info
local _Ci_="%{$bold_color$fg[red]%}" # index info
local _Cu_clean_="" # untracked files state when clean
local _Cu_dirty_="%{$fg_bold[red]%}" # untracked files state when dirty
local _Cp_="%{${fg[cyan]}%}" # upstream info
local _Cs_="" # stash state
# git_prompt_info colors ('_C' for color): # Reset formating:
local _Cerror_="%{$fg[yellow]%}" # bad (empty) .git/ directory local R="%{$terminfo[sgr0]%}"
local _Cb_new_repo_="%{$fg_bold[default]%}" # branch color of new repo
local _Cb_clean_="%{$fg_no_bold[green]%}" # branch color when clean
local _Cb_dirty_="%{$fg_no_bold[red]%}" # branch color when dirty
local _Cr_="%{$bold_color$fg[yellow]%}" # rebase info
local _Ci_="%{$bold_color$fg[red]%}" # index info
local _Cu_clean_="" # untracked files state when clean
local _Cu_dirty_="%{$fg_bold[red]%}" # untracked files state when dirty
local _Cp_="%{${fg[cyan]}%}" # upstream info
local _Cs_="" # stash state
# PROMPT colors:
local _Cuser_root_="%{$fg_bold[yellow]$bg[red]%}"
local _Chost_root_="%{$fg[red]%}"
local _Cpath_root_="%{$fg_bold[white]%}"
local _Cuser_="%{$fg_bold[cyan]%}"
local _Chost_="%{$fg_bold[blue]%}"
local _Cpath_="%{$fg_bold[white]%}"
local _Cjobs_="%{$fg[blue]%}"
# special colors for privileged users (root) # RPROMPT colors:
local jobs_="%{$fg[blue]%}%(1j.%j.)" local _Cdate_="%{$fg[green]%}"
local user_="%(!.%{$fg_bold[yellow]$bg[red]%}.%{$fg_bold[cyan]%})%n" local _Creturn_code_="%{$fg[red]%}"
local host_="%(!.%{$fg[red]%}.%{$fg_bold[blue]%})%m" local _Cvi_mode_="%{$fg_bold[cyan]%}"
local path_="%(!.%{$fg_bold[white]%}.%{$fg_bold[white]%})%~" fi
PROMPT='$user_$R$host_$R$path_$R $(git_prompt_info)$R$jobs_$R# '
local date_format_="%D{%a %b %d}, %*"
local date_="%{$fg[green]%}[$date_format_]"
local return_code_="%(?..%{$fg[red]%}%? ↵ )"
# use the vi-mode oh-my-zsh plugin to get this:
MODE_INDICATOR="%{$fg_bold[cyan]%}-- CMD MODE -- $R"
RPROMPT='$return_code_$R$date_$R'
#------------------ setting git_prompt_info (FAST) ------------------
# To get a fast prompt I borrowed from:
# http://sebastiancelis.com/2009/nov/16/zsh-prompt-git-users/
#
# This section sets up some functions that get called infrequently as possible
# and therefore don't slow your prompt down as you are using zsh.
export GIT_PS1_SHOWUPSTREAM="verbose"
export GIT_PS1_SHOWSTASHSTATE='yes'
export GIT_PS1_SHOWDIRTYSTATE='yes'
export GIT_PS1_SHOWUNTRACKEDFILES='yes'
function git_prompt_info ()
{
# some older versions of zsh don't have periodic_functions, so do the slow
# path if that's the case:
[[ $ZSH_VERSION = *\ 4.2* ]] && update_current_git_vars
echo "$__GIT_PROMPT_INFO"
}
function update_current_git_vars()
{
__GIT_PROMPT_INFO="$(__git_prompt_format_and_color_with_shortcircuit)"
}
function precmd_update_git_vars()
{
if [ -n "$__EXECUTED_GIT_COMMAND" ]; then
update_current_git_vars
unset __EXECUTED_GIT_COMMAND
fi
}
function preexec_update_git_vars ()
{
case "$1" in
vim*)
__EXECUTED_GIT_COMMAND=1
;;
g*)
__EXECUTED_GIT_COMMAND=1
;;
rm*)
__EXECUTED_GIT_COMMAND=1
;;
touch*)
__EXECUTED_GIT_COMMAND=1
;;
mkdir*)
__EXECUTED_GIT_COMMAND=1
;;
# f)
# __EXECUTED_GIT_COMMAND=1
# ;;
# fg)
# __EXECUTED_GIT_COMMAND=1
# ;;
esac
}
# Enable auto-execution of functions.
typeset -ga preexec_functions
typeset -ga precmd_functions
typeset -ga chpwd_functions
typeset -ga periodic_functions
# Append git functions needed for prompt.
preexec_functions+='preexec_update_git_vars'
precmd_functions+='precmd_update_git_vars'
chpwd_functions+='update_current_git_vars'
PERIOD=15
periodic_functions+='update_current_git_vars'
#------------------ git information utils ------------------
# To pull information out of git, I borrowed from:
# https://github.com/git/git/blob/master/contrib/completion/git-completion.bash
# __gitdir accepts 0 or 1 arguments (i.e., location)
# returns location of .git repo
__gitdir ()
{
if [ -z "${1-}" ]; then
if [ -n "${__git_dir-}" ]; then
echo "$__git_dir"
elif [ -d .git ]; then
echo .git
else
git rev-parse --git-dir 2>/dev/null
fi
elif [ -d "$1/.git" ]; then
echo "$1/.git"
else
echo "$1"
fi
}
# echos divergence from upstream
# used by GIT_PS1_SHOWUPSTREAM
__git_show_upstream ()
{
local key value
local svn_remote svn_url_pattern count n
local upstream=git legacy="" verbose=""
local p
# get some config options from git-config
while read key value; do
case "$key" in
prompt.showUpstream)
GIT_PS1_SHOWUPSTREAM="$value"
if [[ -z "${GIT_PS1_SHOWUPSTREAM}" ]]; then
p=""
return
fi
;;
svn-remote.*.url)
svn_remote=( "${svn_remote[@]}" $value )
svn_url_pattern="$svn_url_pattern\\|$value"
upstream=svn+git # default upstream is SVN if available, else git
;;
esac
done < <(git config --get-regexp '^(svn-remote\..*\.url|prompt\.showUpstream)$' 2>/dev/null)
# parse configuration values
for option in ${GIT_PS1_SHOWUPSTREAM}; do
case "$option" in
git|svn) upstream="$option" ;;
verbose) verbose=1 ;;
legacy) legacy=1 ;;
esac
done
# Find our upstream
case "$upstream" in
git) upstream="@{upstream}" ;;
svn*)
# get the upstream from the "git-svn-id: ..." in a commit message
# (git-svn uses essentially the same procedure internally)
local svn_upstream=$(git log --first-parent -1 --grep="^git-svn-id: \(${svn_url_pattern#??}\)" 2>/dev/null | awk '/commit / { print $2 }')
if [[ 0 -ne ${#svn_upstream[@]} ]]; then
if [[ -z "$svn_upstream" ]]; then
# default branch name for checkouts with no layout:
upstream='git-svn'
else
upstream=${svn_upstream#/}
fi
elif [[ "svn+git" = "$upstream" ]]; then
upstream="@{upstream}"
fi
;;
esac
# Find how many commits we are ahead/behind our upstream
# produce equivalent output to --count for older versions of git
local ahead behind
if git rev-list --left-right "$upstream"...HEAD >/dev/null 2>&1; then
behind="$(git rev-list --left-right "$upstream"...HEAD 2>/dev/null | grep '^<' | wc -l | tr -d ' ' 2>/dev/null)"
ahead="$(git rev-list --left-right "$upstream"...HEAD 2>/dev/null | grep '^[^<]' | wc -l | tr -d ' ' 2>/dev/null)"
count="$behind $ahead"
fi
# calculate the result
if [[ -z "$verbose" ]]; then
case "$count" in
"") # no upstream
p="" ;;
"0 0") # equal to upstream
p="=" ;;
"0 "*) # ahead of upstream
p=">" ;;
*" 0") # behind upstream
p="<" ;;
*) # diverged from upstream
p="<>" ;;
esac
else
case "$count" in
"") # no upstream
p="" ;;
"0 0") # equal to upstream
p="=" ;;
"0 "*) # ahead of upstream
p="+${count#0 }" ;;
*" 0") # behind upstream
p="-${count% 0}" ;;
*) # diverged from upstream
p="-${count% *}+${count#* }" ;;
esac
fi
echo $p
}
__git_show_rebase_info ()
{
local r=""
local g="$(__gitdir)"
if [ -n "$g" ]; then
if [ -f "$g/rebase-merge/interactive" ]; then
r="|REBASE-i"
elif [ -d "$g/rebase-merge" ]; then
r="|REBASE-m"
else
if [ -d "$g/rebase-apply" ]; then
if [ -f "$g/rebase-apply/rebasing" ]; then
r="|REBASE"
elif [ -f "$g/rebase-apply/applying" ]; then
r="|AM"
else
r="|AM/REBASE"
fi
elif [ -f "$g/MERGE_HEAD" ]; then
r="|MERGING"
elif [ -f "$g/CHERRY_PICK_HEAD" ]; then
r="|CHERRY-PICKING"
elif [ -f "$g/BISECT_LOG" ]; then
r="|BISECTING"
fi
fi
fi
echo $r
}
# stores the branch name in $b
__git_show_branch ()
{
local b=""
local g="$(__gitdir)"
if [ -n "$g" ]; then
if [ -f "$g/rebase-merge/interactive" ]; then
b="$(cat "$g/rebase-merge/head-name")"
elif [ -d "$g/rebase-merge" ]; then
b="$(cat "$g/rebase-merge/head-name")"
else
b="$(git symbolic-ref HEAD 2>/dev/null)" || {
b="$(
case "${GIT_PS1_DESCRIBE_STYLE-}" in
(contains)
git describe --contains HEAD ;;
(branch)
git describe --contains --all HEAD ;;
(describe)
git describe HEAD ;;
(* | default)
git describe --tags --exact-match HEAD ;;
esac 2>/dev/null)" ||
b="$(cut -c1-7 "$g/HEAD" 2>/dev/null)" ||
b="$b"
}
fi
b=${b##refs/heads/}
if [ "true" = "$(git rev-parse --is-inside-git-dir 2>/dev/null)" ]; then
if [ "true" = "$(git rev-parse --is-bare-repository 2>/dev/null)" ]; then
b="BARE:$b"
else
b="GIT_DIR!"
fi
fi
fi
echo $b
}
__git_show_untracked_files ()
{
if [ -n "$(git ls-files --others --exclude-standard)" ]; then
echo "%"
fi
}
__git_show_stash_state ()
{
git rev-parse --verify refs/stash >/dev/null 2>&1 && echo "$"
}
__git_show_dirty_state_unstaged ()
{
git diff --no-ext-diff --quiet --exit-code || echo "*"
}
__git_show_dirty_state_staged ()
{
if git rev-parse --quiet --verify HEAD >/dev/null; then
git diff-index --cached --quiet HEAD -- || echo "+"
else
echo "#"
fi
}
#----------------------------------------------------- #-----------------------------------------------------
__git_prompt_format_and_color_with_shortcircuit () # git prompt info:
# The git prompt plugin will cause $GIT_PROMPT_INFO_FUNC to be called
# when $__GIT_PROMPT_INFO needs to be updated.
GIT_PROMPT_INFO_FUNC="update__GIT_PROMPT_INFO"
GIT_PROMPT_SHOWUPSTREAM="verbose"
GIT_PROMPT_SHORTCIRCUIT='on'
local __GIT_PROMPT_INFO=''
# will set __GIT_PROMPT_INFO
update__GIT_PROMPT_INFO ()
{ {
local g="$(__gitdir)" local g="$(_git_promt__git_dir)"
if [ -n "$g" ]; then if [ -z "$g" ]; then
local w="" # workspace state __GIT_PROMPT_INFO=''
local s="" # stash state return
local i="" # index state
local si="" # stash + index state
local u="" # untracked files state
local p="" # u'p'stream state
local b="$(__git_show_branch)" # branch
local r="$(__git_show_rebase_info)" # rebase info
if [ -n "$r" ]; then
r="$_Crebase_$r$R"
fi
if [ "true" = "$(git rev-parse --is-inside-work-tree 2>/dev/null)" ]; then
if [ -n "${GIT_PS1_SHOWDIRTYSTATE-}" ]; then
if [ "$(git config --bool prompt.showDirtyState)" != "false" ]; then
if [ -z "$(eval print \$_big_repo$$)" ]; then
# This is the short circuit logic:
# The following 3 functions can take a long time on big
# repositories, so check to see if ctrl-c is entered by
# setting _big_repo$$ for the duration of these functions:
eval _big_repo$$='yes'
i="$(__git_show_dirty_state_staged)"
if [ "$i" = "+" ]; then
i="$_Ci_$i$R"
fi
w="$(__git_show_dirty_state_unstaged)"
if [ -n "$b" ]; then
if [ "$i" = "#" ]; then
# this is a fresh repo, nothing here...
b="$_Cb_new_repo_$b$R"
i=''
elif [ -n "$w" ]; then
b="$_Cb_dirty_$b$R"
else
b="$_Cb_clean_$b$R"
fi
fi
if [ -n "${GIT_PS1_SHOWUNTRACKEDFILES-}" ]; then
u="$(__git_show_untracked_files)"
fi
else
echo "$fg[red]"
echo "${bold_color}SHELL PROMPT$fg_no_bold[red]: Looks like you hit ctrl-c."
echo "${bold_color}SHELL PROMPT$fg_no_bold[red]: On big repositories it takes a long time to get git info for your prompt."
echo "${bold_color}SHELL PROMPT$fg_no_bold[red]: So I'm setting \`git config prompt.showDirtyState false\` on this repository because you hit ctrl-c."
echo "${bold_color}SHELL PROMPT$fg_no_bold[red]: To revert it, run:"
echo "${bold_color}SHELL PROMPT$fg_no_bold[red]:$reset_color git config prompt.showDirtyState true"
echo ''
git config prompt.showDirtyState 'false'
fi
unset _big_repo$$
fi
fi
if [ -n "${GIT_PS1_SHOWSTASHSTATE-}" ]; then
s="$(__git_show_stash_state)"
fi
if [ -n "${GIT_PS1_SHOWUPSTREAM-}" ]; then
p="$(__git_show_upstream)"
fi
si="$i$s"
if [ -n "$s$p" ]; then
i+="$R"
p="$_Cp_$p$R"
s="$_Cs_$s$R"
fi
else
unset _big_repo$$
fi
local _prompt="$b$r${si:+$i$s}$p"
# add ( ) around _prompt:
if [ -z "$w$i$u$b" ]; then
if [ -n "$g" ]; then
_prompt="$_Cerror_(Error: bad ./$g dir)"
fi
elif [ -n "$u" ]; then
_prompt="$_Cu_dirty_($_prompt$_Cu_dirty_)"
else
_prompt="$_Cu_clean_($_prompt$_Cu_clean_)"
fi
echo "$R$_prompt$R"
fi fi
_git_prompt__stash
local s=$GIT_PROMPT_STASH_STATE_DIRTY
_git_prompt__upstream
local p=$GIT_PROMPT_UPSTREAM_STATE
_git_prompt__branch
local b=$GIT_PROMPT_BRANCH
_git_prompt__rebase_info
local r=$GIT_PROMPT_REBASE_INFO
_git_prompt__dirty_state
local w=$GIT_PROMPT_DIRTY_STATE_WORKTREE_DIRTY
local i=$GIT_PROMPT_DIRTY_STATE_INDEX_DIRTY
local u=$GIT_PROMPT_DIRTY_STATE_WORKTREE_UNTRACKED
local f=$GIT_PROMPT_DIRTY_STATE_FRESH_REPO
if [ -z "$b$i$w$u" ]; then
if [ -n "$g" ]; then
__GIT_PROMPT_INFO="$R$_Cerror_(Error: bad ./$g dir)$R"
return
fi
fi
if [ "$s" = 'yes' ]; then
s="$_Cs_\$$R"
else
s=""
fi
if [ -n "$p" ]; then
p="$_Cp_$p$R"
fi
if [ "$i" = "yes" ]; then
i="$_Ci_+$R"
else
i=""
fi
if [ -n "$b" ]; then
if [ "$f" = "yes" ]; then
# this is a fresh repo, nothing here...
b="$_Cb_new_repo_$b$R"
elif [ "$w" = 'yes' ]; then
b="$_Cb_dirty_$b$R"
elif [ "$w" = 'no' ]; then
b="$_Cb_clean_$b$R"
fi
fi
if [ -n "$r" ]; then
r="$_Cr_$r$R"
fi
local _prompt="$b$r$i$s$p"
# add ( ) around _prompt:
if [ "$u" = "yes" ]; then
_prompt="$_Cu_dirty_($_prompt$_Cu_dirty_)"
elif [ "$u" = "no" ]; then
_prompt="$_Cu_clean_($_prompt$_Cu_clean_)"
else
fi
__GIT_PROMPT_INFO="$R$_prompt$R"
} }
#-------------------- PROMPT definition: ----------------------
#
local user_="%(!.$_Cuser_root_.$_Cuser_)%n$R"
local host_="%(!.$_Chost_root_.$_Chost_)%m$R"
local path_="%(!.$_Cpath_root_.$_Cpath_)%~$R"
local jobs_="%(1j.$_Cjobs_%j$R.)"
PROMPT='$user_$host_$path_ $__GIT_PROMPT_INFO$jobs_# '
local date_format_='%D{%a %b %d}, %*'
local date_="${_Cdate_}[$date_format_]$R"
local return_code_="%(?..$_Creturn_code_%? ↵ )$R"
RPROMPT='$return_code_$date_'
# use the vi-mode oh-my-zsh plugin to get this:
MODE_INDICATOR="${_Cvi_mode_}-- CMD MODE -- $R"

26
themes/humza.zsh-theme Normal file
View file

@ -0,0 +1,26 @@
# ZSH THEME Preview: https://skitch.com/huyy/rk979/humza.zshtheme
let TotalBytes=0
for Bytes in $(ls -l | grep "^-" | awk '{ print $5 }')
do
let TotalBytes=$TotalBytes+$Bytes
done
# should it say b, kb, Mb, or Gb
if [ $TotalBytes -lt 1024 ]; then
TotalSize=$(echo -e "scale=3 \n$TotalBytes \nquit" | bc)
suffix="b"
elif [ $TotalBytes -lt 1048576 ]; then
TotalSize=$(echo -e "scale=3 \n$TotalBytes/1024 \nquit" | bc)
suffix="kb"
elif [ $TotalBytes -lt 1073741824 ]; then
TotalSize=$(echo -e "scale=3 \n$TotalBytes/1048576 \nquit" | bc)
suffix="Mb"
else
TotalSize=$(echo -e "scale=3 \n$TotalBytes/1073741824 \nquit" | bc)
suffix="Gb"
fi
PROMPT='%{$reset_color%}%n %{$fg[green]%}{%{$reset_color%}%~%{$fg[green]%}}%{$reset_color%}$(git_prompt_info) greetings, earthling %{$fg[green]%}[%{$reset_color%}%{$TotalSize%}%{$suffix%}%{$fg[green]%}]%{$fg[red]%}$%{$reset_color%} ☞ '
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[red]%}±("
ZSH_THEME_GIT_PROMPT_SUFFIX=");%{$reset_color%}"

View file

@ -0,0 +1,8 @@
# Yay! High voltage and arrows!
ZSH_THEME_GIT_PROMPT_PREFIX="%{$reset_color%}%{$fg[green]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[yellow]%}⚡%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_CLEAN=""
PROMPT='%{$fg[cyan]%}%1~%{$reset_color%}%{$fg[red]%}|%{$reset_color%}$(git_prompt_info)%{$fg[cyan]%}⇒%{$reset_color%} '

17
themes/nebirhos.zsh-theme Normal file
View file

@ -0,0 +1,17 @@
# Based on robbyrussell's theme, with host and rvm indicators. Example:
# @host ➜ currentdir rvm:(rubyversion@gemset) git:(branchname)
# Get the current ruby version in use with RVM:
if [ -e ~/.rvm/bin/rvm-prompt ]; then
RUBY_PROMPT_="%{$fg_bold[blue]%}rvm:(%{$fg[green]%}\$(~/.rvm/bin/rvm-prompt s i v g)%{$fg_bold[blue]%})%{$reset_color%} "
fi
# Get the host name (first 4 chars)
HOST_PROMPT_="%{$fg_bold[red]%}@$HOST[0,4] ➜ %{$fg_bold[cyan]%}%c "
GIT_PROMPT="%{$fg_bold[blue]%}\$(git_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}"
PROMPT="$HOST_PROMPT_$RUBY_PROMPT_$GIT_PROMPT"
ZSH_THEME_GIT_PROMPT_PREFIX="git:(%{$fg[red]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%}) %{$fg[yellow]%}✗%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[blue]%})"

26
themes/sunaku.zsh-theme Normal file
View file

@ -0,0 +1,26 @@
# Git-centric variation of the "fishy" theme.
# See screenshot at http://ompldr.org/vOHcwZg
ZSH_THEME_GIT_PROMPT_ADDED="%{$fg[green]%}+"
ZSH_THEME_GIT_PROMPT_MODIFIED="%{$fg[magenta]%}!"
ZSH_THEME_GIT_PROMPT_DELETED="%{$fg[red]%}-"
ZSH_THEME_GIT_PROMPT_RENAMED="%{$fg[blue]%}>"
ZSH_THEME_GIT_PROMPT_UNMERGED="%{$fg[cyan]%}#"
ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[yellow]%}?"
ZSH_THEME_GIT_PROMPT_PREFIX=""
ZSH_THEME_GIT_PROMPT_SUFFIX=" "
ZSH_THEME_GIT_PROMPT_DIRTY=""
ZSH_THEME_GIT_PROMPT_CLEAN=""
local user_color='green'
test $UID -eq 0 && user_color='red'
PROMPT='%(?..%{$fg_bold[red]%}exit %?
%{$reset_color%})'\
'%{$bold_color%}$(git_prompt_status)%{$reset_color%}'\
'$(git_prompt_info)'\
'%{$fg[$user_color]%}%~%{$reset_color%}'\
'%(!.#.>) '
PROMPT2='%{$fg[red]%}\ %{$reset_color%}'

View file

@ -1,29 +0,0 @@
function prompt_char {
git branch >/dev/null 2>/dev/null && echo '±' && return
hg root >/dev/null 2>/dev/null && echo '☿' && return
echo '○'
}
function virtualenv_info {
[ $VIRTUAL_ENV ] && echo '('`basename $VIRTUAL_ENV`') '
}
function hg_prompt_info {
hg prompt --angle-brackets "\
< on %{$fg[magenta]%}<branch>%{$reset_color%}>\
< at %{$fg[yellow]%}<tags|%{$reset_color%}, %{$fg[yellow]%}>%{$reset_color%}>\
%{$fg[green]%}<status|modified|unknown><update>%{$reset_color%}<
patches: <patches|join( → )|pre_applied(%{$fg[yellow]%})|post_applied(%{$reset_color%})|pre_unapplied(%{$fg_bold[black]%})|post_unapplied(%{$reset_color%})>>" 2>/dev/null
}
PROMPT='
%{$fg[magenta]%}%n%{$reset_color%} at %{$fg[yellow]%}%m%{$reset_color%} in %{$fg_bold[green]%}${PWD/#$HOME/~}%{$reset_color%}$(hg_prompt_info)$(git_prompt_info)
$(virtualenv_info)$(prompt_char) '
ZSH_THEME_GIT_PROMPT_PREFIX=" on %{$fg[magenta]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[green]%}!"
ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[green]%}?"
ZSH_THEME_GIT_PROMPT_CLEAN=""
. ~/bin/dotfiles/zsh/aliases

View file

@ -1,36 +1,36 @@
if [ -d ~/.oh-my-zsh ] if [ -d ~/.oh-my-zsh ]
then then
echo "You already have Oh My Zsh installed. You'll need to remove ~/.oh-my-zsh if you want to install" echo "\033[0;33mYou already have Oh My Zsh installed.\033[0m You'll need to remove ~/.oh-my-zsh if you want to install"
exit exit
fi fi
echo "Cloning Oh My Zsh..." echo "\033[0;34mCloning Oh My Zsh...\033[0m"
/usr/bin/env git clone https://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh /usr/bin/env git clone https://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh
echo "Looking for an existing zsh config..." echo "\033[0;34mLooking for an existing zsh config...\033[0m"
if [ -f ~/.zshrc ] || [ -h ~/.zshrc ] if [ -f ~/.zshrc ] || [ -h ~/.zshrc ]
then then
echo "Found ~/.zshrc. Backing up to ~/.zshrc.pre-oh-my-zsh"; echo "\033[0;33mFound ~/.zshrc.\033[0m \033[0;32]Backing up to ~/.zshrc.pre-oh-my-zsh\033[0m";
cp ~/.zshrc ~/.zshrc.pre-oh-my-zsh; cp ~/.zshrc ~/.zshrc.pre-oh-my-zsh;
rm ~/.zshrc; rm ~/.zshrc;
fi fi
echo "Using the Oh My Zsh template file and adding it to ~/.zshrc" echo "\033[0;34mUsing the Oh My Zsh template file and adding it to ~/.zshrc\033[0m"
cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
echo "Copying your current PATH and adding it to the end of ~/.zshrc for you." echo "\033[0;34mCopying your current PATH and adding it to the end of ~/.zshrc for you.\033[0m"
echo "export PATH=$PATH" >> ~/.zshrc echo "export PATH=$PATH" >> ~/.zshrc
echo "Time to change your default shell to zsh!" echo "\033[0;34mTime to change your default shell to zsh!\033[0m"
chsh -s `which zsh` chsh -s `which zsh`
echo ' __ __ ' echo "\033[0;32m"' __ __ '"\033[0m"
echo ' ____ / /_ ____ ___ __ __ ____ _____/ /_ ' echo "\033[0;32m"' ____ / /_ ____ ___ __ __ ____ _____/ /_ '"\033[0m"
echo ' / __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \ ' echo "\033[0;32m"' / __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \ '"\033[0m"
echo '/ /_/ / / / / / / / / / / /_/ / / /_(__ ) / / / ' echo "\033[0;32m"'/ /_/ / / / / / / / / / / /_/ / / /_(__ ) / / / '"\033[0m"
echo '\____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/ ' echo "\033[0;32m"'\____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/ '"\033[0m"
echo ' /____/' echo "\033[0;32m"' /____/ '"\033[0m"
echo "\n\n ....is now installed." echo "\n\n \033[0;32m....is now installed.\033[0m"
/usr/bin/env zsh /usr/bin/env zsh
source ~/.zshrc source ~/.zshrc

View file

@ -1,12 +1,12 @@
current_path=`pwd` current_path=`pwd`
echo "Upgrading Oh My Zsh" echo "\033[0;34mUpgrading Oh My Zsh\033[0m"
( cd $ZSH && git pull origin master ) ( cd $ZSH && git pull origin master )
echo ' __ __ ' echo "\033[0;32m"' __ __ '"\033[0m"
echo ' ____ / /_ ____ ___ __ __ ____ _____/ /_ ' echo "\033[0;32m"' ____ / /_ ____ ___ __ __ ____ _____/ /_ '"\033[0m"
echo ' / __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \ ' echo "\033[0;32m"' / __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \ '"\033[0m"
echo '/ /_/ / / / / / / / / / / /_/ / / /_(__ ) / / / ' echo "\033[0;32m"'/ /_/ / / / / / / / / / / /_/ / / /_(__ ) / / / '"\033[0m"
echo '\____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/ ' echo "\033[0;32m"'\____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/ '"\033[0m"
echo ' /____/' echo "\033[0;32m"' /____/ '"\033[0m"
echo "Hooray! Oh My Zsh has been updated and/or is at the current version. \nAny new updates will be reflected when you start your next terminal session." echo "\033[0;34mHooray! Oh My Zsh has been updated and/or is at the current version.\033[0m"
echo "To keep up on the latest, be sure to follow Oh My Zsh on twitter: http://twitter.com/ohmyzsh" echo "\033[0;34mTo keep up on the latest, be sure to follow Oh My Zsh on twitter: \033[1mhttp://twitter.com/ohmyzsh\033[0m"
cd $current_path cd $current_path