[Fix #202] Load modules all or nothing

main
Sorin Ionescu 12 years ago
parent 4d86e9c591
commit 060d9064f8

@ -34,27 +34,27 @@ function autoloadable {
function omodload {
local -a omodules
local omodule
local ofunction_glob='^([_.]*|prompt_*_setup|README*)(.N:t)'
# $argv is overridden in the anonymous function.
omodules=("$argv[@]")
# Add functions to $fpath.
fpath=(${omodules:+${OMZ}/modules/${^omodules}/functions(/FN)} $fpath)
function {
local ofunction
# Extended globbing is needed for listing autoloadable function directories.
setopt LOCAL_OPTIONS EXTENDED_GLOB
# Add functions to fpath.
fpath=(${omodules:+${OMZ}/modules/${^omodules}/functions(/FN)} $fpath)
# Load Oh My Zsh functions.
for ofunction in \
$OMZ/modules/${^omodules}/functions/^([_.]*|prompt_*_setup|README*)(.N:t)
do
for ofunction in $OMZ/modules/${^omodules}/functions/$~ofunction_glob; do
autoload -Uz "$ofunction"
done
}
# Load Oh My Zsh modules.
for omodule in "$omodules[@]"; do
if zstyle -t ":omz:module:$omodule" loaded; then
continue
@ -69,6 +69,22 @@ function omodload {
if (( $? == 0 )); then
zstyle ":omz:module:$omodule" loaded 'yes'
else
# Remove the $fpath entry.
fpath[(r)$OMZ/modules/${omodule}/functions]=()
function {
local ofunction
# Extended globbing is needed for listing autoloadable function
# directories.
setopt LOCAL_OPTIONS EXTENDED_GLOB
# Unload Oh My Zsh functions.
for ofunction in $OMZ/modules/$omodule/functions/$~ofunction_glob; do
unfunction "$ofunction"
done
}
zstyle ":omz:module:$omodule" loaded 'no'
fi
fi

@ -5,7 +5,10 @@
# Joseph Jon Booker <joe@neoturbine.net>
#
if [[ -s '/etc/zsh_command_not_found' ]]; then
source '/etc/zsh_command_not_found'
# Return if requirements are not found.
if [[ ! -s '/etc/zsh_command_not_found' ]]; then
return 1
fi
source '/etc/zsh_command_not_found'

@ -6,7 +6,7 @@
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
# Dumb terminals lack support.
# Return if requirements are not found.
if [[ "$TERM" == 'dumb' ]]; then
return 1
fi

@ -7,6 +7,11 @@
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
# Return if requirements are not found.
if (( ! $+commands[dpkg] && ! $+commands[apt-get] )); then
return 1
fi
# Aliases
# Cleans the cache.

@ -40,7 +40,7 @@
# zstyle ':omz:module:editor' completing '...'
#
# Dumb terminals lack support.
# Return if requirements are not found.
if [[ "$TERM" == 'dumb' ]]; then
return 1
fi

@ -5,6 +5,11 @@
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
# Return if requirements are not found.
if (( ! $+commands[git] )); then
return 1
fi
# Source module files.
source "${0:h}/alias.zsh"
source "${0:h}/hub.zsh"

@ -8,7 +8,7 @@
# Get the prefix or use the default.
zstyle -s ':omz:module:gnu-utility' prefix '_gnu_utility_p' || _gnu_utility_p='g'
# Check for the presence of GNU Core Utilities.
# Return if requirements are not found.
if (( ! ${+commands[${_gnu_utility_p}whoami]} )); then
return 1
fi

@ -6,6 +6,7 @@
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
# Return if requirements are not found.
if (( ! $+commands[gpg-agent] )); then
return 1
fi

@ -5,6 +5,11 @@
# Sebastian Wiesner <lunaryorn@googlemail.com>
#
# Return if requirements are not found.
if (( ! $+commands[ghc] )); then
return 1
fi
# Prepend Cabal per user directories to PATH/MANPATH.
if [[ "$OSTYPE" == darwin* ]]; then
path=($HOME/Library/Haskell/bin(/N) $path)

@ -6,7 +6,7 @@
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
# This module is for Mac OS X only.
# Return if requirements are not found.
if [[ "$OSTYPE" != darwin* ]]; then
return 1
fi

@ -5,18 +5,22 @@
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
if (( ! $+commands[npm] )); then
# Return if requirements are not found.
if (( ! $+commands[node] )); then
return 1
fi
cache_file="${0:h}/cache.zsh"
# Load NPM completion.
if (( $+commands[npm] )); then
cache_file="${0:h}/cache.zsh"
if [[ "$commands[npm]" -nt "$cache_file" || ! -s "$cache_file" ]]; then
# npm is slow; cache its output.
npm completion >! "$cache_file" 2> /dev/null
fi
if [[ "$commands[npm]" -nt "$cache_file" || ! -s "$cache_file" ]]; then
# npm is slow; cache its output.
npm completion >! "$cache_file" 2> /dev/null
fi
source "$cache_file"
source "$cache_file"
unset cache_file
unset cache_file
fi

@ -5,7 +5,7 @@
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
# This module is for Mac OS X only.
# Return if requirements are not found.
if [[ "$OSTYPE" != darwin* ]]; then
return 1
fi

@ -9,6 +9,11 @@
# https://wiki.archlinux.org/index.php/Pacman_Tips
#
# Return if requirements are not found.
if (( ! $+commands[pacman] )); then
return 1
fi
# Get the Pacman frontend.
zstyle -s ':omz:module:pacman' frontend '_pacman_frontend'

@ -5,6 +5,11 @@
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
# Return if requirements are not found.
if (( ! $+commands[perl] )); then
return 1
fi
if [[ "$OSTYPE" == darwin* ]]; then
# Perl is slow; cache its output.
cache_file="${0:h}/cache.zsh"

@ -6,6 +6,11 @@
# Sebastian Wiesner <lunaryorn@googlemail.com>
#
# Return if requirements are not found.
if (( ! $+commands[python] )); then
return 1
fi
# Prepend PEP 370 per user site packages directory, which defaults to
# ~/Library/Python on Mac OS X and ~/.local elsewhere, to PATH/MANPATH.
if [[ "$OSTYPE" == darwin* ]]; then

@ -7,6 +7,11 @@
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
# Return if requirements are not found.
if (( ! $+commands[rails] )); then
return 1
fi
# Aliases (Compatible with Rails 2)
alias rc='_rails-command console'
alias rdc='_rails-command dbconsole'

@ -5,6 +5,11 @@
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
# Return if requirements are not found.
if (( ! $+commands[rsync] )); then
return 1
fi
# Aliases
_rsync_cmd='rsync --verbose --progress --human-readable --compress --archive --hard-links --one-file-system'

@ -5,6 +5,11 @@
# Authors: Sorin Ionescu <sorin.ionescu@gmail.com>
#
# Return if requirements are not found.
if (( ! $+commands[ruby] )); then
return 1
fi
# Load RVM into the shell session.
if [[ -s "$HOME/.rvm/scripts/rvm" ]]; then
# Unset AUTO_NAME_DIRS since auto adding variable-stored paths to ~ list
@ -34,16 +39,18 @@ fi
# Aliases
# Bundler
alias b='bundle'
alias be='b exec'
alias bi='b install --path vendor/bundle'
alias bl='b list'
alias bo='b open'
alias bp='b package'
alias bu='b update'
alias bI='bi \
&& b package \
&& print .bundle >>! .gitignore \
&& print vendor/bundle >>! .gitignore \
&& print vendor/cache >>! .gitignore'
if (( $+commands[bundle] )); then
alias b='bundle'
alias be='b exec'
alias bi='b install --path vendor/bundle'
alias bl='b list'
alias bo='b open'
alias bp='b package'
alias bu='b update'
alias bI='bi \
&& b package \
&& print .bundle >>! .gitignore \
&& print vendor/bundle >>! .gitignore \
&& print vendor/cache >>! .gitignore'
fi

@ -5,6 +5,11 @@
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
# Return if requirements are not found.
if (( ! $+commands[screen] )); then
return 1
fi
# Auto Start
if [[ -z "$STY" ]] && zstyle -t ':omz:module:screen' auto-start; then
session="$(

@ -6,6 +6,11 @@
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
# Return if requirements are not found.
if [[ "$TERM" == 'dumb' ]]; then
return 1
fi
typeset -gA FX FG BG
FX=(

@ -11,6 +11,7 @@
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
# Return if requirements are not found.
if (( ! $+commands[ssh-agent] )); then
return 1
fi

@ -5,13 +5,16 @@
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
if zstyle -t ':omz:module:syntax-highlighting' color; then
source "${0:h}/external/zsh-syntax-highlighting.zsh"
# Return if requirements are not found.
if ! zstyle -t ':omz:module:syntax-highlighting' color; then
return 1
fi
source "${0:h}/external/zsh-syntax-highlighting.zsh"
# Set the highlighters.
zstyle -a ':omz:module:syntax-highlighting' highlighters 'ZSH_HIGHLIGHT_HIGHLIGHTERS'
if (( ${#ZSH_HIGHLIGHT_HIGHLIGHTERS[@]} == 0 )); then
ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets cursor)
fi
# Set the highlighters.
zstyle -a ':omz:module:syntax-highlighting' highlighters 'ZSH_HIGHLIGHT_HIGHLIGHTERS'
if (( ${#ZSH_HIGHLIGHT_HIGHLIGHTERS[@]} == 0 )); then
ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets cursor)
fi

@ -6,7 +6,7 @@
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
# Dumb terminals lack support.
# Return if requirements are not found.
if [[ "$TERM" == 'dumb' ]]; then
return 1
fi

@ -6,6 +6,11 @@
# Colin Hebert <hebert.colin@gmail.com>
#
# Return if requirements are not found.
if (( ! $+commands[tmux] )); then
return 1
fi
# Auto Start
if [[ -z "$TMUX" ]] && zstyle -t ':omz:module:tmux' auto-start; then
tmux_session='#OMZ'

@ -6,6 +6,11 @@
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
# Return if requirements are not found.
if (( ! $+commands[yum] )); then
return 1
fi
# Aliases
alias yumc='sudo yum clean all' # Cleans the cache.
alias yumh='yum history' # Displays history.

@ -23,15 +23,18 @@ done
unset _z_prefix{es,} _z_sh
if (( $+functions[_z] )); then
function _z-precmd {
_z --add "${PWD:A}"
}
# Return if requirements are not found.
if (( ! $+functions[_z] )); then
return 1
fi
autoload -Uz add-zsh-hook
add-zsh-hook precmd _z-precmd
function _z-precmd {
_z --add "${PWD:A}"
}
alias z='nocorrect _z'
alias j='nocorrect _z'
fi
autoload -Uz add-zsh-hook
add-zsh-hook precmd _z-precmd
alias z='nocorrect _z'
alias j='nocorrect _z'

Loading…
Cancel
Save