88# BSD licensed, see LICENSE.txt
99
1010# Clone zgenom if you haven't already
11- if [[ -z " $ ZGENOM_PARENT_DIR" ]]; then
12- ZGENOM_PARENT_DIR=$HOME
13- ZGENOM_SOURCE_FILE=$ZGENOM_PARENT_DIR /.zqs-zgenom/zgenom.zsh
11+ if [[ -z ${ ZGENOM_PARENT_DIR-} ]]; then
12+ ZGENOM_PARENT_DIR=${ZDOTDIR :- $ HOME}
13+ ZGENOM_SOURCE_FILE=" $ZGENOM_PARENT_DIR /.zqs-zgenom/zgenom.zsh"
1414
1515 # Set ZGENOM_SOURCE_FILE to the old directory if it already exists
1616 if [[ -f " $ZGENOM_PARENT_DIR /zgenom/zgenom.zsh" ]] ; then
17- ZGENOM_SOURCE_FILE=$ZGENOM_PARENT_DIR /zgenom/zgenom.zsh
17+ ZGENOM_SOURCE_FILE=" $ZGENOM_PARENT_DIR /zgenom/zgenom.zsh"
1818 fi
1919fi
2020
2121# zgenom stores the clones plugins & themes in $ZGEN_DIR when it
2222# is set. Otherwise it stuffs everything in the source tree, which
2323# is unclean.
24- ZGEN_DIR=${ZGEN_DIR:- $HOME / .zgenom}
24+ ZGEN_DIR=${ZGEN_DIR:- ${ZDOTDIR :- $ HOME} / .zgenom}
2525
2626if [[ ! -f " $ZGENOM_SOURCE_FILE " ]] ; then
2727 if [[ ! -d " $ZGENOM_PARENT_DIR " ]]; then
4242unset ZGENOM_PARENT_DIR ZGENOM_SOURCE_FILE
4343
4444warn-about-prompt-change () {
45- if [[ ! -f ~ /.zsh-quickstart-kit-prompt-switch-warning ]]; then
45+ if [[ ! -f ${ZDOTDIR :- $HOME } /.zsh-quickstart-kit-prompt-switch-warning ]]; then
4646 echo
4747 echo " The default ZSH prompt in the quickstart kit has changed from"
4848 echo " bullet-train to powerlevel10k."
@@ -53,7 +53,7 @@ warn-about-prompt-change() {
5353 echo
5454 echo " If you do nothing, you will be switched to powerlevel10k"
5555 echo
56- touch ~ /.zsh-quickstart-kit-prompt-switch-warning
56+ touch ${ZDOTDIR :- $HOME } /.zsh-quickstart-kit-prompt-switch-warning
5757 fi
5858}
5959
@@ -62,7 +62,7 @@ load-starter-plugin-list() {
6262 ZGEN_LOADED=()
6363 ZGEN_COMPLETIONS=()
6464
65- if [[ ! -f ~ /.zsh-quickstart-no-omz ]] || [[ $( _zqs-get-setting load-omz-plugins true) == ' true' ]]; then
65+ if [[ ! -f ${ZDOTDIR :- $HOME } /.zsh-quickstart-no-omz ]] || [[ $( _zqs-get-setting load-omz-plugins true) == ' true' ]]; then
6666 zgenom oh-my-zsh
6767 fi
6868
@@ -136,15 +136,15 @@ load-starter-plugin-list() {
136136 # in a repository securely by encrypting them with gnupg.
137137 zgenom load StackExchange/blackbox
138138
139- if [[ -f ~ /.zqs-add-plugins ]]; then
140- source ~ /.zqs-add-plugins
139+ if [[ -f ${ZDOTDIR :- $HOME } /.zqs-add-plugins ]]; then
140+ source ${ZDOTDIR :- $HOME } /.zqs-add-plugins
141141 fi
142142
143- if [[ -d ~ /.zshrc.add-plugins.d ]]; then
144- load-shell-fragments ~ /.zshrc.add-plugins.d
143+ if [[ -d ${ZDOTDIR :- $HOME } /.zshrc.add-plugins.d ]]; then
144+ load-shell-fragments ${ZDOTDIR :- $HOME } /.zshrc.add-plugins.d
145145 fi
146146
147- if [[ ! -f ~ /.zsh-quickstart-no-omz ]] || [[ $( _zqs-get-setting load-omz-plugins false) == ' true' ]]; then
147+ if [[ ! -f ${ZDOTDIR :- $HOME } /.zsh-quickstart-no-omz ]] || [[ $( _zqs-get-setting load-omz-plugins false) == ' true' ]]; then
148148 # Load some oh-my-zsh plugins
149149 zgenom oh-my-zsh plugins/pip
150150 zgenom oh-my-zsh plugins/sudo
@@ -184,7 +184,7 @@ load-starter-plugin-list() {
184184 zgenom load unixorn/1password-op.plugin.zsh
185185
186186 # Load me last
187- GENCOMPL_FPATH=$HOME /.zsh/complete
187+ GENCOMPL_FPATH=${ZDOTDIR :- $ HOME} /.zsh/complete
188188
189189 # Very cool plugin that generates zsh completion functions for commands
190190 # if they have getopt-style help text. It doesn't generate them on the fly,
@@ -200,7 +200,7 @@ load-starter-plugin-list() {
200200 zgenom load supercrabtree/k
201201
202202 # Be compatible with the old settings files for now
203- if [[ -f ~ /.zsh-quickstart-use-bullet-train ]] || [[ $( _zqs-get-setting bullet-train false) == ' true' ]]; then
203+ if [[ -f ${ZDOTDIR :- $HOME } /.zsh-quickstart-use-bullet-train ]] || [[ $( _zqs-get-setting bullet-train false) == ' true' ]]; then
204204 # Bullet train prompt setup.
205205 zgenom load https://github.com/caiogondim/bullet-train.zsh
206206 else
@@ -216,12 +216,12 @@ load-starter-plugin-list() {
216216setup-zgen-repos () {
217217 ZQS_override_plugin_list=' '
218218 # Check the old name for backward compatibility
219- if [[ -r $HOME /.zgen-local-plugins ]]; then
220- ZQS_override_plugin_list=" $HOME /.zgen-local-plugins"
219+ if [[ -r ${ZDOTDIR :- $ HOME} /.zgen-local-plugins ]]; then
220+ ZQS_override_plugin_list=" ${ZDOTDIR :- $ HOME} /.zgen-local-plugins"
221221 fi
222222 # If they have both, the new name takes precedence
223- if [[ -r $HOME /.zsh-quickstart-local-plugins ]]; then
224- ZQS_override_plugin_list=" $HOME /.zsh-quickstart-local-plugins"
223+ if [[ -r ${ZDOTDIR :- $ HOME} /.zsh-quickstart-local-plugins ]]; then
224+ ZQS_override_plugin_list=" ${ZDOTDIR :- $ HOME} /.zsh-quickstart-local-plugins"
225225 fi
226226
227227 if [[ -r " $ZQS_override_plugin_list " ]]; then
266266# Unfortunately, stat will return the modification time of the
267267# symlink instead of the target file, so construct a full path to hand off
268268# to stat so it returns the modification time of the actual .zgen-setup file.
269- if [[ -f ~ /.zgen-setup ]]; then
270- REAL_ZGEN_SETUP=~ /.zgen-setup
269+ if [[ -f ${ZDOTDIR :- $HOME } /.zgen-setup ]]; then
270+ REAL_ZGEN_SETUP=${ZDOTDIR :- $HOME } /.zgen-setup
271271fi
272- if [[ -L ~ /.zgen-setup ]]; then
273- REAL_ZGEN_SETUP=" $( readlink ~ /.zgen-setup) "
272+ if [[ -L ${ZDOTDIR :- $HOME } /.zgen-setup ]]; then
273+ REAL_ZGEN_SETUP=" $( readlink ${ZDOTDIR :- $HOME } /.zgen-setup) "
274274fi
275275
276276# If you don't want my standard starter set of plugins, create a file named
282282#
283283# Use readlink in case the user is symlinking from another repo checkout, so
284284# they can use a personal dotfiles repository cleanly.
285- if [[ -f ~ /.zgen-local-plugins ]]; then
286- REAL_ZGEN_SETUP=~ /.zgen-local-plugins
285+ if [[ -f ${ZDOTDIR :- $HOME } /.zgen-local-plugins ]]; then
286+ REAL_ZGEN_SETUP=${ZDOTDIR :- $HOME } /.zgen-local-plugins
287287fi
288- if [[ -L ~ /.zgen-local-plugins ]]; then
289- REAL_ZGEN_SETUP=" ${HOME} /$( readlink ~ /.zgen-local-plugins) "
288+ if [[ -L ${ZDOTDIR :- $HOME } /.zgen-local-plugins ]]; then
289+ REAL_ZGEN_SETUP=" ${ZDOTDIR :- $ HOME } /$( readlink ${ZDOTDIR :- $HOME } /.zgen-local-plugins) "
290290fi
291291# Old file still works for backward compatibility, but we want the new file
292292# to take precedence when both exist.
293- if [[ -f ~ /.zsh-quickstart-local-plugins ]]; then
294- REAL_ZGEN_SETUP=~ /.zsh-quickstart-local-plugins
293+ if [[ -f ${ZDOTDIR :- $HOME } /.zsh-quickstart-local-plugins ]]; then
294+ REAL_ZGEN_SETUP=${ZDOTDIR :- $HOME } /.zsh-quickstart-local-plugins
295295fi
296- if [[ -L ~ /.zsh-quickstart-local-plugins ]]; then
297- REAL_ZGEN_SETUP=" ${HOME} /$( readlink ~ /.zsh-quickstart-local-plugins) "
296+ if [[ -L ${ZDOTDIR :- $HOME } /.zsh-quickstart-local-plugins ]]; then
297+ REAL_ZGEN_SETUP=" ${ZDOTDIR :- $ HOME } /$( readlink ${ZDOTDIR :- $HOME } /.zsh-quickstart-local-plugins) "
298298fi
299299
300300# If .zgen-setup is newer than init.zsh, regenerate init.zsh
301- if [ $( get_file_modification_time ${REAL_ZGEN_SETUP} ) -gt $( get_file_modification_time ~ /.zgenom/init.zsh) ]; then
301+ if [ $( get_file_modification_time ${REAL_ZGEN_SETUP} ) -gt $( get_file_modification_time ${ZDOTDIR :- $HOME } /.zgenom/init.zsh) ]; then
302302 echo " $( basename ${REAL_ZGEN_SETUP} ) ($REAL_ZGEN_SETUP ) updated; creating a new init.zsh from plugin list in ${REAL_ZGEN_SETUP} "
303303 setup-zgen-repos
304- elif [ -d ~ /.zshrc.add-plugins.d ]; then
305- init_timestamp=$( get_file_modification_time ~ /.zgenom/init.zsh)
306- plugins_dir_timestamp=$( get_file_modification_time ~ /.zshrc.add-plugins.d)
304+ elif [ -d ${ZDOTDIR :- $HOME } /.zshrc.add-plugins.d ]; then
305+ init_timestamp=$( get_file_modification_time ${ZDOTDIR :- $HOME } /.zgenom/init.zsh)
306+ plugins_dir_timestamp=$( get_file_modification_time ${ZDOTDIR :- $HOME } /.zshrc.add-plugins.d)
307307 if [ " $plugins_dir_timestamp " -gt " $init_timestamp " ]; then
308- need_update=" true"
308+ need_update=" true"
309309 fi
310310
311- if [[ -n " $( " ls" -A ~ /.zshrc.add-plugins.d) " ]] && [[ -z $need_update ]]; then
312- for file in ~ /.zshrc.add-plugins.d/* ; do
311+ if [[ -n " $( " ls" -A ${ZDOTDIR :- $HOME } /.zshrc.add-plugins.d) " ]] && [[ -z ${ need_update-} ]]; then
312+ for file in ${ZDOTDIR :- $HOME } /.zshrc.add-plugins.d/* ; do
313313 if [[ $( get_file_modification_time " ${file} " ) -gt ${init_timestamp} ]]; then
314314 need_update=" true"
315315 break
316316 fi
317317 done
318318 fi
319319
320- if [[ -n $need_update ]]; then
321- echo " Some files in ~ /.zshrc.add-plugins.d updated; creating a new init.zsh from plugin list in ${REAL_ZGEN_SETUP} and plugins dir"
320+ if [[ -n ${ need_update-} ]]; then
321+ echo " Some files in ${ZDOTDIR :- $HOME } /.zshrc.add-plugins.d updated; creating a new init.zsh from plugin list in ${REAL_ZGEN_SETUP} and plugins dir"
322322 setup-zgen-repos
323323 fi
324324 unset init_timestamp
0 commit comments