Merge remote-tracking branch 'robby/master'

This commit is contained in:
Gregory Liras 2012-01-26 02:37:43 +02:00
commit d4b345bb92
16 changed files with 197 additions and 133 deletions

View file

@ -56,7 +56,7 @@ the "refcard":http://www.bash2zsh.com/zsh_refcard/refcard.pdf is pretty tasty fo
h3. Customization h3. Customization
If you want to override any of the default behavior, just add a new file (ending in @.zsh@) into the @custom/@ directory. If you want to override any of the default behavior, just add a new file (ending in @.zsh@) into the @custom/@ directory.
If you have many functions which go good together you can put them as a *.plugin.zsh file in the @custom/plugins/@ directory and then enable this plugin. If you have many functions which go well together you can put them as a *.plugin.zsh file in the @custom/plugins/@ directory and then enable this plugin.
If you would like to override the functionality of a plugin distributed with oh-my-zsh, create a plugin of the same name in the @custom/plugins/@ directory and it will be loaded instead of the one in @plugins/@. 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/@.

View file

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

View file

@ -1,5 +1,9 @@
if [ -f /opt/local/etc/profile.d/autojump.sh ]; then if [ $commands[autojump] ]; then # check if autojump is installed
. /opt/local/etc/profile.d/autojump.sh if [ -f /usr/share/autojump/autojump.zsh ]; then # debian and ubuntu package
elif [ -f `brew --prefix`/etc/autojump ]; then . /usr/share/autojump/autojump.zsh
elif [ -f /etc/profile.d/autojump.zsh ]; then # manual installation
. /etc/profile.d/autojump.zsh
elif [ $commands[brew] -a -f `brew --prefix`/etc/autojump ]; then # mac os x with brew
. `brew --prefix`/etc/autojump . `brew --prefix`/etc/autojump
fi fi
fi

View file

@ -1,7 +1,3 @@
fpath=($ZSH/plugins/bundler $fpath)
autoload -U compinit
compinit -i
alias be="bundle exec" alias be="bundle exec"
alias bi="bundle install" alias bi="bundle install"
alias bl="bundle list" alias bl="bundle list"
@ -10,7 +6,7 @@ alias bu="bundle update"
# The following is based on https://github.com/gma/bundler-exec # The following is based on https://github.com/gma/bundler-exec
bundled_commands=(cap capify cucumber foreman guard heroku nanoc rackup rails rainbows rake rspec ruby shotgun spec spork thin unicorn unicorn_rails) bundled_commands=(annotate cap capify cucumber foreman guard heroku middleman nanoc rackup rainbows rake rspec ruby shotgun spec spork thin thor unicorn unicorn_rails)
## Functions ## Functions
@ -20,7 +16,7 @@ _bundler-installed() {
_within-bundled-project() { _within-bundled-project() {
local check_dir=$PWD local check_dir=$PWD
while [ "$(dirname $check_dir)" != "/" ]; do while [ $check_dir != "/" ]; do
[ -f "$check_dir/Gemfile" ] && return [ -f "$check_dir/Gemfile" ] && return
check_dir="$(dirname $check_dir)" check_dir="$(dirname $check_dir)"
done done

View file

@ -220,3 +220,4 @@ _managepy() {
compdef _managepy manage.py compdef _managepy manage.py
compdef _managepy django compdef _managepy django
compdef _managepy django-manage

View file

@ -78,8 +78,3 @@ function extract() {
alias x=extract alias x=extract
# add extract completion function to path
fpath=($ZSH/plugins/extract $fpath)
autoload -U compinit
compinit -i

View file

@ -36,6 +36,8 @@ alias ga='git add'
compdef _git ga=git-add compdef _git ga=git-add
alias gm='git merge' alias gm='git merge'
compdef _git gm=git-merge compdef _git gm=git-merge
alias grh='git reset HEAD'
alias grhh='git reset HEAD --hard'
# Git and svn mix # Git and svn mix
alias git-svn-dcommit-push='git svn dcommit && git push github master:svntrunk' alias git-svn-dcommit-push='git svn dcommit && git push github master:svntrunk'

View file

@ -1,7 +1,17 @@
# Setup hub function for git, if it is available; http://github.com/defunkt/hub # Setup hub function for git, if it is available; http://github.com/defunkt/hub
if [ "$commands[(I)hub]" ] && [ "$commands[(I)ruby]" ]; then if [ "$commands[(I)hub]" ] && [ "$commands[(I)ruby]" ]; then
# eval `hub alias -s zsh` # eval `hub alias -s zsh`
function git(){hub "$@"} function git(){
if ! (( $+_has_working_hub )); then
hub --version &> /dev/null
_has_working_hub=$(($? == 0))
fi
if (( $_has_working_hub )) ; then
hub "$@"
else
command git "$@"
fi
}
fi fi
# Functions ################################################################# # Functions #################################################################

View file

@ -1,14 +1,14 @@
# Mercurial # Mercurial
alias hgc='hg commit -v' alias hgc='hg commit'
alias hgb='hg branch -v' alias hgb='hg branch'
alias hgba='hg branches' alias hgba='hg branches'
alias hgco='hg checkout' alias hgco='hg checkout'
alias hgd='hg diff' alias hgd='hg diff'
alias hged='hg diffmerge' alias hged='hg diffmerge'
# pull and update # pull and update
alias hgl='hg pull -u -v' alias hgl='hg pull -u'
alias hgp='hg push -v' alias hgp='hg push'
alias hgs='hg status -v' alias hgs='hg status'
# this is the 'git commit --amend' equivalent # this is the 'git commit --amend' equivalent
alias hgca='hg qimport -r tip ; hg qrefresh -e ; hg qfinish tip' alias hgca='hg qimport -r tip ; hg qrefresh -e ; hg qfinish tip'

View file

@ -0,0 +1,6 @@
alias rake="noglob rake" # allows square brackts for rake task invocation
alias brake='noglob bundle exec rake' # execute the bundled rake gem
alias srake='noglob sudo rake' # noglob must come before sudo
alias sbrake='noglob sudo bundle exec rake' # altogether now ...

View file

@ -3,4 +3,4 @@
alias sgem='sudo gem' alias sgem='sudo gem'
# Find ruby file # Find ruby file
alias rfind='find . -name *.rb | xargs grep -n' alias rfind='find . -name "*.rb" | xargs grep -n'

View file

@ -37,7 +37,7 @@ function gems {
local current_gemset=`rvm-prompt g` local current_gemset=`rvm-prompt g`
gem list $@ | sed \ gem list $@ | sed \
-Ee "s/\([0-9\.]+( .+)?\)/$fg[blue]&$reset_color/g" \ -Ee "s/\([0-9, \.]+( .+)?\)/$fg[blue]&$reset_color/g" \
-Ee "s|$(echo $rvm_path)|$fg[magenta]\$rvm_path$reset_color|g" \ -Ee "s|$(echo $rvm_path)|$fg[magenta]\$rvm_path$reset_color|g" \
-Ee "s/$current_ruby@global/$fg[yellow]&$reset_color/g" \ -Ee "s/$current_ruby@global/$fg[yellow]&$reset_color/g" \
-Ee "s/$current_ruby$current_gemset$/$fg[green]&$reset_color/g" -Ee "s/$current_ruby$current_gemset$/$fg[green]&$reset_color/g"

View file

@ -1,37 +1,37 @@
#compdef task #compdef task
#
# zsh completion for taskwarrior # zsh completion for taskwarrior
# #
# taskwarrior - a command line task list manager.
#
# Copyright 2010 - 2011 Johannes Schlatow # Copyright 2010 - 2011 Johannes Schlatow
# Copyright 2009 P.C. Shyamshankar # Copyright 2009 P.C. Shyamshankar
# All rights reserved.
# #
# This script is part of the taskwarrior project. # Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# #
# This program is free software; you can redistribute it and/or modify it under # The above copyright notice and this permission notice shall be included
# the terms of the GNU General Public License as published by the Free Software # in all copies or substantial portions of the Software.
# Foundation; either version 2 of the License, or (at your option) any later
# version.
# #
# This program is distributed in the hope that it will be useful, but WITHOUT # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# details. # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
# #
# You should have received a copy of the GNU General Public License along with # http://www.opensource.org/licenses/mit-license.php
# this program; if not, write to the
#
# Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor,
# Boston, MA
# 02110-1301
# USA
# #
typeset -g _task_cmds _task_projects _task_tags _task_config _task_modifiers typeset -g _task_cmds _task_projects _task_tags _task_config _task_modifiers
_task_projects=($(task _projects)) _task_projects=($(task _projects))
_task_tags=($(task _tags)) _task_tags=($(task _tags))
_task_ids=($(task _ids)) _task_ids=($(task _ids))
_task_config=($(task _config)) _task_config=($(task _config))
_task_columns=($(task _columns))
_task_modifiers=( _task_modifiers=(
'before' \ 'before' \
'after' \ 'after' \
@ -46,39 +46,19 @@ _task_modifiers=(
'word' \ 'word' \
'noword' 'noword'
) )
_task_conjunctions=(
'and' \
'or' \
'xor' \
'\)'
'\('
)
_task_cmds=($(task _commands)) _task_cmds=($(task _commands))
_task_zshcmds=( ${(f)"$(task _zshcommands)"} ) _task_zshcmds=( ${(f)"$(task _zshcommands)"} )
_task_idCmds=(
'append' \
'prepend' \
'annotate' \
'denotate' \
'edit' \
'duplicate' \
'info' \
'start' \
'stop' \
'done'
)
_task_idCmdsDesc=(
'append:Appends more description to an existing task.' \
'prepend:Prepends more description to an existing task.' \
'annotate:Adds an annotation to an existing task.' \
'denotate:Deletes an annotation of an existing task.' \
'edit:Launches an editor to let you modify a task directly.' \
'duplicate:Duplicates the specified task, and allows modifications.' \
'info:Shows all data, metadata for specified task.' \
'start:Marks specified task as started.' \
'stop:Removes the start time from a task.' \
'done:Marks the specified task as completed.'
)
_task() { _task() {
_arguments -s -S \ _arguments -s -S \
"*::task command:_task_commands" "*::task default:_task_default"
return 0 return 0
} }
@ -148,6 +128,7 @@ _regex_words values 'task frequencies' \
'weekly:Every week' \ 'weekly:Every week' \
'biweekly:Every two weeks' \ 'biweekly:Every two weeks' \
'fortnight:Every two weeks' \ 'fortnight:Every two weeks' \
+ 'monthly:Every month' \
'quarterly:Every three months' \ 'quarterly:Every three months' \
'semiannual:Every six months' \ 'semiannual:Every six months' \
'annual:Every year' \ 'annual:Every year' \
@ -196,22 +177,13 @@ _regex_arguments _task_attributes "${args[@]}"
## task commands ## task commands
# default completion # filter completion
(( $+functions[_task_default] )) || (( $+functions[_task_filter] )) ||
_task_default() { _task_filter() {
_task_attributes "$@" _task_attributes "$@"
}
# commands expecting an ID # TODO complete conjunctions only if the previous word is a filter expression, i.e. attribute, ID, any non-command
(( $+functions[_task_id] )) || _describe -t default 'task conjunctions' _task_conjunctions
_task_id() {
if (( CURRENT < 3 )); then
# update IDs
_task_zshids=( ${(f)"$(task _zshids)"} )
_describe -t values 'task IDs' _task_zshids
else
_task_attributes "$@"
fi
} }
# merge completion # merge completion
@ -235,46 +207,42 @@ _task_pull() {
_files _files
} }
# execute completion
(( $+functions[_task_execute] )) ||
_task_execute() {
_files
}
# modify (task [0-9]* ...) completion # id-only completion
(( $+functions[_task_modify] )) || (( $+functions[_task_id] )) ||
_task_modify() { _task_id() {
_describe -t commands 'task command' _task_idCmdsDesc _describe -t values 'task IDs' _task_zshids
_task_attributes "$@"
} }
## first level completion => task sub-command completion ## first level completion => task sub-command completion
(( $+functions[_task_commands] )) || (( $+functions[_task_default] )) ||
_task_commands() { _task_default() {
local cmd ret=1 local cmd ret=1
if (( CURRENT == 1 )); then
integer i=1
while (( i < $#words ))
do
cmd="${_task_cmds[(r)$words[$i]]}"
if (( $#cmd )); then
_call_function ret _task_${cmd} ||
_call_function ret _task_filter ||
_message "No command remaining."
return ret
fi
(( i++ ))
done
# update IDs # update IDs
_task_zshids=( ${(f)"$(task _zshids)"} ) _task_zshids=( ${(f)"$(task _zshids)"} )
_describe -t commands 'task command' _task_zshcmds _describe -t commands 'task command' _task_zshcmds
_describe -t values 'task IDs' _task_zshids _describe -t values 'task IDs' _task_zshids
# TODO match more than one ID _call_function ret _task_filter
elif [[ $words[1] =~ ^[0-9]*$ ]] then
_call_function ret _task_modify
return ret
else
# local curcontext="${curcontext}"
# cmd="${_task_cmds[(r)$words[1]:*]%%:*}"
cmd="${_task_cmds[(r)$words[1]]}"
idCmd="${(M)_task_idCmds[@]:#$words[1]}"
if (( $#cmd )); then
# curcontext="${curcontext%:*:*}:task-${cmd}"
if (( $#idCmd )); then
_call_function ret _task_id
else
_call_function ret _task_${cmd} ||
_call_function ret _task_default ||
_message "No command remaining."
fi
else
_message "Unknown subcommand ${cmd}"
fi
return ret return ret
fi
} }

View file

@ -0,0 +1,11 @@
# Set Apple Terminal.app resume directory
# based on this answer: http://superuser.com/a/315029
function chpwd {
local SEARCH=' '
local REPLACE='%20'
local PWD_URL="file://$HOSTNAME${PWD//$SEARCH/$REPLACE}"
printf '\e]7;%s\a' "$PWD_URL"
}
chpwd

View file

@ -0,0 +1,58 @@
function my_git_prompt() {
tester=$(git rev-parse --git-dir 2> /dev/null) || return
INDEX=$(git status --porcelain 2> /dev/null)
STATUS=""
# is branch ahead?
if $(echo "$(git log origin/$(current_branch)..HEAD 2> /dev/null)" | grep '^commit' &> /dev/null); then
STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_AHEAD"
fi
# is anything staged?
if $(echo "$INDEX" | grep -E -e '^(D[ M]|[MARC][ MD]) ' &> /dev/null); then
STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_STAGED"
fi
# is anything unstaged?
if $(echo "$INDEX" | grep -E -e '^[ MARC][MD] ' &> /dev/null); then
STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_UNSTAGED"
fi
# is anything untracked?
if $(echo "$INDEX" | grep '^?? ' &> /dev/null); then
STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_UNTRACKED"
fi
# is anything unmerged?
if $(echo "$INDEX" | grep -E -e '^(A[AU]|D[DU]|U[ADU]) ' &> /dev/null); then
STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_UNMERGED"
fi
if [[ -n $STATUS ]]; then
STATUS=" $STATUS"
fi
echo "$ZSH_THEME_GIT_PROMPT_PREFIX$(my_current_branch)$STATUS$ZSH_THEME_GIT_PROMPT_SUFFIX"
}
function my_current_branch() {
echo $(current_branch || echo "(no branch)")
}
function ssh_connection() {
if [[ -n $SSH_CONNECTION ]]; then
echo "%{$fg_bold[red]%}(ssh) "
fi
}
PROMPT=$'\n$(ssh_connection)%{$fg_bold[green]%}%n@%m%{$reset_color%}$(my_git_prompt) : %~\n%# '
ZSH_THEME_PROMPT_RETURNCODE_PREFIX="%{$fg_bold[red]%}"
ZSH_THEME_GIT_PROMPT_PREFIX=" $fg[white] %{$fg_bold[yellow]%}"
ZSH_THEME_GIT_PROMPT_AHEAD="%{$fg_bold[magenta]%}↑"
ZSH_THEME_GIT_PROMPT_STAGED="%{$fg_bold[green]%}●"
ZSH_THEME_GIT_PROMPT_UNSTAGED="%{$fg_bold[red]%}●"
ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg_bold[white]%}●"
ZSH_THEME_GIT_PROMPT_UNMERGED="%{$fg_bold[red]%}✕"
ZSH_THEME_GIT_PROMPT_SUFFIX=" $fg_bold[white]%{$reset_color%}"

View file

@ -1,6 +1,9 @@
current_path=`pwd` current_path=`pwd`
printf '\033[0;34m%s\033[0m\n' "Upgrading Oh My Zsh" printf '\033[0;34m%s\033[0m\n' "Upgrading Oh My Zsh"
( cd $ZSH && git pull origin master ) cd $ZSH
if git pull origin master
then
printf '\033[0;32m%s\033[0m\n' ' __ __ ' printf '\033[0;32m%s\033[0m\n' ' __ __ '
printf '\033[0;32m%s\033[0m\n' ' ____ / /_ ____ ___ __ __ ____ _____/ /_ ' printf '\033[0;32m%s\033[0m\n' ' ____ / /_ ____ ___ __ __ ____ _____/ /_ '
printf '\033[0;32m%s\033[0m\n' ' / __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \ ' printf '\033[0;32m%s\033[0m\n' ' / __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \ '
@ -9,4 +12,8 @@ printf '\033[0;32m%s\033[0m\n' '\____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/
printf '\033[0;32m%s\033[0m\n' ' /____/ ' printf '\033[0;32m%s\033[0m\n' ' /____/ '
printf '\033[0;34m%s\033[0m\n' 'Hooray! Oh My Zsh has been updated and/or is at the current version.' printf '\033[0;34m%s\033[0m\n' 'Hooray! Oh My Zsh has been updated and/or is at the current version.'
printf '\033[0;34m%s\033[1m%s\033[0m\n' 'To keep up on the latest, be sure to follow Oh My Zsh on twitter: ' 'http://twitter.com/ohmyzsh' printf '\033[0;34m%s\033[1m%s\033[0m\n' 'To keep up on the latest, be sure to follow Oh My Zsh on twitter: ' 'http://twitter.com/ohmyzsh'
else
printf '\033[0;31m%s\033[0m\n' 'There was an error updating. Try again later?'
fi
cd "$current_path" cd "$current_path"