Last active
April 18, 2024 09:13
-
-
Save vraravam/51e0516f5d7c6beec67668d1a31b7da8 to your computer and use it in GitHub Desktop.
~/.zlogin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env zsh | |
# vim:syntax=zsh | |
# vim:filetype=zsh | |
# file location: ${HOME}/.zlogin | |
# Note: This file is loaded AFTER ${HOME}/.zshrc | |
function recompile-zsh-scripts-as-reqd { | |
if [[ -s "${1}" && (! -s "${1}.zwc" || "${1}" -nt "${1}.zwc") ]]; then | |
echo "recompiling ${1}" | |
zrecompile -pq "${1}" | |
fi | |
} | |
function find-in-folder-and-recompile { | |
[ ! -d "${1}" ] && return | |
# TODO: This still doesn't handle '.pnpm' folders - need to investigate later | |
for f in $(find ${1} -maxdepth 4 -name "*.sh" -o -name "*.zsh" ! -path "**/node_modules/**"); do | |
recompile-zsh-scripts-as-reqd "${f}" | |
done | |
} | |
# Execute code in the background to not affect the current session | |
( | |
# <https://github.com/zimfw/zimfw/blob/master/login_init.zsh> | |
setopt LOCAL_OPTIONS EXTENDED_GLOB | |
autoload -U zrecompile | |
# zsh config files can be compiled to improve performance | |
# Based from: https://github.com/romkatv/zsh-bench/blob/master/configs/ohmyzsh%2B/setup | |
recompile-zsh-scripts-as-reqd "${ZDOTDIR:-${HOME}}/.aliases.${USERNAME}" | |
recompile-zsh-scripts-as-reqd "${ZDOTDIR:-${HOME}}/.aliases" | |
recompile-zsh-scripts-as-reqd "${ZDOTDIR:-${HOME}}/.p10k.zsh" | |
recompile-zsh-scripts-as-reqd "${ZDOTDIR:-${HOME}}/.zprofile" | |
recompile-zsh-scripts-as-reqd "${ZDOTDIR:-${HOME}}/.zshenv" | |
recompile-zsh-scripts-as-reqd "${ZDOTDIR:-${HOME}}/.zshrc.custom" | |
recompile-zsh-scripts-as-reqd "${ZDOTDIR:-${HOME}}/.zshrc" | |
find-in-folder-and-recompile /usr/local | |
find-in-folder-and-recompile /opt/homebrew | |
find-in-folder-and-recompile "${ZSH:-${HOME}/.oh-my-zsh}" | |
find-in-folder-and-recompile "${HOME}/.bin" | |
find-in-folder-and-recompile "${HOME}/dev/oss" | |
find-in-folder-and-recompile "${HOME}/personal/dev" | |
) &! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment