summaryrefslogtreecommitdiff
path: root/zsh/zscripts/zplug.zsh
diff options
context:
space:
mode:
Diffstat (limited to 'zsh/zscripts/zplug.zsh')
-rwxr-xr-xzsh/zscripts/zplug.zsh136
1 files changed, 0 insertions, 136 deletions
diff --git a/zsh/zscripts/zplug.zsh b/zsh/zscripts/zplug.zsh
deleted file mode 100755
index 27dc70f..0000000
--- a/zsh/zscripts/zplug.zsh
+++ /dev/null
@@ -1,136 +0,0 @@
-#!/usr/bin/env zsh
-
-local home=~
-local zplugs="${ZDOTDIR:-$home/.}${ZDOTDIR:+/}zplugs" # Declare all variables using `local` to keep them away from the interactive shell
-local zplugins="${ZPLUGINSDIR:-$home/.local/share/zsh/zplugins}"
-#[[ $EUID != 0 ]] && [ -z "$ZPLUGNOROOT" ] && local sudo=${SUDO-sudo}
-
-function __zplugInstall() {
- touch "$zplugs"
- local pluglist=( `\grep -v '#' "$zplugs"` )
- local confirm plug
- shift
- for plug in "$@"; do; pluglist+=(${plug}); done
-
- $sudo mkdir -p "$zplugins"
-
- for plug in ${pluglist[@]}; do
- [ -d "$zplugins/$(basename -s'.git' "$plug")" ] && continue
- if ! `$sudo git -C "$zplugins" clone "$plug" "$(basename -s'.git' "$plug")"`; then
- # Runs if git has an error
- printf "Remove \"$plug\"? [y|n]: "
- read confirm
- case $confirm in
- y|yes) pluglist=(${pluglist#$plug}) && echo "Repo Deleted" ;;
- *) echo "Repo Kept" ;;
- esac
- fi
- echo
- done
- for plug in ${pluglist[@]}; do echo "$plug"; done | sort -u > "$zplugs"
- echo "All plugins installed and saved to $zplugs!\nDone"
-}
-
-function __zplugUninstall() {
- local pluglist=( `cat "$zplugs"` ) pluglistbn=()
- local confirm i plug plugids plugig
-
- [ -z "$pluglist" ] && echo "No packages are installed!" && return
-
- $sudo mkdir -p "$zplugins"
- echo "Listing all packages in $zplugins ..."
- for i in {1..${#pluglist[@]}}; do
- pluglistbn[$i]="$(basename -s'.git' "${pluglist[$i]}")"
- printf '%3d) %s\n' $i "${pluglistbn[$i]}"
- done
-
- echo
- printf "Choose zsh plugin(s) to remove: "
- read plugids
- [ -z "$plugids" ] && echo "No plugins selected\nAborting" && return
-
- echo "\nListing selected plugins:"
- for plugid in $=plugids; do
- if [ -z ${pluglist[$plugid]} ]; then
- echo "Error: input \"$plugid\" is not a valid plugin identifier"
- return
- fi
- echo "\t${pluglistbn[$plugid]}"
- done
-
- printf "\nReally remove all of these plugins? [y|n]: "
- read confirm
- case $confirm in
- y|yes) ;;
- n|no) echo "Aborted" && return ;;
- *) echo "Input not understood\nAborted" && return ;;
- esac
- for plugid in $=plugids; do
- printf '\t'
- $sudo rm -vrf "$zplugins/${pluglistbn[$plugid]}"
- pluglist[$plugid]=""
- done
- for plug in ${pluglist[@]}; do echo "$plug"; done | sort -u > "$zplugs"
- echo "\nDone"
-}
-
-function __zplugUpgrade() {
- local plugdir
- $sudo mkdir -p "$zplugins"
- echo "Upgrading all packages...\n"
- for plugdir in "$zplugins"/*; do;
- basename "$plugdir"
- $sudo git -C "$plugdir" pull;
- echo
- done
- echo "Done"
-}
-
-function __zplugList() {
- mkdir -p "$zplugins"
- echo "Listing all packages...\n"
- ls "$zplugins" | nl -s') ' -w3
- echo "\nDone"
-}
-
-function __zplugHelp() {
- echo "Usage: zplug [install/add/i|uninstall/remove/r|upgrade/update/u|list/l|help/h]
- install, add, i [packages] : Install plugins from config file & add any new plugins
- uninstall, remove, r : Interactively remove plugins
- upgrade, update, u : Update all installed plugins
- list, l : List all installed plugins
- help, h : Show this help menu
-
- All plugins are listed in $zplugs
- All plugins are installed in $zplugins
-
- To install a plugin, just put it in the zplug file and run \"zplug install\"
- or just run \"zplug install [plugin]\" where [plugin] is a link to download the
- plugin using git
-
- For instance, \"https://github.com/zdharma-continuum/fast-syntax-highlighting\" is
- a valid plugin link for the fast-syntax-highlighting plugin.
-
- To use your plugins, just put \"zplugInitialize\" as the last line of your zshrc!"
-}
-
-function zplug() {
- local cmd=${1:-h}
- case $cmd in
- install|add|i) __zplugInstall $@ ;;
- uninstall|remove|r) __zplugUninstall ;;
- upgrade|update|u) __zplugUpgrade ;;
- list|l) __zplugList ;;
- help|h) __zplugHelp ;;
- *) echo "zplug: input \"$1\" not recognized!" && __zplugHelp ;;
- esac
-}
-
-function zplugInitialize() {
- local plugin
- if ! [ -d "$zplugins" ] && [ -f "$zplugs" ]; then
- echo "zplug installing plugins..."
- __zplugInstall 0 # Put in some value since there is a shift
- fi
- for plugin in "$zplugins"/*/*.zsh; do source "$plugin"; done 2>/dev/null
-}