[Fix #202] Load modules all or nothing
This commit is contained in:
parent
4d86e9c591
commit
060d9064f8
28
helper.zsh
28
helper.zsh
@ -34,27 +34,27 @@ function autoloadable {
|
|||||||
function omodload {
|
function omodload {
|
||||||
local -a omodules
|
local -a omodules
|
||||||
local omodule
|
local omodule
|
||||||
|
local ofunction_glob='^([_.]*|prompt_*_setup|README*)(.N:t)'
|
||||||
|
|
||||||
# $argv is overridden in the anonymous function.
|
# $argv is overridden in the anonymous function.
|
||||||
omodules=("$argv[@]")
|
omodules=("$argv[@]")
|
||||||
|
|
||||||
|
# Add functions to $fpath.
|
||||||
|
fpath=(${omodules:+${OMZ}/modules/${^omodules}/functions(/FN)} $fpath)
|
||||||
|
|
||||||
function {
|
function {
|
||||||
local ofunction
|
local ofunction
|
||||||
|
|
||||||
# Extended globbing is needed for listing autoloadable function directories.
|
# Extended globbing is needed for listing autoloadable function directories.
|
||||||
setopt LOCAL_OPTIONS EXTENDED_GLOB
|
setopt LOCAL_OPTIONS EXTENDED_GLOB
|
||||||
|
|
||||||
# Add functions to fpath.
|
|
||||||
fpath=(${omodules:+${OMZ}/modules/${^omodules}/functions(/FN)} $fpath)
|
|
||||||
|
|
||||||
# Load Oh My Zsh functions.
|
# Load Oh My Zsh functions.
|
||||||
for ofunction in \
|
for ofunction in $OMZ/modules/${^omodules}/functions/$~ofunction_glob; do
|
||||||
$OMZ/modules/${^omodules}/functions/^([_.]*|prompt_*_setup|README*)(.N:t)
|
|
||||||
do
|
|
||||||
autoload -Uz "$ofunction"
|
autoload -Uz "$ofunction"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Load Oh My Zsh modules.
|
||||||
for omodule in "$omodules[@]"; do
|
for omodule in "$omodules[@]"; do
|
||||||
if zstyle -t ":omz:module:$omodule" loaded; then
|
if zstyle -t ":omz:module:$omodule" loaded; then
|
||||||
continue
|
continue
|
||||||
@ -69,6 +69,22 @@ function omodload {
|
|||||||
if (( $? == 0 )); then
|
if (( $? == 0 )); then
|
||||||
zstyle ":omz:module:$omodule" loaded 'yes'
|
zstyle ":omz:module:$omodule" loaded 'yes'
|
||||||
else
|
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'
|
zstyle ":omz:module:$omodule" loaded 'no'
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -5,7 +5,10 @@
|
|||||||
# Joseph Jon Booker <joe@neoturbine.net>
|
# Joseph Jon Booker <joe@neoturbine.net>
|
||||||
#
|
#
|
||||||
|
|
||||||
if [[ -s '/etc/zsh_command_not_found' ]]; then
|
# Return if requirements are not found.
|
||||||
source '/etc/zsh_command_not_found'
|
if [[ ! -s '/etc/zsh_command_not_found' ]]; then
|
||||||
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
source '/etc/zsh_command_not_found'
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||||
#
|
#
|
||||||
|
|
||||||
# Dumb terminals lack support.
|
# Return if requirements are not found.
|
||||||
if [[ "$TERM" == 'dumb' ]]; then
|
if [[ "$TERM" == 'dumb' ]]; then
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
@ -7,6 +7,11 @@
|
|||||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||||
#
|
#
|
||||||
|
|
||||||
|
# Return if requirements are not found.
|
||||||
|
if (( ! $+commands[dpkg] && ! $+commands[apt-get] )); then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
# Aliases
|
# Aliases
|
||||||
|
|
||||||
# Cleans the cache.
|
# Cleans the cache.
|
||||||
|
@ -40,7 +40,7 @@
|
|||||||
# zstyle ':omz:module:editor' completing '...'
|
# zstyle ':omz:module:editor' completing '...'
|
||||||
#
|
#
|
||||||
|
|
||||||
# Dumb terminals lack support.
|
# Return if requirements are not found.
|
||||||
if [[ "$TERM" == 'dumb' ]]; then
|
if [[ "$TERM" == 'dumb' ]]; then
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
@ -5,6 +5,11 @@
|
|||||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||||
#
|
#
|
||||||
|
|
||||||
|
# Return if requirements are not found.
|
||||||
|
if (( ! $+commands[git] )); then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
# Source module files.
|
# Source module files.
|
||||||
source "${0:h}/alias.zsh"
|
source "${0:h}/alias.zsh"
|
||||||
source "${0:h}/hub.zsh"
|
source "${0:h}/hub.zsh"
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
# Get the prefix or use the default.
|
# Get the prefix or use the default.
|
||||||
zstyle -s ':omz:module:gnu-utility' prefix '_gnu_utility_p' || _gnu_utility_p='g'
|
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
|
if (( ! ${+commands[${_gnu_utility_p}whoami]} )); then
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||||
#
|
#
|
||||||
|
|
||||||
|
# Return if requirements are not found.
|
||||||
if (( ! $+commands[gpg-agent] )); then
|
if (( ! $+commands[gpg-agent] )); then
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
@ -5,6 +5,11 @@
|
|||||||
# Sebastian Wiesner <lunaryorn@googlemail.com>
|
# 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.
|
# Prepend Cabal per user directories to PATH/MANPATH.
|
||||||
if [[ "$OSTYPE" == darwin* ]]; then
|
if [[ "$OSTYPE" == darwin* ]]; then
|
||||||
path=($HOME/Library/Haskell/bin(/N) $path)
|
path=($HOME/Library/Haskell/bin(/N) $path)
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||||
#
|
#
|
||||||
|
|
||||||
# This module is for Mac OS X only.
|
# Return if requirements are not found.
|
||||||
if [[ "$OSTYPE" != darwin* ]]; then
|
if [[ "$OSTYPE" != darwin* ]]; then
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
@ -5,10 +5,13 @@
|
|||||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||||
#
|
#
|
||||||
|
|
||||||
if (( ! $+commands[npm] )); then
|
# Return if requirements are not found.
|
||||||
|
if (( ! $+commands[node] )); then
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Load NPM completion.
|
||||||
|
if (( $+commands[npm] )); then
|
||||||
cache_file="${0:h}/cache.zsh"
|
cache_file="${0:h}/cache.zsh"
|
||||||
|
|
||||||
if [[ "$commands[npm]" -nt "$cache_file" || ! -s "$cache_file" ]]; then
|
if [[ "$commands[npm]" -nt "$cache_file" || ! -s "$cache_file" ]]; then
|
||||||
@ -19,4 +22,5 @@ fi
|
|||||||
source "$cache_file"
|
source "$cache_file"
|
||||||
|
|
||||||
unset cache_file
|
unset cache_file
|
||||||
|
fi
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||||
#
|
#
|
||||||
|
|
||||||
# This module is for Mac OS X only.
|
# Return if requirements are not found.
|
||||||
if [[ "$OSTYPE" != darwin* ]]; then
|
if [[ "$OSTYPE" != darwin* ]]; then
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
@ -9,6 +9,11 @@
|
|||||||
# https://wiki.archlinux.org/index.php/Pacman_Tips
|
# 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.
|
# Get the Pacman frontend.
|
||||||
zstyle -s ':omz:module:pacman' frontend '_pacman_frontend'
|
zstyle -s ':omz:module:pacman' frontend '_pacman_frontend'
|
||||||
|
|
||||||
|
@ -5,6 +5,11 @@
|
|||||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||||
#
|
#
|
||||||
|
|
||||||
|
# Return if requirements are not found.
|
||||||
|
if (( ! $+commands[perl] )); then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ "$OSTYPE" == darwin* ]]; then
|
if [[ "$OSTYPE" == darwin* ]]; then
|
||||||
# Perl is slow; cache its output.
|
# Perl is slow; cache its output.
|
||||||
cache_file="${0:h}/cache.zsh"
|
cache_file="${0:h}/cache.zsh"
|
||||||
|
@ -6,6 +6,11 @@
|
|||||||
# Sebastian Wiesner <lunaryorn@googlemail.com>
|
# 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
|
# Prepend PEP 370 per user site packages directory, which defaults to
|
||||||
# ~/Library/Python on Mac OS X and ~/.local elsewhere, to PATH/MANPATH.
|
# ~/Library/Python on Mac OS X and ~/.local elsewhere, to PATH/MANPATH.
|
||||||
if [[ "$OSTYPE" == darwin* ]]; then
|
if [[ "$OSTYPE" == darwin* ]]; then
|
||||||
|
@ -7,6 +7,11 @@
|
|||||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||||
#
|
#
|
||||||
|
|
||||||
|
# Return if requirements are not found.
|
||||||
|
if (( ! $+commands[rails] )); then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
# Aliases (Compatible with Rails 2)
|
# Aliases (Compatible with Rails 2)
|
||||||
alias rc='_rails-command console'
|
alias rc='_rails-command console'
|
||||||
alias rdc='_rails-command dbconsole'
|
alias rdc='_rails-command dbconsole'
|
||||||
|
@ -5,6 +5,11 @@
|
|||||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||||
#
|
#
|
||||||
|
|
||||||
|
# Return if requirements are not found.
|
||||||
|
if (( ! $+commands[rsync] )); then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
# Aliases
|
# Aliases
|
||||||
_rsync_cmd='rsync --verbose --progress --human-readable --compress --archive --hard-links --one-file-system'
|
_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>
|
# 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.
|
# Load RVM into the shell session.
|
||||||
if [[ -s "$HOME/.rvm/scripts/rvm" ]]; then
|
if [[ -s "$HOME/.rvm/scripts/rvm" ]]; then
|
||||||
# Unset AUTO_NAME_DIRS since auto adding variable-stored paths to ~ list
|
# Unset AUTO_NAME_DIRS since auto adding variable-stored paths to ~ list
|
||||||
@ -34,6 +39,7 @@ fi
|
|||||||
# Aliases
|
# Aliases
|
||||||
|
|
||||||
# Bundler
|
# Bundler
|
||||||
|
if (( $+commands[bundle] )); then
|
||||||
alias b='bundle'
|
alias b='bundle'
|
||||||
alias be='b exec'
|
alias be='b exec'
|
||||||
alias bi='b install --path vendor/bundle'
|
alias bi='b install --path vendor/bundle'
|
||||||
@ -46,4 +52,5 @@ alias bI='bi \
|
|||||||
&& print .bundle >>! .gitignore \
|
&& print .bundle >>! .gitignore \
|
||||||
&& print vendor/bundle >>! .gitignore \
|
&& print vendor/bundle >>! .gitignore \
|
||||||
&& print vendor/cache >>! .gitignore'
|
&& print vendor/cache >>! .gitignore'
|
||||||
|
fi
|
||||||
|
|
||||||
|
@ -5,6 +5,11 @@
|
|||||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||||
#
|
#
|
||||||
|
|
||||||
|
# Return if requirements are not found.
|
||||||
|
if (( ! $+commands[screen] )); then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
# Auto Start
|
# Auto Start
|
||||||
if [[ -z "$STY" ]] && zstyle -t ':omz:module:screen' auto-start; then
|
if [[ -z "$STY" ]] && zstyle -t ':omz:module:screen' auto-start; then
|
||||||
session="$(
|
session="$(
|
||||||
|
@ -6,6 +6,11 @@
|
|||||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||||
#
|
#
|
||||||
|
|
||||||
|
# Return if requirements are not found.
|
||||||
|
if [[ "$TERM" == 'dumb' ]]; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
typeset -gA FX FG BG
|
typeset -gA FX FG BG
|
||||||
|
|
||||||
FX=(
|
FX=(
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||||
#
|
#
|
||||||
|
|
||||||
|
# Return if requirements are not found.
|
||||||
if (( ! $+commands[ssh-agent] )); then
|
if (( ! $+commands[ssh-agent] )); then
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
@ -5,7 +5,11 @@
|
|||||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||||
#
|
#
|
||||||
|
|
||||||
if zstyle -t ':omz:module:syntax-highlighting' color; then
|
# 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"
|
source "${0:h}/external/zsh-syntax-highlighting.zsh"
|
||||||
|
|
||||||
# Set the highlighters.
|
# Set the highlighters.
|
||||||
@ -13,5 +17,4 @@ if zstyle -t ':omz:module:syntax-highlighting' color; then
|
|||||||
if (( ${#ZSH_HIGHLIGHT_HIGHLIGHTERS[@]} == 0 )); then
|
if (( ${#ZSH_HIGHLIGHT_HIGHLIGHTERS[@]} == 0 )); then
|
||||||
ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets cursor)
|
ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets cursor)
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||||
#
|
#
|
||||||
|
|
||||||
# Dumb terminals lack support.
|
# Return if requirements are not found.
|
||||||
if [[ "$TERM" == 'dumb' ]]; then
|
if [[ "$TERM" == 'dumb' ]]; then
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
@ -6,6 +6,11 @@
|
|||||||
# Colin Hebert <hebert.colin@gmail.com>
|
# Colin Hebert <hebert.colin@gmail.com>
|
||||||
#
|
#
|
||||||
|
|
||||||
|
# Return if requirements are not found.
|
||||||
|
if (( ! $+commands[tmux] )); then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
# Auto Start
|
# Auto Start
|
||||||
if [[ -z "$TMUX" ]] && zstyle -t ':omz:module:tmux' auto-start; then
|
if [[ -z "$TMUX" ]] && zstyle -t ':omz:module:tmux' auto-start; then
|
||||||
tmux_session='#OMZ'
|
tmux_session='#OMZ'
|
||||||
|
@ -6,6 +6,11 @@
|
|||||||
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
# Sorin Ionescu <sorin.ionescu@gmail.com>
|
||||||
#
|
#
|
||||||
|
|
||||||
|
# Return if requirements are not found.
|
||||||
|
if (( ! $+commands[yum] )); then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
# Aliases
|
# Aliases
|
||||||
alias yumc='sudo yum clean all' # Cleans the cache.
|
alias yumc='sudo yum clean all' # Cleans the cache.
|
||||||
alias yumh='yum history' # Displays history.
|
alias yumh='yum history' # Displays history.
|
||||||
|
@ -23,7 +23,11 @@ done
|
|||||||
|
|
||||||
unset _z_prefix{es,} _z_sh
|
unset _z_prefix{es,} _z_sh
|
||||||
|
|
||||||
if (( $+functions[_z] )); then
|
# Return if requirements are not found.
|
||||||
|
if (( ! $+functions[_z] )); then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
function _z-precmd {
|
function _z-precmd {
|
||||||
_z --add "${PWD:A}"
|
_z --add "${PWD:A}"
|
||||||
}
|
}
|
||||||
@ -33,5 +37,4 @@ if (( $+functions[_z] )); then
|
|||||||
|
|
||||||
alias z='nocorrect _z'
|
alias z='nocorrect _z'
|
||||||
alias j='nocorrect _z'
|
alias j='nocorrect _z'
|
||||||
fi
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user