Refactor: Extract zsh config file loading to function
This commit is contained in:
parent
54b756a0f6
commit
ff874c4c79
1 changed files with 18 additions and 36 deletions
54
.zshrc
54
.zshrc
|
@ -78,7 +78,7 @@ check_zgen_installation() {
|
|||
## will be run after numbered ones (in a random order) if you uncomment the
|
||||
## corresponding line below.
|
||||
|
||||
# Set ZSH_CONFIG_DIR to default to ~/.zsh.d, or let user override
|
||||
# Set ZSH_CONFIG_DIR to default to ~/.config/zsh, or let user override
|
||||
# Exit early if no configuration directory has been found
|
||||
if [ ! -d ${ZSH_CONFIG_DIR:="${XDG_CONFIG_DIR:-$HOME/.config}/zsh"} ]; then
|
||||
# If the user explicitly overrode the path give him an error
|
||||
|
@ -91,55 +91,31 @@ fi
|
|||
|
||||
# //TODO: Prints error when -no- files are found
|
||||
# Load bootstrap settings (00-19) before plugin initialization
|
||||
if [ -n "$(/bin/ls $ZSH_CONFIG_DIR/)" ]; then
|
||||
GLOB=($ZSH_CONFIG_DIR/[0-1][0-9]-*)
|
||||
for dotfile in $GLOB; do
|
||||
print_dbg "Phase 1: $dotfile\n" #//DEBUG
|
||||
if [ -r "${dotfile}" ]; then
|
||||
source "${dotfile}"
|
||||
fi
|
||||
done
|
||||
unset GLOB
|
||||
fi
|
||||
print_dbg "Starting bootstrap (00-19)...\n"
|
||||
load_config_files $ZSH_CONFIG_DIR 01
|
||||
|
||||
# set up zgen - load external zsh plugins
|
||||
# If you need to reload your plugins use 'zgen reset' and restart
|
||||
# your shell
|
||||
if [ -n "$(/bin/ls $ZSH_CONFIG_DIR/)" ]; then
|
||||
print_dbg "Phase 2: Setting up ZGEN\n" #//DEBUG
|
||||
print_dbg "Starting plugin system...\n" #//DEBUG
|
||||
|
||||
check_zgen_installation
|
||||
|
||||
if ! zgen saved; then
|
||||
|
||||
if [ -n "$(/bin/ls $ZSH_CONFIG_DIR/)" ]; then
|
||||
GLOB=($ZSH_CONFIG_DIR/2[0-9]-*)
|
||||
for dotfile in $GLOB; do
|
||||
print_dbg "Phase 2: $dotfile - Plugin\n" #//DEBUG
|
||||
if [ -r "${dotfile}" ]; then
|
||||
source "${dotfile}"
|
||||
fi
|
||||
done
|
||||
unset GLOB
|
||||
fi
|
||||
print_dbg "Applying plugins (20-29)...\n"
|
||||
load_config_files $ZSH_CONFIG_DIR 2
|
||||
|
||||
# Save it all to init script.
|
||||
zgen save
|
||||
fi
|
||||
|
||||
else
|
||||
print_dbg "Plugins already applied. If you want to re-apply run 'zgen reset' and open new terminal.\n"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Load additional settings (30-99) after plugin initialization
|
||||
if [ -n "$(/bin/ls $ZSH_CONFIG_DIR/)" ]; then
|
||||
GLOB=($ZSH_CONFIG_DIR/[3-9][0-9]-*)
|
||||
for dotfile in $GLOB; do
|
||||
print_dbg "Phase 3: $dotfile\n" #//DEBUG
|
||||
if [ -r "${dotfile}" ]; then
|
||||
source "${dotfile}"
|
||||
fi
|
||||
done
|
||||
unset GLOB
|
||||
fi
|
||||
print_dbg "Setting up remaining scripts (30-99)\n"
|
||||
load_config_files $ZSH_CONFIG_DIR 3456789
|
||||
|
||||
# Uncomment this section to enable execution of arbitrarily named config files
|
||||
# if [ -n "$(/bin/ls $ZSH_CONFIG_DIR/)" ]; then
|
||||
|
@ -154,7 +130,13 @@ fi
|
|||
# fi
|
||||
|
||||
unset ZSH_CONFIG_DIR
|
||||
unset ZGEN_DIR
|
||||
unset ZGEN_PARENT_DIR
|
||||
unset ZSH_SETUP_SHOW_DEBUG
|
||||
unfunction print_dbg
|
||||
unfunction load_config_files
|
||||
unfunction check_zgen_installation
|
||||
|
||||
|
||||
# //FIXME this needs to get the hell out of here -> put it in an env loading file
|
||||
export GOPATH="$HOME/Code/go"
|
||||
export PATH="$PATH:$GOPATH/bin"
|
||||
|
|
Loading…
Reference in a new issue