<commit_before>load_autojump() {
	if [ `uname` = 'Darwin' ];
	then
		source_safe /usr/local/etc/profile.d/autojump.sh
	else
		source_safe /usr/share/autojump/autojump.zsh
	fi

}

load_pyenv() {
	if has_bin pyenv
	then
		export PYENV_ROOT="$HOME/.pyenv"
		export PATH="$PYENV_ROOT/bin:$PATH"
		eval "$(pyenv init -)"
		eval "$(pyenv virtualenv-init -)"

		if has_bin thefuck; then eval "$(thefuck --alias)"; fi
	fi
}

load_nvm() {
	if [[ -d "$HOME/.nvm" ]]
	then
		export NVM_DIR="$HOME/.nvm"
		source_safe "$NVM_DIR/nvm.sh" 
		# Prefer locally installed node binaries
		export PATH=node_modules/.bin:$PATH
	fi
}

init_funcs=(load_autojump load_pyenv load_nvm)
init_total=${#init_funcs[*]}
init_index=1

# Triggers an init function
# $1: the init function index to trigger
# $2: the number of seconds to wait before triggering
run() {
	sleep ${2:0}
	echo $1
}

source ${HOME}/.zsh/async.zsh
async_init
async_start_worker zsh -n

init_callback() {
	if [[ "$1" == "run" ]]
	then
		# Run the current init function
		eval "$init_funcs[$3]"

		# Trigger the next init function. This ensures the init
		# functions runs in serial.
		if (( init_index < init_total ))
		then
			init_index=$(( init_index + 1 ))
			async_job zsh run $init_index 0
		fi
	fi
}
async_register_callback zsh init_callback

# Delay init function triggering for 2s to make the shell starts faster.
async_job zsh run 1 2
<commit_msg>load autojump immediately<commit_after>load_autojump() {
	if [ `uname` = 'Darwin' ];
	then
		source_safe /usr/local/etc/profile.d/autojump.sh
	else
		source_safe /usr/share/autojump/autojump.zsh
	fi

}

load_pyenv() {
	if has_bin pyenv
	then
		export PYENV_ROOT="$HOME/.pyenv"
		export PATH="$PYENV_ROOT/bin:$PATH"
		eval "$(pyenv init -)"
		eval "$(pyenv virtualenv-init -)"

		if has_bin thefuck; then eval "$(thefuck --alias)"; fi
	fi
}

load_nvm() {
	if [[ -d "$HOME/.nvm" ]]
	then
		export NVM_DIR="$HOME/.nvm"
		source_safe "$NVM_DIR/nvm.sh" 
		# Prefer locally installed node binaries
		export PATH=node_modules/.bin:$PATH
	fi
}

init_funcs=(load_pyenv load_nvm)
init_total=${#init_funcs[*]}
init_index=1

# Triggers an init function
# $1: the init function index to trigger
# $2: the number of seconds to wait before triggering
run() {
	sleep ${2:0}
	echo $1
}

source ${HOME}/.zsh/async.zsh
async_init
async_start_worker zsh -n

init_callback() {
	if [[ "$1" == "run" ]]
	then
		# Run the current init function
		eval "$init_funcs[$3]"

		# Trigger the next init function. This ensures the init
		# functions runs in serial.
		if (( init_index < init_total ))
		then
			init_index=$(( init_index + 1 ))
			async_job zsh run $init_index 0
		fi
	fi
}
async_register_callback zsh init_callback

# Make sure autojump is always loaded
load_autojump

# Delay init function triggering for 2s to make the shell starts faster.
async_job zsh run 1 2

{'fraction_non_alphanumeric': 0.12258517737969793, 'fraction_numerical': 0.0091324200913242, 'mean_word_length': 3.901893287435456, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3337842', 'n_tokens_mistral': 1155, 'n_tokens_neox': 1068, 'n_words': 302}