From 092ba6eb6d472bba476e167f82c0e393684689c9 Mon Sep 17 00:00:00 2001 From: Joerg Jaspert Date: Fri, 22 Mar 2013 20:39:38 +0100 Subject: [PATCH] make zrecompile optional --- .zsh/.zshrc | 38 ++++++++++++++++++++++++-------------- .zsh/zshenv.local.sample | 5 +++++ 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/.zsh/.zshrc b/.zsh/.zshrc index 9596022..55637a5 100644 --- a/.zsh/.zshrc +++ b/.zsh/.zshrc @@ -9,20 +9,30 @@ # Base directory for all plugins, themes, functions, whatever ZSH=${HOME}/.zsh -debug () -{ - [[ "${DEBUG}" = "no" ]] && return - msg=${1:-""} - nl=${2:-""} - echo ${nl} "${msg}$reset_color" -} +if [[ ${DEBUG} != no ]]; then + debug () { + [[ "${DEBUG}" = "no" ]] && return + msg=${1:-""} + nl=${2:-""} + echo ${nl} "${msg}$reset_color" + } +else + debug () {} + # May want to use colors in log output... + autoload -U colors && colors +fi -# May want to use colors in log output... -[[ "${DEBUG}" = "no" ]] && autoload -U colors && colors debug "Starting zsh" -autoload -Uz zrecompile -zrecompile -q -p -R ${ZDOTDIR}/.zshrc -- -M ${ZDOTDIR}/var/.zcompdump +if zstyle -T ':ganneff:config' zrecompile; then + autoload -Uz zrecompile + zrecompile -q -p -R ${ZDOTDIR}/.zshrc -- -M ${ZDOTDIR}/var/.zcompdump + maybe_compile () { + zrecompile -q -p -U -R ${1} + } +else + maybe_compile () {} +fi # Idea copied from https://github.com/hugues/zdotdir/blob/master/zshrc # AUTHOR: Hugues Hiegel @@ -31,7 +41,7 @@ if [ -d ${ZDOTDIR} ]; then for script in ${ZDOTDIR}/??_*.zsh; do lscript=${script:t:r} debug "Loading ${lscript/??_/}... " -n - zrecompile -q -p -U -R ${script} + maybe_compile ${script} source $script debug "$fg_no_bold[green]done" for i in "net:$DOMAIN" \ @@ -65,14 +75,14 @@ if [ -d ${ZDOTDIR} ]; then #debug "Checking $specific_script... " if [ -r ${specific_script} ]; then debug "Loading $i/${${specific_script:t:r}/??_/}... " -n - zrecompile -q -p -U -R ${specific_script} + maybe_compile ${specific_script} source ${specific_script} debug "$fg_no_bold[green]done" fi done if [[ -f ${ZDOTDIR}/${lscript}.zsh.local ]]; then debug "Loading local ${lscript/??_/}... " -n - zrecompile -q -p -U -R ${lscript}.zsh.local + maybe_compile ${lscript}.zsh.local source ${script}.local debug "$fg_no_bold[green]done" fi diff --git a/.zsh/zshenv.local.sample b/.zsh/zshenv.local.sample index 3768f63..5732e69 100644 --- a/.zsh/zshenv.local.sample +++ b/.zsh/zshenv.local.sample @@ -46,6 +46,11 @@ lmanpath=( ## The format of login/logout reports # zstyle ':ganneff:config' WATCHFMT '%n %a %l from %m at %t.' +## Do you want to have zsh compile your startup files? +## It may make it faster. It may make it slower. Check yourself. +## This uses zrecompile, so changed files are automagically detected +# zstyle ':ganneff:config' zrecompile false + ## The two variables COLORS and LINEDRAW, by default, are set according ## to the capabilities of your terminal. COLORS if it supports colors ## (tput colors > 0), ## LINEDRAW, who would have thought, if it can -- 2.20.1