Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New way to add plugins #250

Merged
merged 4 commits into from
Mar 1, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions zsh/.zgen-setup
Original file line number Diff line number Diff line change
Expand Up @@ -290,5 +290,29 @@ fi
if [ $(get_file_modification_time ${REAL_ZGEN_SETUP}) -gt $(get_file_modification_time ~/.zgenom/init.zsh) ]; then
echo "$(basename ${REAL_ZGEN_SETUP}) ($REAL_ZGEN_SETUP) updated; creating a new init.zsh from plugin list in ${REAL_ZGEN_SETUP}"
setup-zgen-repos
elif [ -d ~/.zshrc.add-plugins.d ]; then
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for only looking at the plugin fragments if we don't already need to rebuild init.zsh because of $REAL_ZGEN_SETUP. Every bit of speedup helps.

init_timestamp=$(get_file_modification_time ~/.zgenom/init.zsh)
plugins_dir_timestamp=$(get_file_modification_time ~/.zshrc.add-plugins.d)
if [ "$plugins_dir_timestamp" -gt "$init_timestamp" ]; then
need_update="true"
fi

if [[ -n "$(ls -A ~/.zshrc.add-plugins.d)" ]] && [[ -z $need_update ]]; then
for file in ~/.zshrc.add-plugins.d/*; do
if [[ $(get_file_modification_time "${file}") -gt ${init_timestamp} ]]; then
need_update="true"
break
fi
done
fi

if [[ -n $need_update ]]; then
echo "Some files in ~/.zshrc.add-plugins.d updated; creating a new init.zsh from plugin list in ${REAL_ZGEN_SETUP} and plugins dir"
setup-zgen-repos
fi
unset init_timestamp
unset plugins_dir_timestamp
unset need_update
fi

unset REAL_ZGEN_SETUP
2 changes: 1 addition & 1 deletion zsh/.zshrc
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ _zqs-purge-setting() {
function _zqs-update-stale-settings-files() {
# Convert .zqs-additional-plugins to new format
neiromaster marked this conversation as resolved.
Show resolved Hide resolved
if [[ -f ~/.zqs-additional-plugins ]]; then
mkdir -p "~/.zshrc.add-plugins.d"
mkdir -p ~/.zshrc.add-plugins.d
sed -e 's/^./zgenom load &/' ~/.zqs-additional-plugins >> ~/.zshrc.add-plugins.d/0000-transferred-plugins
rm -f ~/.zqs-additional-plugins
echo "Plugins from .zqs-additional-plugins were moved to .zshrc.add-plugins.d/0000-transferred-plugins with a format change"
Expand Down