From 8cdf06e3861d0eee9023e07d0d1e3fed23e38b2b Mon Sep 17 00:00:00 2001 From: Sorin Ionescu Date: Mon, 3 Sep 2012 16:13:53 -0400 Subject: [PATCH] [#255] Use $ZDOTDIR or $HOME --- helper.zsh | 14 +++++++------- init.zsh | 5 +++++ modules/completion/init.zsh | 2 +- modules/history/init.zsh | 2 +- runcoms/zlogin | 2 +- runcoms/zshenv | 4 ---- runcoms/zshrc | 4 +++- 7 files changed, 18 insertions(+), 15 deletions(-) diff --git a/helper.zsh b/helper.zsh index 0682d25..7581873 100644 --- a/helper.zsh +++ b/helper.zsh @@ -40,7 +40,7 @@ function pmodload { pmodules=("$argv[@]") # Add functions to $fpath. - fpath=(${pmodules:+${PREZTO}/modules/${^pmodules}/functions(/FN)} $fpath) + fpath=(${pmodules:+${ZDOTDIR:-$HOME}/.zprezto/modules/${^pmodules}/functions(/FN)} $fpath) function { local pfunction @@ -49,7 +49,7 @@ function pmodload { setopt LOCAL_OPTIONS EXTENDED_GLOB # Load Prezto functions. - for pfunction in $PREZTO/modules/${^pmodules}/functions/$~pfunction_glob; do + for pfunction in ${ZDOTDIR:-$HOME}/.zprezto/modules/${^pmodules}/functions/$~pfunction_glob; do autoload -Uz "$pfunction" done } @@ -58,19 +58,19 @@ function pmodload { for pmodule in "$pmodules[@]"; do if zstyle -t ":prezto:module:$pmodule" loaded; then continue - elif [[ ! -d "$PREZTO/modules/$pmodule" ]]; then + elif [[ ! -d "${ZDOTDIR:-$HOME}/.zprezto/modules/$pmodule" ]]; then print "$0: no such module: $pmodule" >&2 continue else - if [[ -s "$PREZTO/modules/$pmodule/init.zsh" ]]; then - source "$PREZTO/modules/$pmodule/init.zsh" + if [[ -s "${ZDOTDIR:-$HOME}/.zprezto/modules/$pmodule/init.zsh" ]]; then + source "${ZDOTDIR:-$HOME}/.zprezto/modules/$pmodule/init.zsh" fi if (( $? == 0 )); then zstyle ":prezto:module:$pmodule" loaded 'yes' else # Remove the $fpath entry. - fpath[(r)$PREZTO/modules/${pmodule}/functions]=() + fpath[(r)${ZDOTDIR:-$HOME}/.zprezto/modules/${pmodule}/functions]=() function { local pfunction @@ -80,7 +80,7 @@ function pmodload { setopt LOCAL_OPTIONS EXTENDED_GLOB # Unload Prezto functions. - for pfunction in $PREZTO/modules/$pmodule/functions/$~pfunction_glob; do + for pfunction in ${ZDOTDIR:-$HOME}/.zprezto/modules/$pmodule/functions/$~pfunction_glob; do unfunction "$pfunction" done } diff --git a/init.zsh b/init.zsh index 7e74bbd..87609d0 100644 --- a/init.zsh +++ b/init.zsh @@ -13,6 +13,11 @@ if ! autoload -Uz is-at-least || ! is-at-least "$min_zsh_version"; then fi unset min_zsh_version +# Source the Prezto configuration file. +if [[ -s "${ZDOTDIR:-$HOME}/.zpreztorc" ]]; then + source "${ZDOTDIR:-$HOME}/.zpreztorc" +fi + # Disable color and theme in dumb terminals. if [[ "$TERM" == 'dumb' ]]; then zstyle ':prezto:*:*' color 'no' diff --git a/modules/completion/init.zsh b/modules/completion/init.zsh index 9b214a0..de59a5d 100644 --- a/modules/completion/init.zsh +++ b/modules/completion/init.zsh @@ -39,7 +39,7 @@ WORDCHARS='*?_-.[]~&;!#$%^(){}<>' # Use caching to make completion for cammands such as dpkg and apt usable. zstyle ':completion::complete:*' use-cache on -zstyle ':completion::complete:*' cache-path "$HOME/.zcompcache" +zstyle ':completion::complete:*' cache-path "${ZDOTDIR:-$HOME}/.zcompcache" # Case-insensitive (all), partial-word, and then substring completion. if zstyle -t ':prezto:module:completion:*' case-sensitive; then diff --git a/modules/history/init.zsh b/modules/history/init.zsh index b774e13..e23fb8b 100644 --- a/modules/history/init.zsh +++ b/modules/history/init.zsh @@ -10,7 +10,7 @@ # Variables # -HISTFILE="$HOME/.zhistory" # The path to the history file. +HISTFILE="${ZDOTDIR:-$HOME}/.zhistory" # The path to the history file. HISTSIZE=10000 # The maximum number of events to save in the internal history. SAVEHIST=10000 # The maximum number of events to save in the history file. diff --git a/runcoms/zlogin b/runcoms/zlogin index 35a8b35..9e31577 100644 --- a/runcoms/zlogin +++ b/runcoms/zlogin @@ -8,7 +8,7 @@ # Execute code that does not affect the current session in the background. { # Compile the completion dump to increase startup speed. - zcompdump="$HOME/.zcompdump" + zcompdump="${ZDOTDIR:-$HOME}/.zcompdump" if [[ "$zcompdump" -nt "${zcompdump}.zwc" || ! -s "${zcompdump}.zwc" ]]; then zcompile "$zcompdump" fi diff --git a/runcoms/zshenv b/runcoms/zshenv index d23533b..5e6c58b 100644 --- a/runcoms/zshenv +++ b/runcoms/zshenv @@ -5,10 +5,6 @@ # Sorin Ionescu # -# Set the path to Prezto. -export ZDOTDIR="${ZDOTDIR:-$HOME}" -export PREZTO="$ZDOTDIR/.zprezto" - # # Browser # diff --git a/runcoms/zshrc b/runcoms/zshrc index 0f869eb..f646f6c 100644 --- a/runcoms/zshrc +++ b/runcoms/zshrc @@ -45,7 +45,9 @@ zstyle ':prezto:load' pmodule \ zstyle ':prezto:module:prompt' theme 'sorin' # Source Prezto. -source "$PREZTO/init.zsh" +if [[ -s "${ZDOTDIR:-$HOME}/.zprezto/init.zsh" ]]; then + source "${ZDOTDIR:-$HOME}/.zprezto/init.zsh" +fi # Customize to your needs...