Skip to content

Commit

Permalink
feat: Update & Delete Plugin Options (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pheon-Dev authored Nov 10, 2022
1 parent 107a22a commit ba9ff4d
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 1 deletion.
9 changes: 9 additions & 0 deletions doc.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
zap [options]

OPTIONS:
-h help
-v version
update update plugin(s)
delete delete plugin(s)
pause pause plugin(s)
unpause unpause plugin(s)
1 change: 0 additions & 1 deletion install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,5 @@ main() {
fi
}

echo "..."
main
echo " Zapped"
40 changes: 40 additions & 0 deletions zap.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,43 @@ function zapcmp() {
local completion_file="$(basename "${completion_file_path}")"
[ "$initialize_completion" = true ] && compinit "${completion_file:1}"
}

update () {
ls -1 "$ZAP_PLUGIN_DIR"
echo -n "Plugin Name or (a) to Update All: ";
read plugin;
pwd=$(pwd)
if [ $plugin="a" ]; then
cd "$ZAP_PLUGIN_DIR" && for plug in *; do cd $plug && echo "Updating $plug ..." && git pull > /dev/null 1>&1 && echo "Updated $plug" && cd ..; done
cd $pwd
else
cd "$ZAP_PLUGIN_DIR/$plugin" && echo "Updating $plugin ..." && git pull > /dev/null 2>&1 && cd - > /dev/null 2>&1 && echo "Updated $plugin " || echo "Failed to update : $plugin"
fi
}

delete () {
ls -1 "$ZAP_PLUGIN_DIR"
echo -n "Plugin Name: ";
read plugin;
cd "$ZAP_PLUGIN_DIR" && echo "Deleting $plugin ..." && rm -rf $plugin > /dev/null 2>&1 && cd - > /dev/null 2>&1 && echo "Deleted $plugin " || echo "Failed to delete : $plugin"
}

# pause target
pause() {
sed -i '/^zapplug/s/^/#/g' ~/.zshrc
}

# unpause target
unpause() {
sed -i '/^#zapplug/s/^#//g' ~/.zshrc
}

Help () {
cat "./doc.txt"
}

function zap() {
local command="$1"
[[ "$command" == "-h" ]] && Help || $command || echo "$command: command not found"
}

0 comments on commit ba9ff4d

Please sign in to comment.