Skip to content

Commit

Permalink
feat: show updates available zap-zsh#59
Browse files Browse the repository at this point in the history
  • Loading branch information
Pheon-Dev committed Nov 14, 2022
1 parent c4b4036 commit ae4454b
Showing 1 changed file with 26 additions and 14 deletions.
40 changes: 26 additions & 14 deletions zap.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ plug() {
_pull() {
echo "🔌 $1"
git pull > /dev/null 2>&1
if [ $? -ne 0 ]; then echo "Failed to update $1" && exit 1; fi
# if [ $? -ne 0 ]; then echo "Failed to update $1" && exit 1; fi
echo -e "\e[1A\e[K⚡ $1"
}

Expand All @@ -75,36 +75,48 @@ _zap_clean() {
}

_zap_update() {
plugins=$(cat "$HOME/.local/share/zap/installed_plugins" | awk 'BEGIN { FS = "\n" } { print " " int((NR)) echo " 🔌 " $1 }')
echo -e " 0 ⚡ Zap"
echo "$plugins \n"
_changes() {
count=$(git remote update > /dev/null 2>&1 && git status -uno | grep "modified" | wc -l)
mods=$(git remote update > /dev/null 2>&1 && git status -uno | grep "modified" | head -5)
if [[ $count -ne 0 ]]; then
echo -e " $mods"
echo -e " ... $count new change(s), update. \n"
fi
cd "$ZAP_PLUGIN_DIR"
}
plugins=$(ls "$HOME/.local/share/zap/plugins" | awk 'BEGIN { FS = "\n" } { print " " int((NR)) echo " 🔌 " $1 }')
pwd=$(pwd)
cd "$ZAP_DIR"
echo " 0 ⚡ Zap" | grep -E "Zap"
git remote update > /dev/null 2>&1 && git status -uno | grep "modified" > /dev/null 2>&1
_changes
for plug in *; do
cd $plug
echo -n $plugins | grep "$plug$"
_changes
done
echo -n "🔌 Plugin Number | (a) All Plugins | (0) ⚡ Zap Itself: "
read plugin
pwd=$(pwd)
echo ""
if [[ $plugin == "a" ]]; then
cd "$ZAP_PLUGIN_DIR"
for plug in *; do
cd $plug
_pull $plug
cd "$ZAP_PLUGIN_DIR"
done
cd $pwd > /dev/null 2>&1
elif [[ $plugin == "0" ]]; then
cd "$ZAP_DIR"
_pull 'zap'
cd $pwd
else
for plug in $plugins; do
selected=$(echo $plug | grep -E "^ $plugin" | awk 'BEGIN { FS = "[ /]" } { print $6 }')
cd "$ZAP_PLUGIN_DIR/$selected"
_pull $selected
cd - > /dev/null 2>&1
done
cd "$ZAP_PLUGIN_DIR"
selected=$(echo $plugins | grep -E "^ $plugin" | awk 'BEGIN { FS = "[ /]" } { print $5 }')
cd $selected
_pull $selected
fi
if [[ $ZAP_CLEAN_ON_UPDATE == true ]]; then
_zap_clean
fi
cd $pwd > /dev/null 2>&1
}

_zap_help() {
Expand Down

0 comments on commit ae4454b

Please sign in to comment.