From 1cb064898fb29bda13eb020e46a005bb8426a2f6 Mon Sep 17 00:00:00 2001 From: Ben O'Hara Date: Sun, 17 Jun 2012 14:33:13 +1000 Subject: [PATCH 1/7] Check minimum required zsh version in modules and dont return from the main init --- init.zsh | 3 +-- modules/editor/init.zsh | 7 +++++++ modules/history-substring-search/init.zsh | 7 +++++++ modules/syntax-highlighting/init.zsh | 7 +++++++ modules/terminal/init.zsh | 7 +++++++ 5 files changed, 29 insertions(+), 2 deletions(-) diff --git a/init.zsh b/init.zsh index 9b466450..d663b572 100644 --- a/init.zsh +++ b/init.zsh @@ -7,10 +7,9 @@ # # Check for the minimum supported version. -min_zsh_version='4.3.10' +min_zsh_version='4.2.6' if ! autoload -Uz is-at-least || ! is-at-least "$min_zsh_version"; then print "omz: old shell detected, minimum required: $min_zsh_version" >&2 - return 1 fi unset min_zsh_version diff --git a/modules/editor/init.zsh b/modules/editor/init.zsh index 0fbd5711..bdeb9bdd 100644 --- a/modules/editor/init.zsh +++ b/modules/editor/init.zsh @@ -40,6 +40,13 @@ # zstyle ':omz:module:editor' completing '...' # +# Check for the minimum supported version. +min_zsh_version='4.3.10' +if ! autoload -Uz is-at-least || ! is-at-least "$min_zsh_version"; then + return 1 +fi +unset min_zsh_version + # Dumb terminals lack support. if [[ "$TERM" == 'dumb' ]]; then return 1 diff --git a/modules/history-substring-search/init.zsh b/modules/history-substring-search/init.zsh index a0ff287f..66fc0349 100644 --- a/modules/history-substring-search/init.zsh +++ b/modules/history-substring-search/init.zsh @@ -6,6 +6,13 @@ # Sorin Ionescu # +# Check for the minimum supported version. +min_zsh_version='4.3.10' +if ! autoload -Uz is-at-least || ! is-at-least "$min_zsh_version"; then + return 1 +fi +unset min_zsh_version + source "${0:h}/external/zsh-history-substring-search.zsh" if zstyle -t ':omz:module:history-substring-search' case-sensitive; then diff --git a/modules/syntax-highlighting/init.zsh b/modules/syntax-highlighting/init.zsh index 88ec7b47..297955db 100644 --- a/modules/syntax-highlighting/init.zsh +++ b/modules/syntax-highlighting/init.zsh @@ -5,6 +5,13 @@ # Sorin Ionescu # +# Check for the minimum supported version. +min_zsh_version='4.3.10' +if ! autoload -Uz is-at-least || ! is-at-least "$min_zsh_version"; then + return 1 +fi +unset min_zsh_version + if zstyle -t ':omz:module:syntax-highlighting' color; then source "${0:h}/external/zsh-syntax-highlighting.zsh" diff --git a/modules/terminal/init.zsh b/modules/terminal/init.zsh index d0bab0b7..b27e9b2b 100644 --- a/modules/terminal/init.zsh +++ b/modules/terminal/init.zsh @@ -6,6 +6,13 @@ # Sorin Ionescu # +# Check for the minimum supported version. +min_zsh_version='4.3.10' +if ! autoload -Uz is-at-least || ! is-at-least "$min_zsh_version"; then + return 1 +fi +unset min_zsh_version + # Dumb terminals lack support. if [[ "$TERM" == 'dumb' ]]; then return 1 From 0aa4cf91e1c07a2271b03a3bccb2f1748f552e93 Mon Sep 17 00:00:00 2001 From: Ben O'Hara Date: Sun, 17 Jun 2012 14:40:29 +1000 Subject: [PATCH 2/7] group-directories-first was introduced in coreutils 6 --- modules/utility/init.zsh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/utility/init.zsh b/modules/utility/init.zsh index 53b618d4..2e58c8e0 100644 --- a/modules/utility/init.zsh +++ b/modules/utility/init.zsh @@ -56,7 +56,9 @@ alias type='type -a' # ls if is-callable 'dircolors'; then # GNU Core Utilities - alias ls='ls --group-directories-first' + if [[ `dircolors --version |head -1 |awk '{print $NF}'` > 6 ]]; then + alias ls='ls --group-directories-first' + fi if zstyle -t ':omz:module:utility:ls' color; then if [[ -s "$HOME/.dir_colors" ]]; then From ce93ba5d20a41cdcf203f6ce518f0a4874176182 Mon Sep 17 00:00:00 2001 From: Ben O'Hara Date: Sun, 17 Jun 2012 14:41:03 +1000 Subject: [PATCH 3/7] Exit the module if the required commands arnt installed so aliases arnt set that wont work --- modules/git/init.zsh | 4 ++++ modules/rsync/init.zsh | 4 ++++ modules/screen/init.zsh | 4 ++++ modules/tmux/init.zsh | 4 ++++ 4 files changed, 16 insertions(+) diff --git a/modules/git/init.zsh b/modules/git/init.zsh index e3c3ac84..cf15851e 100644 --- a/modules/git/init.zsh +++ b/modules/git/init.zsh @@ -5,6 +5,10 @@ # Sorin Ionescu # +if (( ! $+commands[git] )); then + return 1 +fi + # Source module files. source "${0:h}/alias.zsh" source "${0:h}/hub.zsh" diff --git a/modules/rsync/init.zsh b/modules/rsync/init.zsh index e0f866a8..2117e20e 100644 --- a/modules/rsync/init.zsh +++ b/modules/rsync/init.zsh @@ -5,6 +5,10 @@ # Sorin Ionescu # +if (( ! $+commands[rsync] )); then + return 1 +fi + # Aliases _rsync_cmd='rsync --verbose --progress --human-readable --compress --archive --hard-links --one-file-system' diff --git a/modules/screen/init.zsh b/modules/screen/init.zsh index 8c0f1d57..f1275495 100644 --- a/modules/screen/init.zsh +++ b/modules/screen/init.zsh @@ -5,6 +5,10 @@ # Sorin Ionescu # +if (( ! $+commands[screen] )); then + return 1 +fi + # Aliases alias sl="screen -list" alias sn="screen -U -S" diff --git a/modules/tmux/init.zsh b/modules/tmux/init.zsh index c066ea98..7d3b266e 100644 --- a/modules/tmux/init.zsh +++ b/modules/tmux/init.zsh @@ -6,6 +6,10 @@ # Colin Hebert # +if (( ! $+commands[tmux] )); then + return 1 +fi + # Aliases alias ta="tmux attach-session" alias tl="tmux list-sessions" From 2a0a7b30616ef1fe820652391055df6dd4144284 Mon Sep 17 00:00:00 2001 From: Ben O'Hara Date: Sun, 17 Jun 2012 14:53:14 +1000 Subject: [PATCH 4/7] dont load the prompt module if older zsh version --- modules/prompt/init.zsh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/modules/prompt/init.zsh b/modules/prompt/init.zsh index a92eb233..749d706f 100644 --- a/modules/prompt/init.zsh +++ b/modules/prompt/init.zsh @@ -8,6 +8,13 @@ # Load and execute the prompt theming system. autoload -Uz promptinit && promptinit +# Check for the minimum supported version. +min_zsh_version='4.3.10' +if ! autoload -Uz is-at-least || ! is-at-least "$min_zsh_version"; then + return 1 +fi +unset min_zsh_version + # Load the prompt theme. zstyle -a ':omz:module:prompt' theme 'prompt_argv' if (( $#prompt_argv > 0 )); then From c6bc0845e9517c32921fd34a74903f161a5269db Mon Sep 17 00:00:00 2001 From: Ben O'Hara Date: Sun, 17 Jun 2012 14:58:48 +1000 Subject: [PATCH 5/7] Fixes loading the functions under older zsh versions --- helper.zsh | 27 +++++++++++---------------- modules/prompt/init.zsh | 7 ------- 2 files changed, 11 insertions(+), 23 deletions(-) diff --git a/helper.zsh b/helper.zsh index 7c960b20..e6515abc 100644 --- a/helper.zsh +++ b/helper.zsh @@ -38,22 +38,8 @@ function omodload { # $argv is overridden in the anonymous function. omodules=("$argv[@]") - 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 - autoload -Uz "$ofunction" - done - } + # Extended globbing is needed for listing autoloadable function directories. + setopt LOCAL_OPTIONS EXTENDED_GLOB for omodule in "$omodules[@]"; do if zstyle -t ":omz:module:$omodule" loaded; then @@ -68,6 +54,15 @@ function omodload { if (( $? == 0 )); then zstyle ":omz:module:$omodule" loaded 'yes' + # 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 + autoload -Uz "$ofunction" + done else zstyle ":omz:module:$omodule" loaded 'no' fi diff --git a/modules/prompt/init.zsh b/modules/prompt/init.zsh index 749d706f..a92eb233 100644 --- a/modules/prompt/init.zsh +++ b/modules/prompt/init.zsh @@ -8,13 +8,6 @@ # Load and execute the prompt theming system. autoload -Uz promptinit && promptinit -# Check for the minimum supported version. -min_zsh_version='4.3.10' -if ! autoload -Uz is-at-least || ! is-at-least "$min_zsh_version"; then - return 1 -fi -unset min_zsh_version - # Load the prompt theme. zstyle -a ':omz:module:prompt' theme 'prompt_argv' if (( $#prompt_argv > 0 )); then From 7936a18d7f439b1ed28aceca8fd073dbb49192cc Mon Sep 17 00:00:00 2001 From: Ben O'Hara Date: Sun, 17 Jun 2012 15:24:34 +1000 Subject: [PATCH 6/7] omodule not omodules --- helper.zsh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/helper.zsh b/helper.zsh index e6515abc..79322fc5 100644 --- a/helper.zsh +++ b/helper.zsh @@ -55,11 +55,11 @@ function omodload { if (( $? == 0 )); then zstyle ":omz:module:$omodule" loaded 'yes' # Add functions to fpath. - fpath=(${omodules:+${OMZ}/modules/${^omodules}/functions(/FN)} $fpath) + fpath=(${omodule:+${OMZ}/modules/${^omodule}/functions(/FN)} $fpath) # Load Oh My Zsh functions. for ofunction in \ - $OMZ/modules/${^omodules}/functions/^([_.]*|prompt_*_setup|README*)(.N:t) + $OMZ/modules/${^omodule}/functions/^([_.]*|prompt_*_setup|README*)(.N:t) do autoload -Uz "$ofunction" done From 1b869f8e6a0a326e0f709b86cfd1d2eca66d8cd9 Mon Sep 17 00:00:00 2001 From: Ben O'Hara Date: Sun, 17 Jun 2012 16:26:41 +1000 Subject: [PATCH 7/7] omodules --- helper.zsh | 4 ++-- modules/completion/functions | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/helper.zsh b/helper.zsh index 79322fc5..e6515abc 100644 --- a/helper.zsh +++ b/helper.zsh @@ -55,11 +55,11 @@ function omodload { if (( $? == 0 )); then zstyle ":omz:module:$omodule" loaded 'yes' # Add functions to fpath. - fpath=(${omodule:+${OMZ}/modules/${^omodule}/functions(/FN)} $fpath) + fpath=(${omodules:+${OMZ}/modules/${^omodules}/functions(/FN)} $fpath) # Load Oh My Zsh functions. for ofunction in \ - $OMZ/modules/${^omodule}/functions/^([_.]*|prompt_*_setup|README*)(.N:t) + $OMZ/modules/${^omodules}/functions/^([_.]*|prompt_*_setup|README*)(.N:t) do autoload -Uz "$ofunction" done diff --git a/modules/completion/functions b/modules/completion/functions index 8b89dd9d..39e26ca0 160000 --- a/modules/completion/functions +++ b/modules/completion/functions @@ -1 +1 @@ -Subproject commit 8b89dd9d10e86313f49fafdf88e8540f97346f33 +Subproject commit 39e26ca01fabcaa6f20d4638f56f9866a82f2b1f