From da678afb28803f7ed292ec13a43aeb818a510053 Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Fri, 22 Mar 2013 12:53:05 +0100 Subject: [PATCH] Introduce antigen-use command --- README.mkd | 18 +++++++++--------- antigen.zsh | 13 +++++++++++++ tests/antigen-use.t | 19 +++++++++++++++++++ 3 files changed, 41 insertions(+), 9 deletions(-) create mode 100644 tests/antigen-use.t diff --git a/README.mkd b/README.mkd index f7e675e..f1c4833 100644 --- a/README.mkd +++ b/README.mkd @@ -77,7 +77,7 @@ See? It's easy! To see how that works, refer to the section on the Note: Many of those plugins and especially themes, assume you have the core library of oh-my-zsh loaded. So, if you want to experiment further, issue a - antigen-lib + antigen-use oh-my-zsh and continue until you're tired. At which point you can come back to this page ;) @@ -98,7 +98,7 @@ might look like this source /path-to-antigen-clone/antigen.zsh # Load the oh-my-zsh's library. - antigen-lib + antigen-use oh-my-zsh # Bundles from the default repo (robbyrussell's oh-my-zsh). antigen-bundle git @@ -351,7 +351,7 @@ clones. If the `--force` argument is given, then this confirmation is not asked. It straight away deletes all the unused clones. This option makes this command usable in a non-interactive fashion. -### antigen-lib +### antigen-use oh-my-zsh This is (almost) the same as @@ -365,19 +365,19 @@ correct path, if not already set to something else. Please note that this assumes that the `ANTIGEN_DEFAULT_REPO_URL` is set to the oh-my-zsh repo or a fork of that repo. If you want to specify the `url` too, -then you can't use the `antigen-lib` short cut. You have to do that directly +then you can't use the `antigen-use oh-my-zsh` short cut. You have to do that directly with the `antigen-bundle` command. This is present to ease dealing with oh-my-zsh plugins. Use - antigen-lib + antigen-use oh-my-zsh in your `.zshrc`, before any `antigen-bundle` declarations. It takes no arguments. -### antigen-prezto-lib α +### antigen-use prezto α This is (almost, but not quite) the same as doing, @@ -411,9 +411,9 @@ Will pull the apple theme from the canonical oh-my-zsh repo. Also, note that the You can use this command to change your theme on the fly in your shell. Go on, try out a few themes in your shell before you set it in your `.zshrc`. -**Note**: Some themes use functions that are loaded by `antigen-lib`. So, to -avoid any trouble, run `antigen-lib` if you haven't already before experimenting -with themes. If you have `antigen-lib` in your `.zshrc`, you're covered. +**Note**: Some themes use functions that are loaded by `antigen-use oh-my-zsh`. So, to +avoid any trouble, run `antigen-use oh-my-zsh` if you haven't already before experimenting +with themes. If you have `antigen-use oh-my-zsh` in your `.zshrc`, you're covered. **Note**: Do *not* provide the `--btype` argument to `antigen-theme`. Its an internal argument. diff --git a/antigen.zsh b/antigen.zsh index 5d13ace..0f0ba50 100644 --- a/antigen.zsh +++ b/antigen.zsh @@ -371,6 +371,19 @@ antigen-cleanup () { fi } +antigen-use () { + if [[ $1 == "oh-my-zsh" ]]; then + antigen-lib $@ + elif [[ $1 == "prezto" ]]; then + antigen-prezto-lib $@ + else + echo 'Antigen currently supports only following libraries:' >&2 + echo ' * oh-my-zsh' >&2 + echo ' * prezto' >&2 + return 1 + fi +} + antigen-lib () { if [[ -z "$ZSH" ]]; then export ZSH="$(-antigen-get-clone-dir "$ANTIGEN_DEFAULT_REPO_URL")" diff --git a/tests/antigen-use.t b/tests/antigen-use.t new file mode 100644 index 0000000..ad8499b --- /dev/null +++ b/tests/antigen-use.t @@ -0,0 +1,19 @@ +Load unknown library. + + $ antigen-use unknown + Antigen currently supports only following libraries: + * oh-my-zsh + * prezto + [1] + +# Fixme: loading prezto or oh-my-zsh library breaks all the tests. +# +# Load prezto library. +# +# $ antigen-use prezto &> /dev/null +# $ antigen-bundle git &> /dev/null +# +# Load oh-my-zsh library. +# +# $ antigen-use oh-my-zsh &> /dev/null +# $ antigen-bundle git &> /dev/null -- 2.0.0