diff options
-rw-r--r-- | lib/history.zsh | 9 | ||||
-rw-r--r-- | lib/nvm.zsh | 2 | ||||
-rw-r--r-- | plugins/autojump/autojump.plugin.zsh | 2 | ||||
-rw-r--r-- | plugins/aws/aws.plugin.zsh | 7 | ||||
-rw-r--r-- | plugins/brew/_brew | 38 | ||||
-rw-r--r-- | plugins/chruby/chruby.plugin.zsh | 6 | ||||
-rw-r--r-- | plugins/docker/_docker | 12 | ||||
-rw-r--r-- | plugins/heroku/_heroku | 32 | ||||
-rw-r--r-- | plugins/tmux/tmux.plugin.zsh | 2 | ||||
-rw-r--r-- | plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh | 92 | ||||
-rw-r--r-- | plugins/web-search/web-search.plugin.zsh | 3 | ||||
-rw-r--r-- | plugins/xcode/xcode.plugin.zsh | 1 | ||||
-rw-r--r-- | plugins/yii2/README.md | 7 | ||||
-rw-r--r-- | plugins/yii2/yii2.plugin.zsh | 29 | ||||
-rw-r--r-- | tools/check_for_upgrade.sh | 2 |
15 files changed, 133 insertions, 111 deletions
diff --git a/lib/history.zsh b/lib/history.zsh index 179c22848..e78a98e9e 100644 --- a/lib/history.zsh +++ b/lib/history.zsh @@ -2,12 +2,9 @@ if [ -z "$HISTFILE" ]; then HISTFILE=$HOME/.zsh_history fi -if [ -z "$HISTSIZE" ]; then - HISTSIZE=10000 -fi -if [ -z "$SAVEHIST" ]; then - SAVEHIST=10000 -fi + +HISTSIZE=10000 +SAVEHIST=10000 setopt extended_history setopt hist_expire_dups_first diff --git a/lib/nvm.zsh b/lib/nvm.zsh index 5cadf7061..61d997fc0 100644 --- a/lib/nvm.zsh +++ b/lib/nvm.zsh @@ -1,6 +1,6 @@ # get the node.js version function nvm_prompt_info() { - [ -f $HOME/.nvm/nvm.sh ] || return + [ -f "$HOME/.nvm/nvm.sh" ] || return local nvm_prompt nvm_prompt=$(node -v 2>/dev/null) [[ "${nvm_prompt}x" == "x" ]] && return diff --git a/plugins/autojump/autojump.plugin.zsh b/plugins/autojump/autojump.plugin.zsh index 652d22696..4cf036401 100644 --- a/plugins/autojump/autojump.plugin.zsh +++ b/plugins/autojump/autojump.plugin.zsh @@ -1,6 +1,8 @@ if [ $commands[autojump] ]; then # check if autojump is installed if [ -f $HOME/.autojump/etc/profile.d/autojump.zsh ]; then # manual user-local installation . $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 . $HOME/.nix-profile/etc/profile.d/autojump.zsh elif [ -f /usr/share/autojump/autojump.zsh ]; then # debian and ubuntu package diff --git a/plugins/aws/aws.plugin.zsh b/plugins/aws/aws.plugin.zsh index de786725f..0ae18dd56 100644 --- a/plugins/aws/aws.plugin.zsh +++ b/plugins/aws/aws.plugin.zsh @@ -22,7 +22,10 @@ function aws_profiles { compctl -K aws_profiles asp 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 - source `which aws_zsh_completer.sh` + _aws_zsh_completer_path=$(which aws_zsh_completer.sh) fi + +[ -x $_aws_zsh_completer_path ] && source $_aws_zsh_completer_path +unset _aws_zsh_completer_path diff --git a/plugins/brew/_brew b/plugins/brew/_brew index 40442a1d3..d11aa245d 100644 --- a/plugins/brew/_brew +++ b/plugins/brew/_brew @@ -19,21 +19,18 @@ _brew_outdated_formulae() { outdated_formulae=(`brew outdated`) } -_brew_running_services() { - running_services=(`brew services list | awk '{print $1}'`) -} - local -a _1st_arguments _1st_arguments=( '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' 'cleanup:uninstall unused and old versions of packages' 'commands:show a list of commands' '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' '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' 'info:information about a formula' 'install:install a formula' @@ -44,32 +41,24 @@ _1st_arguments=( 'missing:check all installed formuale for missing dependencies.' 'outdated:list formulae for which a newer version is available' 'pin:pin specified formulae' + 'postinstall:perform post_install for a given formula' 'prune:remove dead links' 'remove:remove a formula' 'search:search for a formula (/regex/ or string)' - 'server:start a local web app that lets you browse formulae (requires Sinatra)' - 'services:small wrapper around `launchctl` for supported formulae' + 'switch:switch linkage between installed versions of a formula' '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' 'unlink:unlink a formula' 'unpin:unpin specified formulae' 'untap:remove a tapped repository' - 'update:freshen up links' + 'update:pull latest repository' 'upgrade:upgrade outdated formulae' '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 -a formulae installed_formulae installed_taps outdated_formulae running_services +local -a formulae installed_formulae installed_taps outdated_formulae _arguments \ '(-v)-v[verbose]' \ @@ -80,6 +69,7 @@ _arguments \ '(--version)--version[version information]' \ '(--prefix)--prefix[where brew lives on this system]' \ '(--cache)--cache[brew cache]' \ + '(--force)--force[brew force]' \ '*:: :->subcmds' && return 0 if (( CURRENT == 1 )); then @@ -109,16 +99,6 @@ case "$words[1]" in _arguments \ '(--macports)--macports[search the macports 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) _brew_installed_taps _wanted installed_taps expl 'installed taps' compadd -a installed_tapsĀ ;; diff --git a/plugins/chruby/chruby.plugin.zsh b/plugins/chruby/chruby.plugin.zsh index 2a2c80cf6..b461b0c9b 100644 --- a/plugins/chruby/chruby.plugin.zsh +++ b/plugins/chruby/chruby.plugin.zsh @@ -24,7 +24,7 @@ _homebrew-installed() { } _chruby-from-homebrew-installed() { - brew --prefix chruby &> /dev/null + [ -r $(brew --prefix chruby)] &> /dev/null } _ruby-build_installed() { @@ -45,11 +45,11 @@ _source_from_omz_settings() { zstyle -s :omz:plugins:chruby path _chruby_path 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} fi - if _chruby_auto && [[ -r _chruby_auto ]]; then + if ${_chruby_auto} && [[ -r ${_chruby_auto} ]]; then source ${_chruby_auto} fi } diff --git a/plugins/docker/_docker b/plugins/docker/_docker index 28568a6e5..880b6faa6 100644 --- a/plugins/docker/_docker +++ b/plugins/docker/_docker @@ -4,6 +4,7 @@ # Requires: Docker installed # Author: Azaan (@aeonazaan) # Updates: Bob Maerten (@bobmaerten) for Docker v0.9+ +# Paul van den Berg (@bergvandenp) for Docker v1.3+ # ----- Helper functions @@ -238,6 +239,14 @@ __wait() { __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 --------- # ---------------------- @@ -276,6 +285,7 @@ _1st_arguments=( "top":"Lookup the running processes of a container" "version":"Show the docker version information" "wait":"Block until a container stops, then print its exit code" + "exec":"Run a task inside a running container" ) _arguments '*:: :->command' @@ -353,4 +363,6 @@ case "$words[1]" in __version ;; wait) __wait ;; + exec) + __exec ;; esac diff --git a/plugins/heroku/_heroku b/plugins/heroku/_heroku index 46663303a..bb2f7403f 100644 --- a/plugins/heroku/_heroku +++ b/plugins/heroku/_heroku @@ -27,8 +27,6 @@ _1st_arguments=( "config\:push":"push local config vars to heroku" "config\:set":"set 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\:add":"add a custom domain to an app" "domains\:remove":"remove a custom domain from an app" @@ -43,12 +41,20 @@ _1st_arguments=( "logs\:drains":"manage syslog drains" "maintenance\:on":"put the app into 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\: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\:ps":"view active queries with execution time" "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\: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" "pgbackups":"list captured backups" "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]' \ ) ;; - 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) _command_args=( '(-l|--long)'{-l,--long}'[display extended information for each key]' \ diff --git a/plugins/tmux/tmux.plugin.zsh b/plugins/tmux/tmux.plugin.zsh index 626c41f3d..bc32c8907 100644 --- a/plugins/tmux/tmux.plugin.zsh +++ b/plugins/tmux/tmux.plugin.zsh @@ -5,6 +5,8 @@ alias ta='tmux attach -t' alias ts='tmux new-session -s' alias tl='tmux list-sessions' +alias tksv='tmux kill-server' +alias tkss='tmux kill-session -t' # Only run if tmux is actually installed if which tmux &> /dev/null diff --git a/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh b/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh index f58bda1ad..52e02d3e0 100644 --- a/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh +++ b/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh @@ -1,57 +1,63 @@ virtualenvwrapper='virtualenvwrapper.sh' if (( $+commands[$virtualenvwrapper] )); then + source ${${virtualenvwrapper}:c} - if [[ ! $DISABLE_VENV_CD -eq 1 ]]; then - # Automatically activate Git projects's virtual environments based on the - # directory name of the project. Virtual environment name can be overridden - # by placing a .venv file in the project root with a virtualenv name in it - function workon_cwd { + 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 + # Automatically activate Git projects's virtual environments based on the + # directory name of the project. Virtual environment name can be overridden + # by placing a .venv file in the project root with a virtualenv name in it + function workon_cwd { if [ ! $WORKON_CWD ]; then - WORKON_CWD=1 - # Check if this is a Git repo - PROJECT_ROOT=`git rev-parse --show-toplevel 2> /dev/null` - if (( $? != 0 )); then - PROJECT_ROOT="." - fi - # Check for virtualenv name override - if [[ -f "$PROJECT_ROOT/.venv" ]]; then - ENV_NAME=`cat "$PROJECT_ROOT/.venv"` - elif [[ -f "$PROJECT_ROOT/.venv/bin/activate" ]];then - ENV_NAME="$PROJECT_ROOT/.venv" - elif [[ "$PROJECT_ROOT" != "." ]]; then - ENV_NAME=`basename "$PROJECT_ROOT"` - else - ENV_NAME="" - fi - if [[ "$ENV_NAME" != "" ]]; then - # Activate the environment only if it is not already active - if [[ "$VIRTUAL_ENV" != "$WORKON_HOME/$ENV_NAME" ]]; then - if [[ -e "$WORKON_HOME/$ENV_NAME/bin/activate" ]]; then - workon "$ENV_NAME" && export CD_VIRTUAL_ENV="$ENV_NAME" - elif [[ -e "$ENV_NAME/bin/activate" ]]; then - source $ENV_NAME/bin/activate && export CD_VIRTUAL_ENV="$ENV_NAME" - fi - fi - elif [ $CD_VIRTUAL_ENV ]; then - # We've just left the repo, deactivate the environment - # Note: this only happens if the virtualenv was activated automatically - deactivate && unset CD_VIRTUAL_ENV + WORKON_CWD=1 + # Check if this is a Git repo + PROJECT_ROOT=`git rev-parse --show-toplevel 2> /dev/null` + if (( $? != 0 )); then + PROJECT_ROOT="." + fi + # Check for virtualenv name override + if [[ -f "$PROJECT_ROOT/.venv" ]]; then + ENV_NAME=`cat "$PROJECT_ROOT/.venv"` + elif [[ -f "$PROJECT_ROOT/.venv/bin/activate" ]];then + ENV_NAME="$PROJECT_ROOT/.venv" + elif [[ "$PROJECT_ROOT" != "." ]]; then + ENV_NAME=`basename "$PROJECT_ROOT"` + else + ENV_NAME="" + fi + if [[ "$ENV_NAME" != "" ]]; then + # Activate the environment only if it is not already active + if [[ "$VIRTUAL_ENV" != "$WORKON_HOME/$ENV_NAME" ]]; then + if [[ -e "$WORKON_HOME/$ENV_NAME/bin/activate" ]]; then + workon "$ENV_NAME" && export CD_VIRTUAL_ENV="$ENV_NAME" + elif [[ -e "$ENV_NAME/bin/activate" ]]; then + source $ENV_NAME/bin/activate && export CD_VIRTUAL_ENV="$ENV_NAME" + fi fi - unset PROJECT_ROOT - unset WORKON_CWD + elif [ $CD_VIRTUAL_ENV ]; then + # We've just left the repo, deactivate the environment + # Note: this only happens if the virtualenv was activated automatically + deactivate && unset CD_VIRTUAL_ENV + fi + unset PROJECT_ROOT + unset WORKON_CWD fi - } + } - # Append workon_cwd to the chpwd_functions array, so it will be called on cd - # http://zsh.sourceforge.net/Doc/Release/Functions.html - # TODO: replace with 'add-zsh-hook chpwd workon_cwd' when oh-my-zsh min version is raised above 4.3.4 - if (( ${+chpwd_functions} )); then + # Append workon_cwd to the chpwd_functions array, so it will be called on cd + # http://zsh.sourceforge.net/Doc/Release/Functions.html + # TODO: replace with 'add-zsh-hook chpwd workon_cwd' when oh-my-zsh min version is raised above 4.3.4 + if (( ${+chpwd_functions} )); then if (( $chpwd_functions[(I)workon_cwd] == 0 )); then - set -A chpwd_functions $chpwd_functions workon_cwd + set -A chpwd_functions $chpwd_functions workon_cwd fi - else + else set -A chpwd_functions workon_cwd + fi fi fi else diff --git a/plugins/web-search/web-search.plugin.zsh b/plugins/web-search/web-search.plugin.zsh index 371e3a303..28559deb9 100644 --- a/plugins/web-search/web-search.plugin.zsh +++ b/plugins/web-search/web-search.plugin.zsh @@ -37,8 +37,7 @@ function web_search() { done url="${url%?}" # remove the last '+' - nohup $open_cmd "$url" - rm nohup.out + nohup $open_cmd "$url" >/dev/null 2&>1 } diff --git a/plugins/xcode/xcode.plugin.zsh b/plugins/xcode/xcode.plugin.zsh index b7b75cf93..1d1205b80 100644 --- a/plugins/xcode/xcode.plugin.zsh +++ b/plugins/xcode/xcode.plugin.zsh @@ -16,6 +16,7 @@ function xcsel { alias xcb='xcodebuild' 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 alias simulator='open $(xcode-select -p)/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app' diff --git a/plugins/yii2/README.md b/plugins/yii2/README.md new file mode 100644 index 000000000..345b66eb6 --- /dev/null +++ b/plugins/yii2/README.md @@ -0,0 +1,7 @@ +# Yii2 autocomplete plugin + +* Adds autocomplete commands and subcommands for yii. + +## Requirements + +Autocomplete works from directory where your `yii` file contains. diff --git a/plugins/yii2/yii2.plugin.zsh b/plugins/yii2/yii2.plugin.zsh new file mode 100644 index 000000000..e8993adf4 --- /dev/null +++ b/plugins/yii2/yii2.plugin.zsh @@ -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
\ No newline at end of file diff --git a/tools/check_for_upgrade.sh b/tools/check_for_upgrade.sh index 4a0803210..b2b356e0c 100644 --- a/tools/check_for_upgrade.sh +++ b/tools/check_for_upgrade.sh @@ -22,8 +22,6 @@ if [[ -z "$epoch_target" ]]; then epoch_target=13 fi -[ -f ~/.profile ] && source ~/.profile - # Cancel upgrade if the current user doesn't have write permissions for the # oh-my-zsh directory. [[ -w "$ZSH" ]] || return 0 |