From 6f92745761afc000b54bd782c7f3bcc0733302f7 Mon Sep 17 00:00:00 2001 From: Cenk Alti Date: Sat, 25 Aug 2012 09:51:58 +0300 Subject: [PATCH 1/7] Added another path for virtualenvwrapper plugin MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When you install python via brew on OSX, pip is installed into /usr/local/share/python/ and all packages installed with this pip are installed here. --- plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh b/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh index 5d0860400..8506624b5 100644 --- a/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh +++ b/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh @@ -1,5 +1,5 @@ WRAPPER_FOUND=0 -for wrapsource in "/usr/bin/virtualenvwrapper.sh" "/usr/local/bin/virtualenvwrapper.sh" "/etc/bash_completion.d/virtualenvwrapper" ; do +for wrapsource in "/usr/bin/virtualenvwrapper.sh" "/usr/local/bin/virtualenvwrapper.sh" "/usr/local/share/python/virtualenvwrapper.sh" "/etc/bash_completion.d/virtualenvwrapper" ; do if [[ -e $wrapsource ]] ; then WRAPPER_FOUND=1 source $wrapsource From d5e5b7ee5adaf74afa96cae00260c50581d8f46f Mon Sep 17 00:00:00 2001 From: Cenk Alti Date: Sat, 25 Aug 2012 10:26:00 +0300 Subject: [PATCH 2/7] search virtualenvwrapper.sh in PATH --- .../virtualenvwrapper.plugin.zsh | 76 +++++++++---------- 1 file changed, 35 insertions(+), 41 deletions(-) diff --git a/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh b/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh index 8506624b5..a5abb77c3 100644 --- a/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh +++ b/plugins/virtualenvwrapper/virtualenvwrapper.plugin.zsh @@ -1,46 +1,40 @@ -WRAPPER_FOUND=0 -for wrapsource in "/usr/bin/virtualenvwrapper.sh" "/usr/local/bin/virtualenvwrapper.sh" "/usr/local/share/python/virtualenvwrapper.sh" "/etc/bash_completion.d/virtualenvwrapper" ; do - if [[ -e $wrapsource ]] ; then - WRAPPER_FOUND=1 - source $wrapsource +wrapsource=`which virtualenvwrapper.sh` - if [[ ! $DISABLE_VENV_CD -eq 1 ]]; then - # Automatically activate Git projects' 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 { - # Check that this is a Git repo - PROJECT_ROOT=`git rev-parse --show-toplevel 2> /dev/null` - if (( $? == 0 )); then - # Check for virtualenv name override - ENV_NAME=`basename "$PROJECT_ROOT"` - if [[ -f "$PROJECT_ROOT/.venv" ]]; then - ENV_NAME=`cat "$PROJECT_ROOT/.venv"` - fi - # 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" - 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 - fi - unset PROJECT_ROOT - } +if [[ -f "$wrapsource" ]]; then + source $wrapsource - # New cd function that does the virtualenv magic - function cd { - builtin cd "$@" && workon_cwd - } - fi + if [[ ! $DISABLE_VENV_CD -eq 1 ]]; then + # Automatically activate Git projects' 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 { + # Check that this is a Git repo + PROJECT_ROOT=`git rev-parse --show-toplevel 2> /dev/null` + if (( $? == 0 )); then + # Check for virtualenv name override + ENV_NAME=`basename "$PROJECT_ROOT"` + if [[ -f "$PROJECT_ROOT/.venv" ]]; then + ENV_NAME=`cat "$PROJECT_ROOT/.venv"` + fi + # 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" + 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 + fi + unset PROJECT_ROOT + } - break + # New cd function that does the virtualenv magic + function cd { + builtin cd "$@" && workon_cwd + } fi -done - -if [ $WRAPPER_FOUND -eq 0 ] ; then - print "zsh virtualenvwrapper plugin: Couldn't activate virtualenvwrapper. Please run \`pip install virtualenvwrapper\`." +else + print "zsh virtualenvwrapper plugin: Cannot find virtualenvwrapper.sh. Please install with \`pip install virtualenvwrapper\`." fi From 28d3b80db1d5d976a809bc01da191be5b1768fcb Mon Sep 17 00:00:00 2001 From: Xavier Lacoste Date: Thu, 30 Aug 2012 16:25:36 +0200 Subject: [PATCH 3/7] Add empty function rbenv_prompt_info() if doesn't exists --- themes/jonathan.zsh-theme | 2 ++ 1 file changed, 2 insertions(+) diff --git a/themes/jonathan.zsh-theme b/themes/jonathan.zsh-theme index 2f0c4b917..9f0f30271 100644 --- a/themes/jonathan.zsh-theme +++ b/themes/jonathan.zsh-theme @@ -1,3 +1,5 @@ +functions rbenv_prompt_info >& /dev/null || rbenv_prompt_info(){} + function theme_precmd { local TERMWIDTH (( TERMWIDTH = ${COLUMNS} - 1 )) From 2643ac975bff9513753b6e3d99a34164e48955f7 Mon Sep 17 00:00:00 2001 From: Nicholas Hutchinson Date: Sun, 2 Sep 2012 10:38:08 +1200 Subject: [PATCH 4/7] Update fishy theme to collapse working directory in PROMPT. For non-trailing path components, we show only the first character. So, as in Fish proper, we convert ~/some/really/really/really/long/path/name to ~/s/r/r/r/l/p/name. --- themes/fishy.zsh-theme | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/themes/fishy.zsh-theme b/themes/fishy.zsh-theme index f9e506cae..e9f78a54e 100644 --- a/themes/fishy.zsh-theme +++ b/themes/fishy.zsh-theme @@ -1,7 +1,11 @@ # ZSH Theme emulating the Fish shell's default prompt. +_fishy_collapsed_wd() { + echo $(pwd | perl -pe "s|^$HOME|~|g; s|/([^/])[^/]*(?=/)|/\$1|g") +} + local user_color='green'; [ $UID -eq 0 ] && user_color='red' -PROMPT='%n@%m %{$fg[$user_color]%}%~%{$reset_color%}%(!.#.>) ' +PROMPT='%n@%m %{$fg[$user_color]%}$(_fishy_collapsed_wd)%{$reset_color%}%(!.#.>) ' PROMPT2='%{$fg[red]%}\ %{$reset_color%}' local return_status="%{$fg_bold[red]%}%(?..%?)%{$reset_color%}" From fa859f90d2ba91be36c77520b1a23442c55d9cfe Mon Sep 17 00:00:00 2001 From: Ben Cao Date: Mon, 3 Sep 2012 11:51:28 +0800 Subject: [PATCH 5/7] fix rvm auto complete, pointing to $rvm_path --- plugins/rvm/_rvm | 147 ------------------------------------- plugins/rvm/rvm.plugin.zsh | 7 +- 2 files changed, 6 insertions(+), 148 deletions(-) delete mode 100644 plugins/rvm/_rvm diff --git a/plugins/rvm/_rvm b/plugins/rvm/_rvm deleted file mode 100644 index bba5304a0..000000000 --- a/plugins/rvm/_rvm +++ /dev/null @@ -1,147 +0,0 @@ -#compdef rvm - -local curcontext="$curcontext" state line cmds ret=1 - -_arguments -C \ - '(- 1 *)'{-v,--version}'[display version information]' \ - '(-l|--level)'{-l,--level}'+[patch level to use with rvm use / install]:number' \ - '(--prefix)--prefix[path for all rvm files (~/.rvm/), with trailing slash!]:path:_files' \ - '(--bin)--bin[path for binaries to be placed (~/.rvm/bin/)]:path:_files' \ - '(--source)--source[src directory to use (~/.rvm/src/)]:path:_files' \ - '(--archives)--archives[directory for downladed files (~/.rvm/archives/)]:path:_files' \ - '-S[Specify a script file to attempt to load and run (rubydo)]:file:_files' \ - '-e[Execute code from the command line]:code' \ - '(-G)-G[root gem path to use]:path:_files' \ - '(--gems)--gems[Used to set the gems_flag, use with remove to remove gems]' \ - '(--archive)--archive[Used to set the archive_flag, use with remove to remove archive]' \ - '(--patch)--patch[With MRI Rubies you may specify one or more full paths to patches]' \ - '(-C|--configure)'{-C,--configure}'=[custom configure options]' \ - '(--nice)--nice[process niceness (for slow computers, default 0)]:number' \ - '(--ree)--ree-options[Options passed directly to ree ./installer on the command line]:options' \ - '(--head)--head[with update, updates rvm to git head version]' \ - '(--rubygems)--rubygems[with update, updates rubygems for selected ruby]' \ - '(--default)--default[with ruby select, sets a default ruby for new shells]' \ - '(--debug)--debug[Toggle debug mode on for very verbose output]' \ - '(--trace)--trace[Toggle trace mode on to see EVERYTHING rvm is doing]' \ - '(--force)--force[Force install, removes old install & source before install]' \ - '(--summary)--summary[Used with rubydo to print out a summary of the commands run]' \ - '(--latest)--latest[with gemset --dump skips version strings for latest gem]' \ - '(--gems)--gems[with uninstall/remove removes gems with the interpreter]' \ - '(--docs)--docs[with install, attempt to generate ri after installation]' \ - '(--reconfigure)--reconfigure[Force ./configure on install even if Makefile already exists]' \ - '1: :->cmds' \ - '*: :->args' && ret=0 - -case $state in - cmds) - cmds=( - "version:show the rvm version installed in rvm_path" - "use:setup current shell to use a specific ruby version" - "reload:reload rvm source itself (useful after changing rvm source)" - "implode:(seppuku) removes the rvm installation completely. This means everything in $rvm_path (~/.rvm)." - "update:upgrades rvm to the latest version." - "reset:remove current and stored default & system settings." - "info :show the *current* environment information for current ruby" - "current:print the *current* ruby version and the name of any gemset being used." - "debug:show info plus additional information for common issues" - "install:install one or many ruby versions" - "uninstall:uninstall one or many ruby versions, leaves their sources" - "remove:uninstall one or many ruby versions and remove their sources" - "migrate:Lets you migrate all gemsets from one ruby to another." - "upgrade:Lets you upgrade from one version of a ruby to another, including migrating your gemsets semi-automatically." - "wrapper:generates a set of wrapper executables for a given ruby with the specified ruby and gemset combination. Used under the hood for passenger support and the like." - "cleanup:Lets you remove stale source folders / archives and other miscellaneous data associated with rvm." - "repair:Lets you repair parts of your environment e.g. wrappers, env files and and similar files (e.g. general maintenance)." - "snapshot:Lets your backup / restore an rvm installation in a lightweight manner." - "disk-usage:Tells you how much disk space rvm install is using." - "tools:Provides general information about the ruby environment, primarily useful when scripting rvm." - "docs:Tools to make installing ri and rdoc documentation easier." - "rvmrc:Tools related to managing rvmrc trust and loading." - "exec:runs an arbitrary command as a set operation." - "ruby:runs a named ruby file against specified and/or all rubies" - "gem:runs a gem command using selected ruby's 'gem'" - "rake:runs a rake task against specified and/or all rubies" - "tests:runs 'rake test' across selected ruby versions" - "specs:runs 'rake spec' across selected ruby versions" - "monitor:Monitor cwd for testing, run rake {spec,test} on changes." - "gemset:gemsets: http://rvm.beginrescueend.com/gemsets/" - "rubygems:Switches the installed version of rubygems for the current ruby." - "gemdir:display the path to the current gem directory (GEM_HOME)." - "srcdir:display the path to rvm source directory (may be yanked)" - "fetch:Performs an archive / src fetch only of the selected ruby." - "list:show currently installed rubies, interactive output." - "package:Install a dependency package {readline,iconv,zlib,openssl}" - "notes:Display notes, with operating system specifics." - "export:Temporarily set an environment variable in the current shell." - "unexport:Undo changes made to the environment by 'rvm export'." - ) - _describe -t commands 'rvm command' cmds && ret=0 - ;; - args) - case $line[1] in - (use|uninstall|remove|list) - _values -S , 'rubies' $(rvm list strings | sed -e 's/ruby-\([^) ]*\)-\([^) ]*\)/ruby-\1-\2 \1-\2 \1/g') default system && ret=0 - ;; - (install|fetch) - _values -S , 'rubies' $(rvm list known_strings) && ret=0 - ;; - gemset) - if (( CURRENT == 3 )); then - _values 'gemset_commands' \ - 'import' \ - 'export' \ - 'create' \ - 'copy' \ - 'rename' \ - 'empty' \ - 'delete' \ - 'name' \ - 'dir' \ - 'list' \ - 'list_all' \ - 'gemdir' \ - 'install' \ - 'pristine' \ - 'clear' \ - 'use' \ - 'update' \ - 'unpack' \ - 'globalcache' - else - _values -S , 'gemsets' $(rvm gemset list | grep -v gemset 2>/dev/null) - fi - ret=0 - ;; - package) - if (( CURRENT == 3 )); then - _values 'package_commands' \ - 'install' \ - 'uninstall' - else - _values 'packages' \ - 'readline' \ - 'iconv' \ - 'curl' \ - 'openssl' \ - 'zlib' \ - 'autoconf' \ - 'ncurses' \ - 'pkgconfig' \ - 'gettext' \ - 'glib' \ - 'mono' \ - 'llvm' \ - 'libxml2' \ - 'libxslt' \ - 'libyaml' - fi - ret=0 - ;; - *) - (( ret )) && _message 'no more arguments' - ;; - esac - ;; -esac - -return ret diff --git a/plugins/rvm/rvm.plugin.zsh b/plugins/rvm/rvm.plugin.zsh index 604c00713..e0c58ebda 100644 --- a/plugins/rvm/rvm.plugin.zsh +++ b/plugins/rvm/rvm.plugin.zsh @@ -2,7 +2,7 @@ alias rubies='rvm list rubies' alias gemsets='rvm gemset list' local ruby18='ruby-1.8.7-p334' -local ruby19='ruby-1.9.2-p180' +local ruby19='ruby-1.9.3-p194' function rb18 { if [ -z "$1" ]; then @@ -42,3 +42,8 @@ function gems { -Ee "s/$current_ruby@global/$fg[yellow]&$reset_color/g" \ -Ee "s/$current_ruby$current_gemset$/$fg[green]&$reset_color/g" } + +function _rvm_completion { + source $rvm_path"/scripts/zsh/Completion/_rvm" +} +compdef _rvm_completion rvm From 5e0fd9bb9f8f11da1d7562f5e867a28706accb57 Mon Sep 17 00:00:00 2001 From: Martin Foot Date: Wed, 26 Sep 2012 14:16:15 +0100 Subject: [PATCH 6/7] Add user-local installation autojump zsh plugin source If you manually install autojump as advised by the autojump README by running the install.sh script, it will install by default to $HOME/.autojump. Add an extra case in the zsh autojump plugin to find the new file and stop a syntax error in the else clause every time a new zsh starts (running brew when brew does not exist). --- plugins/autojump/autojump.plugin.zsh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/autojump/autojump.plugin.zsh b/plugins/autojump/autojump.plugin.zsh index d367863b8..ca0090560 100644 --- a/plugins/autojump/autojump.plugin.zsh +++ b/plugins/autojump/autojump.plugin.zsh @@ -3,6 +3,8 @@ if [ $commands[autojump] ]; then # check if autojump is installed . /usr/share/autojump/autojump.zsh elif [ -f /etc/profile.d/autojump.zsh ]; then # manual installation . /etc/profile.d/autojump.zsh + elif [ -f $HOME/.autojump/etc/profile.d/autojump.zsh ]; then # manual user-local installation + . $HOME/.autojump/etc/profile.d/autojump.zsh elif [ -f /opt/local/etc/profile.d/autojump.zsh ]; then # mac os x with ports . /opt/local/etc/profile.d/autojump.zsh elif [ $commands[brew] -a -f `brew --prefix`/etc/autojump ]; then # mac os x with brew From 263446d7259e22a21fe797284607fd2423fb076b Mon Sep 17 00:00:00 2001 From: Hok Shun Poon Date: Tue, 30 Oct 2012 22:42:52 +0000 Subject: [PATCH 7/7] Expand for-loop so that it works under Snow Leopard Terminal.app. --- oh-my-zsh.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/oh-my-zsh.sh b/oh-my-zsh.sh index ddef1ad6c..4a5b175d5 100644 --- a/oh-my-zsh.sh +++ b/oh-my-zsh.sh @@ -11,7 +11,9 @@ fpath=($ZSH/functions $ZSH/completions $fpath) # Load all of the config files in ~/oh-my-zsh that end in .zsh # TIP: Add files you don't want in git to .gitignore -for config_file ($ZSH/lib/*.zsh) source $config_file +for config_file ($ZSH/lib/*.zsh); do + source $config_file +done # Set ZSH_CUSTOM to the path where your custom config files # and plugins exists, or else we will use the default custom/ @@ -51,7 +53,9 @@ for plugin ($plugins); do done # Load all of your custom configurations from custom/ -for config_file ($ZSH_CUSTOM/*.zsh(N)) source $config_file +for config_file ($ZSH_CUSTOM/*.zsh(N)); do + source $config_file +done # Load the theme if [ "$ZSH_THEME" = "random" ]