~yerinalexey/miniplug

79fe20b7c114127ed483d615a96fa60add9d29cd — Alexey Yerin 1 year, 2 months ago 88834cc
Add command to register a theme
1 files changed, 17 insertions(+), 0 deletions(-)

M miniplug.zsh
M miniplug.zsh => miniplug.zsh +17 -0
@@ 4,6 4,7 @@

# Globals
declare MINIPLUG_HOME="${MINIPLUG_HOME:-$HOME/.miniplug}"
declare MINIPLUG_THEME="${MINIPLUG_THEME:-}"
declare MINIPLUG_PLUGINS=()

# Helper functions {{{


@@ 17,6 18,7 @@ function __miniplug_usage() {
  echo "Usage: miniplug <command> [arguments]"
  echo "Commands:"
  echo "  plugin - Register a plugin"
  echo "  theme - Register a theme (can be done only once)"
  echo "  install - Install plugins"
  echo "  help - Show this message"
}


@@ 28,6 30,20 @@ function __miniplug_plugin() {
  MINIPLUG_PLUGINS+=("$plugin_url")
}

# Register a theme
function __miniplug_theme() {
  local theme_url="$1"

  # Throw an error if theme is already set but not if MINIPLUG_THEME and new theme match
  if [ -n "$MINIPLUG_THEME" ] && [ "$MINIPLUG_THEME" != "$theme_url" ]; then
    echo "Theme is already set"
    return 1
  fi

  MINIPLUG_PLUGINS+=("$theme_url")
  MINIPLUG_THEME="$theme_url"
}

# Install plugins
function __miniplug_install() {
  local plugin_url plugin_name clone_url clone_dest


@@ 71,6 87,7 @@ function __miniplug_install() {
function miniplug() {
  case "$1" in
    plugin) __miniplug_plugin "$2" ;;
    theme) __miniplug_theme "$2" ;;
    install) __miniplug_install ;;
    help) __miniplug_usage ;;
    *) __miniplug_usage ;;