Merge commit '175b4a807383530aa75145b5b6fdedb3ce1f11f2'

This commit is contained in:
zghember 2015-01-03 14:41:34 +08:00
commit 8105d4acc9
29 changed files with 238 additions and 152 deletions

View File

@ -78,7 +78,7 @@ function git_prompt_long_sha() {
git_prompt_status() { git_prompt_status() {
INDEX=$(command git status --porcelain -b 2> /dev/null) INDEX=$(command git status --porcelain -b 2> /dev/null)
STATUS="" STATUS=""
if $(echo "$INDEX" | grep -E '^\?\? ' &> /dev/null); then if $(echo "$INDEX" | command grep -E '^\?\? ' &> /dev/null); then
STATUS="$ZSH_THEME_GIT_PROMPT_UNTRACKED$STATUS" STATUS="$ZSH_THEME_GIT_PROMPT_UNTRACKED$STATUS"
fi fi
if $(echo "$INDEX" | grep '^A ' &> /dev/null); then if $(echo "$INDEX" | grep '^A ' &> /dev/null); then

View File

@ -1,24 +1,24 @@
# # is x grep argument available?
# Color grep results
# Examples: http://rubyurl.com/ZXv
#
GREP_OPTIONS="--color=auto"
# avoid VCS folders (if the necessary grep flags are available)
grep-flag-available() { grep-flag-available() {
echo | grep $1 "" >/dev/null 2>&1 echo | grep $1 "" >/dev/null 2>&1
} }
if grep-flag-available --exclude-dir=.cvs; then
for PATTERN in .cvs .git .hg .svn; do
GREP_OPTIONS+=" --exclude-dir=$PATTERN"
done
elif grep-flag-available --exclude=.cvs; then
for PATTERN in .cvs .git .hg .svn; do
GREP_OPTIONS+=" --exclude=$PATTERN"
done
fi
unfunction grep-flag-available
export GREP_OPTIONS="$GREP_OPTIONS" # color grep results
export GREP_COLOR='1;32' GREP_OPTIONS="--color=auto"
# ignore VCS folders (if the necessary grep flags are available)
VCS_FOLDERS="{.bzr,.cvs,.git,.hg,.svn}"
if grep-flag-available --exclude-dir=.cvs; then
GREP_OPTIONS+=" --exclude-dir=$VCS_FOLDERS"
elif grep-flag-available --exclude=.cvs; then
GREP_OPTIONS+=" --exclude=$VCS_FOLDERS"
fi
# export grep settings
alias grep="grep $GREP_OPTIONS"
# clean up
unset GREP_OPTIONS
unset VCS_FOLDERS
unfunction grep-flag-available

View File

@ -1,7 +1,8 @@
## Command history configuration ## Command history configuration
if [ -z $HISTFILE ]; then if [ -z "$HISTFILE" ]; then
HISTFILE=$HOME/.zsh_history HISTFILE=$HOME/.zsh_history
fi fi
HISTSIZE=10000 HISTSIZE=10000
SAVEHIST=10000 SAVEHIST=10000

View File

@ -1,6 +1,6 @@
# get the node.js version # get the node.js version
function nvm_prompt_info() { function nvm_prompt_info() {
[ -f $HOME/.nvm/nvm.sh ] || return [ -f "$HOME/.nvm/nvm.sh" ] || return
local nvm_prompt local nvm_prompt
nvm_prompt=$(node -v 2>/dev/null) nvm_prompt=$(node -v 2>/dev/null)
[[ "${nvm_prompt}x" == "x" ]] && return [[ "${nvm_prompt}x" == "x" ]] && return

View File

@ -1,6 +1,8 @@
if [ $commands[autojump] ]; then # check if autojump is installed if [ $commands[autojump] ]; then # check if autojump is installed
if [ -f $HOME/.autojump/etc/profile.d/autojump.zsh ]; then # manual user-local installation if [ -f $HOME/.autojump/etc/profile.d/autojump.zsh ]; then # manual user-local installation
. $HOME/.autojump/etc/profile.d/autojump.zsh . $HOME/.autojump/etc/profile.d/autojump.zsh
elif [ -f $HOME/.autojump/share/autojump/autojump.zsh ]; then # another manual user-local installation
. $HOME/.autojump/share/autojump/autojump.zsh
elif [ -f $HOME/.nix-profile/etc/profile.d/autojump.zsh ]; then # nix installation elif [ -f $HOME/.nix-profile/etc/profile.d/autojump.zsh ]; then # nix installation
. $HOME/.nix-profile/etc/profile.d/autojump.zsh . $HOME/.nix-profile/etc/profile.d/autojump.zsh
elif [ -f /usr/share/autojump/autojump.zsh ]; then # debian and ubuntu package elif [ -f /usr/share/autojump/autojump.zsh ]; then # debian and ubuntu package

View File

@ -22,7 +22,10 @@ function aws_profiles {
compctl -K aws_profiles asp compctl -K aws_profiles asp
if _homebrew-installed && _awscli-homebrew-installed ; then if _homebrew-installed && _awscli-homebrew-installed ; then
source $(brew --prefix)/opt/awscli/libexec/bin/aws_zsh_completer.sh _aws_zsh_completer_path=$(brew --prefix)/opt/awscli/libexec/bin/aws_zsh_completer.sh
else else
source `which aws_zsh_completer.sh` _aws_zsh_completer_path=$(which aws_zsh_completer.sh)
fi fi
[ -x $_aws_zsh_completer_path ] && source $_aws_zsh_completer_path
unset _aws_zsh_completer_path

View File

@ -19,21 +19,18 @@ _brew_outdated_formulae() {
outdated_formulae=(`brew outdated`) outdated_formulae=(`brew outdated`)
} }
_brew_running_services() {
running_services=(`brew services list | awk '{print $1}'`)
}
local -a _1st_arguments local -a _1st_arguments
_1st_arguments=( _1st_arguments=(
'audit:check formulae for Homebrew coding style' 'audit:check formulae for Homebrew coding style'
'bundle:look for a Brewfile and run each line as a brew command'
'cat:display formula file for a formula' 'cat:display formula file for a formula'
'cleanup:uninstall unused and old versions of packages' 'cleanup:uninstall unused and old versions of packages'
'commands:show a list of commands' 'commands:show a list of commands'
'create:create a new formula' 'create:create a new formula'
'deps:list dependencies and dependants of a formula' 'deps:list dependencies of a formula'
'doctor:audits your installation for common issues' 'doctor:audits your installation for common issues'
'edit:edit a formula' 'edit:edit a formula'
'fetch:download formula resources to the cache'
'gist-logs:generate a gist of the full build logs'
'home:visit the homepage of a formula or the brew project' 'home:visit the homepage of a formula or the brew project'
'info:information about a formula' 'info:information about a formula'
'install:install a formula' 'install:install a formula'
@ -44,32 +41,24 @@ _1st_arguments=(
'missing:check all installed formuale for missing dependencies.' 'missing:check all installed formuale for missing dependencies.'
'outdated:list formulae for which a newer version is available' 'outdated:list formulae for which a newer version is available'
'pin:pin specified formulae' 'pin:pin specified formulae'
'postinstall:perform post_install for a given formula'
'prune:remove dead links' 'prune:remove dead links'
'remove:remove a formula' 'remove:remove a formula'
'search:search for a formula (/regex/ or string)' 'search:search for a formula (/regex/ or string)'
'server:start a local web app that lets you browse formulae (requires Sinatra)' 'switch:switch linkage between installed versions of a formula'
'services:small wrapper around `launchctl` for supported formulae'
'tap:tap a new formula repository from GitHub, or list existing taps' 'tap:tap a new formula repository from GitHub, or list existing taps'
'test-bot:test a formula and build a bottle'
'uninstall:uninstall a formula' 'uninstall:uninstall a formula'
'unlink:unlink a formula' 'unlink:unlink a formula'
'unpin:unpin specified formulae' 'unpin:unpin specified formulae'
'untap:remove a tapped repository' 'untap:remove a tapped repository'
'update:freshen up links' 'update:pull latest repository'
'upgrade:upgrade outdated formulae' 'upgrade:upgrade outdated formulae'
'uses:show formulae which depend on a formula' 'uses:show formulae which depend on a formula'
) )
local -a _service_arguments
_service_arguments=(
'cleanup:get rid of stale services and unused plists'
'list:list all services managed by `brew services`'
'restart:gracefully restart selected service'
'start:start selected service'
'stop:stop selected service'
)
local expl local expl
local -a formulae installed_formulae installed_taps outdated_formulae running_services local -a formulae installed_formulae installed_taps outdated_formulae
_arguments \ _arguments \
'(-v)-v[verbose]' \ '(-v)-v[verbose]' \
@ -80,6 +69,7 @@ _arguments \
'(--version)--version[version information]' \ '(--version)--version[version information]' \
'(--prefix)--prefix[where brew lives on this system]' \ '(--prefix)--prefix[where brew lives on this system]' \
'(--cache)--cache[brew cache]' \ '(--cache)--cache[brew cache]' \
'(--force)--force[brew force]' \
'*:: :->subcmds' && return 0 '*:: :->subcmds' && return 0
if (( CURRENT == 1 )); then if (( CURRENT == 1 )); then
@ -109,16 +99,6 @@ case "$words[1]" in
_arguments \ _arguments \
'(--macports)--macports[search the macports repository]' \ '(--macports)--macports[search the macports repository]' \
'(--fink)--fink[search the fink repository]' ;; '(--fink)--fink[search the fink repository]' ;;
services)
if [[ -n "$words[2]" ]]; then
case "$words[2]" in
restart|start|stop)
_brew_running_services
_wanted running_services expl 'running services' compadd -a running_services ;;
esac
else
_describe -t commands "brew services subcommand" _service_arguments
fi ;;
untap) untap)
_brew_installed_taps _brew_installed_taps
_wanted installed_taps expl 'installed taps' compadd -a installed_taps ;; _wanted installed_taps expl 'installed taps' compadd -a installed_taps ;;

View File

@ -24,7 +24,7 @@ _homebrew-installed() {
} }
_chruby-from-homebrew-installed() { _chruby-from-homebrew-installed() {
brew --prefix chruby &> /dev/null [ -r $(brew --prefix chruby)] &> /dev/null
} }
_ruby-build_installed() { _ruby-build_installed() {
@ -45,11 +45,11 @@ _source_from_omz_settings() {
zstyle -s :omz:plugins:chruby path _chruby_path zstyle -s :omz:plugins:chruby path _chruby_path
zstyle -s :omz:plugins:chruby auto _chruby_auto zstyle -s :omz:plugins:chruby auto _chruby_auto
if _chruby_path && [[ -r _chruby_path ]]; then if ${_chruby_path} && [[ -r ${_chruby_path} ]]; then
source ${_chruby_path} source ${_chruby_path}
fi fi
if _chruby_auto && [[ -r _chruby_auto ]]; then if ${_chruby_auto} && [[ -r ${_chruby_auto} ]]; then
source ${_chruby_auto} source ${_chruby_auto}
fi fi
} }

View File

@ -5,6 +5,6 @@
eval "insert-cycledleft () { zle push-line; LBUFFER='pushd -q +1'; zle accept-line }" eval "insert-cycledleft () { zle push-line; LBUFFER='pushd -q +1'; zle accept-line }"
zle -N insert-cycledleft zle -N insert-cycledleft
bindkey "\e[1;6D" insert-cycledleft bindkey "\e[1;6D" insert-cycledleft
eval "insert-cycledright () { zle push-line; LBUFFER='pushd -q -0'; zle accept-line }" eval "insert-cycledright () { zle push-line; LBUFFER='pushd -q +0'; zle accept-line }"
zle -N insert-cycledright zle -N insert-cycledright
bindkey "\e[1;6C" insert-cycledright bindkey "\e[1;6C" insert-cycledright

View File

@ -4,6 +4,7 @@
# Requires: Docker installed # Requires: Docker installed
# Author: Azaan (@aeonazaan) # Author: Azaan (@aeonazaan)
# Updates: Bob Maerten (@bobmaerten) for Docker v0.9+ # Updates: Bob Maerten (@bobmaerten) for Docker v0.9+
# Paul van den Berg (@bergvandenp) for Docker v1.3+
# ----- Helper functions # ----- Helper functions
@ -238,6 +239,14 @@ __wait() {
__docker_containers __docker_containers
} }
__exec() {
_arguments \
'(-d,--detach=)'{-d,--detach=}'[Detached mode: run command in the background]' \
'(-i,--interactive=)'{-i,--interactive=}'[Keep STDIN open even if not attached]' \
'(-t,--tty=)'{-t,--tty=}'[Allocate a pseudo-TTY]'
__docker_containers
}
# end commands --------- # end commands ---------
# ---------------------- # ----------------------
@ -276,6 +285,7 @@ _1st_arguments=(
"top":"Lookup the running processes of a container" "top":"Lookup the running processes of a container"
"version":"Show the docker version information" "version":"Show the docker version information"
"wait":"Block until a container stops, then print its exit code" "wait":"Block until a container stops, then print its exit code"
"exec":"Run a task inside a running container"
) )
_arguments '*:: :->command' _arguments '*:: :->command'
@ -353,4 +363,6 @@ case "$words[1]" in
__version ;; __version ;;
wait) wait)
__wait ;; __wait ;;
exec)
__exec ;;
esac esac

View File

@ -27,8 +27,6 @@ _1st_arguments=(
"config\:push":"push local config vars to heroku" "config\:push":"push local config vars to heroku"
"config\:set":"set one or more config vars" "config\:set":"set one or more config vars"
"config\:unset":"unset one or more config vars" "config\:unset":"unset one or more config vars"
"db\:push":"push local data up to your app"
"db\:pull":"pull heroku data down into your local database"
"domains":"list custom domains for an app" "domains":"list custom domains for an app"
"domains\:add":"add a custom domain to an app" "domains\:add":"add a custom domain to an app"
"domains\:remove":"remove a custom domain from an app" "domains\:remove":"remove a custom domain from an app"
@ -43,12 +41,20 @@ _1st_arguments=(
"logs\:drains":"manage syslog drains" "logs\:drains":"manage syslog drains"
"maintenance\:on":"put the app into maintenance mode" "maintenance\:on":"put the app into maintenance mode"
"maintenance\:off":"take the app out of maintenance mode" "maintenance\:off":"take the app out of maintenance mode"
"pg\:credentials":"display the DATABASE credentials"
"pg\:diagnose":"run diagnostics report on DATABASE"
"pg\:info":"display database information" "pg\:info":"display database information"
"pg\:ingress":"allow direct connections to the database from this IP for one minute" "pg\:kill":"kill a query"
"pg\:killall":"terminates ALL connections"
"pg\:maintenance":"manage maintenance for DATABASE"
"pg\:promote":"sets DATABASE as your DATABASE_URL" "pg\:promote":"sets DATABASE as your DATABASE_URL"
"pg\:ps":"view active queries with execution time"
"pg\:psql":"open a psql shell to the database" "pg\:psql":"open a psql shell to the database"
"pg\:pull":"pull from REMOTE_SOURCE_DATABASE to LOCAL_TARGET_DATABASE"
"pg\:push":"push from LOCAL_SOURCE_DATABASE to REMOTE_TARGET_DATABASE"
"pg\:reset":"delete all data in DATABASE" "pg\:reset":"delete all data in DATABASE"
"pg\:unfollow":"stop a replica from following and make it a read/write database" "pg\:unfollow":"stop a replica from following and make it a read/write database"
"pg\:upgrade":"unfollow a database and upgrade it to the latest PostgreSQL version"
"pg\:wait":"monitor database creation, exit when complete" "pg\:wait":"monitor database creation, exit when complete"
"pgbackups":"list captured backups" "pgbackups":"list captured backups"
"pgbackups\:url":"get a temporary URL for a backup" "pgbackups\:url":"get a temporary URL for a backup"
@ -108,26 +114,6 @@ case "$words[1]" in
'(-s|--shell)'{-s,--shell}'[output config vars in shell format]' \ '(-s|--shell)'{-s,--shell}'[output config vars in shell format]' \
) )
;; ;;
db:push)
_command_args=(
'(-c|--chunksize)'{-c,--chunksize}'[specify the number of rows to send in each batch]' \
'(-d|--debug)'{-d,--debug}'[enable debugging output]' \
'(-e|--exclude)'{-e,--exclude}'[exclude the specified tables from the push]' \
'(-f|--filter)'{-f,--filter}'[only push certain tables]' \
'(-r|--resume)'{-r,--resume}'[resume transfer described by a .dat file]' \
'(-t|--tables)'{-t,--tables}'[only push the specified tables]' \
)
;;
db:pull)
_command_args=(
'(-c|--chunksize)'{-c,--chunksize}'[specify the number of rows to send in each batch]' \
'(-d|--debug)'{-d,--debug}'[enable debugging output]' \
'(-e|--exclude)'{-e,--exclude}'[exclude the specified tables from the pull]' \
'(-f|--filter)'{-f,--filter}'[only pull certain tables]' \
'(-r|--resume)'{-r,--resume}'[resume transfer described by a .dat file]' \
'(-t|--tables)'{-t,--tables}'[only pull the specified tables]' \
)
;;
keys) keys)
_command_args=( _command_args=(
'(-l|--long)'{-l,--long}'[display extended information for each key]' \ '(-l|--long)'{-l,--long}'[display extended information for each key]' \

View File

@ -42,7 +42,7 @@ $ZSH_THEME_REPO_NAME_COLOR$_DISPLAY$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_HG_PROMPT_SU
function hg_dirty_choose { function hg_dirty_choose {
if [ $(in_hg) ]; then if [ $(in_hg) ]; then
hg status 2> /dev/null | grep -Eq '^\s*[ACDIM!?L]' hg status 2> /dev/null | command grep -Eq '^\s*[ACDIM!?L]'
if [ $pipestatus[-1] -eq 0 ]; then if [ $pipestatus[-1] -eq 0 ]; then
# Grep exits with 0 when "One or more lines were selected", return "dirty". # Grep exits with 0 when "One or more lines were selected", return "dirty".
echo $1 echo $1

View File

@ -177,12 +177,43 @@ function itunes() {
vol) vol)
opt="set sound volume to $1" #$1 Due to the shift opt="set sound volume to $1" #$1 Due to the shift
;; ;;
shuf|shuff|shuffle)
# The shuffle property of current playlist can't be changed in iTunes 12,
# so this workaround uses AppleScript to simulate user input instead.
# Defaults to toggling when no options are given.
# The toggle option depends on the shuffle button being visible in the Now playing area.
# On and off use the menu bar items.
local state=$1
if [[ -n "$state" && ! "$state" =~ "^(on|off|toggle)$" ]]
then
print "Usage: itunes shuffle [on|off|toggle]. Invalid option."
return 1
fi
case "$state" in
on|off)
# Inspired by: http://stackoverflow.com/a/14675583
osascript 1>/dev/null 2>&1 <<-EOF
tell application "System Events" to perform action "AXPress" of (menu item "${state}" of menu "Shuffle" of menu item "Shuffle" of menu "Controls" of menu bar item "Controls" of menu bar 1 of application process "iTunes" )
EOF
return 0
;;
toggle|*)
osascript 1>/dev/null 2>&1 <<-EOF
tell application "System Events" to perform action "AXPress" of (button 2 of process "iTunes"'s window "iTunes"'s scroll area 1)
EOF
return 0
;;
esac
;;
""|-h|--help) ""|-h|--help)
echo "Usage: itunes <option>" echo "Usage: itunes <option>"
echo "option:" echo "option:"
echo "\tlaunch|play|pause|stop|rewind|resume|quit" echo "\tlaunch|play|pause|stop|rewind|resume|quit"
echo "\tmute|unmute\tcontrol volume set" echo "\tmute|unmute\tcontrol volume set"
echo "\tnext|previous\tplay next or previous track" echo "\tnext|previous\tplay next or previous track"
echo "\tshuf|shuffle [on|off|toggle]\tSet shuffled playback. Default: toggle. Note: toggle doesn't support the MiniPlayer."
echo "\tvol\tSet the volume, takes an argument from 0 to 100" echo "\tvol\tSet the volume, takes an argument from 0 to 100"
echo "\thelp\tshow this message and exit" echo "\thelp\tshow this message and exit"
return 0 return 0

View File

@ -1,13 +1,13 @@
_phing_does_target_list_need_generating () { _phing_does_target_list_need_generating () {
[ ! -f .phing_targets ] && return 0; [ ! -f .phing_targets ] && return 0;
[ .phing_targets -nt build.xml ] && return 0; [ build.xml -nt .phing_targets ] && return 0;
return 1; return 1;
} }
_phing () { _phing () {
if [ -f build.xml ]; then if [ -f build.xml ]; then
if _phing_does_target_list_need_generating; then if _phing_does_target_list_need_generating; then
phing -l |grep -v ":$" |grep -v "^-*$" > .phing_targets phing -l|grep -v "\[property\]"|grep -v "Buildfile"|sed 1d|grep -v ":$" |grep -v "^\-*$"|awk '{print $1}' > .phing_targets
fi fi
compadd `cat .phing_targets` compadd `cat .phing_targets`
fi fi

View File

@ -63,11 +63,11 @@ function svn_current_revision() {
function svn_status_info() { function svn_status_info() {
local svn_status_string="$ZSH_THEME_SVN_PROMPT_CLEAN" local svn_status_string="$ZSH_THEME_SVN_PROMPT_CLEAN"
local svn_status="$(svn status 2> /dev/null)"; local svn_status="$(svn status 2> /dev/null)";
if grep -E '^\s*A' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string ${ZSH_THEME_SVN_PROMPT_ADDITIONS:-+}"; fi if command grep -E '^\s*A' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string ${ZSH_THEME_SVN_PROMPT_ADDITIONS:-+}"; fi
if grep -E '^\s*D' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string ${ZSH_THEME_SVN_PROMPT_DELETIONS:-}"; fi if command grep -E '^\s*D' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string ${ZSH_THEME_SVN_PROMPT_DELETIONS:-}"; fi
if grep -E '^\s*M' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string ${ZSH_THEME_SVN_PROMPT_MODIFICATIONS:-}"; fi if command grep -E '^\s*M' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string ${ZSH_THEME_SVN_PROMPT_MODIFICATIONS:-}"; fi
if grep -E '^\s*[R~]' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string ${ZSH_THEME_SVN_PROMPT_REPLACEMENTS:-}"; fi if command grep -E '^\s*[R~]' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string ${ZSH_THEME_SVN_PROMPT_REPLACEMENTS:-}"; fi
if grep -E '^\s*\?' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string ${ZSH_THEME_SVN_PROMPT_UNTRACKED:-?}"; fi if command grep -E '^\s*\?' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string ${ZSH_THEME_SVN_PROMPT_UNTRACKED:-?}"; fi
if grep -E '^\s*[CI!L]' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string ${ZSH_THEME_SVN_PROMPT_DIRTY:-'!'}"; fi if command grep -E '^\s*[CI!L]' &> /dev/null <<< $svn_status; then svn_status_string="$svn_status_string ${ZSH_THEME_SVN_PROMPT_DIRTY:-'!'}"; fi
echo $svn_status_string echo $svn_status_string
} }

View File

@ -61,7 +61,7 @@ function svn_get_rev_nr() {
function svn_dirty_choose() { function svn_dirty_choose() {
if in_svn; then if in_svn; then
root=`svn info 2> /dev/null | sed -n 's/^Working Copy Root Path: //p'` root=`svn info 2> /dev/null | sed -n 's/^Working Copy Root Path: //p'`
if $(svn status $root 2> /dev/null | grep -Eq '^\s*[ACDIM!?L]'); then if $(svn status $root 2> /dev/null | command grep -Eq '^\s*[ACDIM!?L]'); then
# Grep exits with 0 when "One or more lines were selected", return "dirty". # Grep exits with 0 when "One or more lines were selected", return "dirty".
echo $1 echo $1
else else
@ -78,7 +78,7 @@ function svn_dirty() {
function svn_dirty_choose_pwd () { function svn_dirty_choose_pwd () {
if in_svn; then if in_svn; then
root=$PWD root=$PWD
if $(svn status $root 2> /dev/null | grep -Eq '^\s*[ACDIM!?L]'); then if $(svn status $root 2> /dev/null | command grep -Eq '^\s*[ACDIM!?L]'); then
# Grep exits with 0 when "One or more lines were selected", return "dirty". # Grep exits with 0 when "One or more lines were selected", return "dirty".
echo $1 echo $1
else else

View File

@ -5,7 +5,7 @@ _symfony_console () {
} }
_symfony2_get_command_list () { _symfony2_get_command_list () {
`_symfony_console` --no-ansi | sed "1,/Available commands/d" | awk '/^ [a-z]+/ { print $1 }' `_symfony_console` --no-ansi | sed "1,/Available commands/d" | awk '/^ ?[a-z]+/ { print $1 }'
} }
_symfony2 () { _symfony2 () {

View File

@ -5,6 +5,8 @@
alias ta='tmux attach -t' alias ta='tmux attach -t'
alias ts='tmux new-session -s' alias ts='tmux new-session -s'
alias tl='tmux list-sessions' alias tl='tmux list-sessions'
alias tksv='tmux kill-server'
alias tkss='tmux kill-session -t'
# Only run if tmux is actually installed # Only run if tmux is actually installed
if which tmux &> /dev/null if which tmux &> /dev/null

View File

@ -1,7 +1,12 @@
virtualenvwrapper='virtualenvwrapper.sh' virtualenvwrapper='virtualenvwrapper.sh'
if (( $+commands[$virtualenvwrapper] )); then if (( $+commands[$virtualenvwrapper] )); then
source ${${virtualenvwrapper}:c} source ${${virtualenvwrapper}:c}
if [[ "$WORKON_HOME" == "" ]]; then
echo "\$WORKON_HOME is not defined so ZSH plugin virtualenvwrapper will not work"
else
if [[ ! $DISABLE_VENV_CD -eq 1 ]]; then if [[ ! $DISABLE_VENV_CD -eq 1 ]]; then
# Automatically activate Git projects's virtual environments based on the # Automatically activate Git projects's virtual environments based on the
# directory name of the project. Virtual environment name can be overridden # directory name of the project. Virtual environment name can be overridden
@ -54,6 +59,7 @@ if (( $+commands[$virtualenvwrapper] )); then
set -A chpwd_functions workon_cwd set -A chpwd_functions workon_cwd
fi fi
fi fi
fi
else else
print "zsh virtualenvwrapper plugin: Cannot find ${virtualenvwrapper}. Please install with \`pip install virtualenvwrapper\`." print "zsh virtualenvwrapper plugin: Cannot find ${virtualenvwrapper}. Please install with \`pip install virtualenvwrapper\`."
fi fi

View File

@ -37,8 +37,7 @@ function web_search() {
done done
url="${url%?}" # remove the last '+' url="${url%?}" # remove the last '+'
nohup $open_cmd "$url" nohup $open_cmd "$url" >/dev/null 2&>1
rm nohup.out
} }

View File

@ -16,6 +16,7 @@ function xcsel {
alias xcb='xcodebuild' alias xcb='xcodebuild'
alias xcp='xcode-select --print-path' alias xcp='xcode-select --print-path'
alias xcdd='rm -rf ~/Library/Developer/Xcode/DerivedData/*'
if [[ -d $(xcode-select -p)/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app ]]; then if [[ -d $(xcode-select -p)/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app ]]; then
alias simulator='open $(xcode-select -p)/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app' alias simulator='open $(xcode-select -p)/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app'

7
plugins/yii2/README.md Normal file
View File

@ -0,0 +1,7 @@
# Yii2 autocomplete plugin
* Adds autocomplete commands and subcommands for yii.
## Requirements
Autocomplete works from directory where your `yii` file contains.

View File

@ -0,0 +1,29 @@
# Yii2 command completion
_yii2_format_command () {
awk '/^- [a-z]+/ { sub(":", "", $2); print $2 }'
}
_yii2 () {
if [ -f ./yii ]; then
_arguments \
'1: :->command'\
'*: :->params'
case $state in
command)
local -a commands
local -a name
if [[ $words[2] == *\/ ]]; then
name=$words[2]
fi
commands=(${(f)"$(./yii help $name --color=0 | _yii2_format_command)"})
compadd -Q -S '' -a -- commands
esac
fi
}
compdef _yii2 yii

View File

@ -123,10 +123,10 @@ prompt_hg() {
st="" st=""
rev=$(hg id -n 2>/dev/null | sed 's/[^-0-9]//g') rev=$(hg id -n 2>/dev/null | sed 's/[^-0-9]//g')
branch=$(hg id -b 2>/dev/null) branch=$(hg id -b 2>/dev/null)
if `hg st | grep -Eq "^\?"`; then if `hg st | grep -q "^\?"`; then
prompt_segment red black prompt_segment red black
st='±' st='±'
elif `hg st | grep -Eq "^(M|A)"`; then elif `hg st | grep -q "^(M|A)"`; then
prompt_segment yellow black prompt_segment yellow black
st='±' st='±'
else else

View File

@ -31,7 +31,7 @@ bureau_git_status () {
if $(echo "$_INDEX" | grep '^.[MTD] ' &> /dev/null); then if $(echo "$_INDEX" | grep '^.[MTD] ' &> /dev/null); then
_STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_UNSTAGED" _STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_UNSTAGED"
fi fi
if $(echo "$_INDEX" | grep -E '^\?\? ' &> /dev/null); then if $(echo "$_INDEX" | command grep -E '^\?\? ' &> /dev/null); then
_STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_UNTRACKED" _STATUS="$_STATUS$ZSH_THEME_GIT_PROMPT_UNTRACKED"
fi fi
if $(echo "$_INDEX" | grep '^UU ' &> /dev/null); then if $(echo "$_INDEX" | grep '^UU ' &> /dev/null); then

29
themes/mira.zsh-theme Normal file
View File

@ -0,0 +1,29 @@
# Based on bira zsh theme with nvm, rvm and jenv support
local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
local user_host='%{$terminfo[bold]$fg[green]%}%n@%m%{$reset_color%}'
local current_dir='%{$terminfo[bold]$fg[blue]%} %~%{$reset_color%}'
local rvm_ruby=''
if which rvm-prompt &> /dev/null; then
rvm_ruby='%{$fg[red]%}$(rvm-prompt i v g)%{$reset_color%}'
else
if which rbenv &> /dev/null; then
rvm_ruby='%{$fg[red]%}$(rbenv version | sed -e "s/ (set.*$//")%{$reset_color%}'
fi
fi
local nvm_node=''
nvm_node='%{$fg[green]%}node-$(nvm_prompt_info)%{$reset_color%}'
local jenv_java=''
jenv_java='%{$fg[blue]%}$(jenv_prompt_info)%{$reset_color%}'
local git_branch='$(git_prompt_info)%{$reset_color%}'
PROMPT="╭─${user_host} ${current_dir} ${nvm_node} ${rvm_ruby} ${jenv_java} ${git_branch}
╰─%B$%b "
RPS1="${return_code}"
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[yellow]%}("
ZSH_THEME_GIT_PROMPT_SUFFIX=") %{$reset_color%}"

View File

@ -10,12 +10,12 @@ function my_git_prompt() {
fi fi
# is anything staged? # is anything staged?
if $(echo "$INDEX" | grep -E -e '^(D[ M]|[MARC][ MD]) ' &> /dev/null); then if $(echo "$INDEX" | command grep -E -e '^(D[ M]|[MARC][ MD]) ' &> /dev/null); then
STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_STAGED" STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_STAGED"
fi fi
# is anything unstaged? # is anything unstaged?
if $(echo "$INDEX" | grep -E -e '^[ MARC][MD] ' &> /dev/null); then if $(echo "$INDEX" | command grep -E -e '^[ MARC][MD] ' &> /dev/null); then
STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_UNSTAGED" STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_UNSTAGED"
fi fi
@ -25,7 +25,7 @@ function my_git_prompt() {
fi fi
# is anything unmerged? # is anything unmerged?
if $(echo "$INDEX" | grep -E -e '^(A[AU]|D[DU]|U[ADU]) ' &> /dev/null); then if $(echo "$INDEX" | command grep -E -e '^(A[AU]|D[DU]|U[ADU]) ' &> /dev/null); then
STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_UNMERGED" STATUS="$STATUS$ZSH_THEME_GIT_PROMPT_UNMERGED"
fi fi

View File

@ -4,7 +4,7 @@
function hg_prompt_info { function hg_prompt_info {
hg prompt --angle-brackets "\ hg prompt --angle-brackets "\
<hg:%{$fg[magenta]%}<branch>%{$reset_color%}>\ <hg:%{$fg[magenta]%}<branch>%{$reset_color%}><:%{$fg[magenta]%}<bookmark>%{$reset_color%}>\
</%{$fg[yellow]%}<tags|%{$reset_color%}, %{$fg[yellow]%}>%{$reset_color%}>\ </%{$fg[yellow]%}<tags|%{$reset_color%}, %{$fg[yellow]%}>%{$reset_color%}>\
%{$fg[red]%}<status|modified|unknown><update>%{$reset_color%}< %{$fg[red]%}<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 patches: <patches|join( → )|pre_applied(%{$fg[yellow]%})|post_applied(%{$reset_color%})|pre_unapplied(%{$fg_bold[black]%})|post_unapplied(%{$reset_color%})>>" 2>/dev/null

View File

@ -22,8 +22,6 @@ if [[ -z "$epoch_target" ]]; then
epoch_target=13 epoch_target=13
fi fi
[ -f ~/.profile ] && source ~/.profile
# Cancel upgrade if the current user doesn't have write permissions for the # Cancel upgrade if the current user doesn't have write permissions for the
# oh-my-zsh directory. # oh-my-zsh directory.
[[ -w "$ZSH" ]] || return 0 [[ -w "$ZSH" ]] || return 0