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

feat: Update & Delete Plugin Options #15

Merged
merged 5 commits into from
Nov 10, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
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"
}