From 0c257ebe4a9289925701e6755ad0cc421f988f8b Mon Sep 17 00:00:00 2001 From: Shrikant Sharat Date: Wed, 19 Sep 2012 19:50:52 +0530 Subject: [PATCH] For #29. Intial working implementation with tests. The `-theme` command is now little more than an extension to the `-bundle` command. The difference is that this command sets `--btype=theme`, which is what indicates that this bundle is a theme. As such, the `-theme` command accepts all the documented options taken by `-bundle`. --- antigen.zsh | 19 +++++++++++++++++-- tests/.zshenv | 1 + tests/theme.t | 7 +++++++ 3 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 tests/theme.t diff --git a/antigen.zsh b/antigen.zsh index 1e4155b..c71d4d1 100644 --- a/antigen.zsh +++ b/antigen.zsh @@ -49,6 +49,11 @@ antigen-bundle () { make_local_clone=false fi + # Add the theme extension to `loc`, if this is a theme. + if [[ $btype == theme && $loc != *.zsh-theme ]]; then + loc="$loc.zsh-theme" + fi + # Add it to the record. _ANTIGEN_BUNDLE_RECORD="$_ANTIGEN_BUNDLE_RECORD\n$url $loc $btype" _ANTIGEN_BUNDLE_RECORD="$_ANTIGEN_BUNDLE_RECORD $make_local_clone" @@ -313,8 +318,18 @@ antigen-lib () { } antigen-theme () { - local name="${1:-robbyrussell}" - antigen-bundle --loc=themes/$name.zsh-theme --btype=theme + + if [[ "$1" != */* && "$1" != --* ]]; then + # The first argument is just a name of the plugin, to be picked up from + # the default repo. + local name="${1:-robbyrussell}" + antigen-bundle --loc=themes/$name --btype=theme + + else + antigen-bundle "$@" --btype=theme + + fi + } antigen-apply () { diff --git a/tests/.zshenv b/tests/.zshenv index e5e494f..d942446 100644 --- a/tests/.zshenv +++ b/tests/.zshenv @@ -17,6 +17,7 @@ mkdir "$PLUGIN_DIR" alias pg='git --git-dir "$PLUGIN_DIR/.git" --work-tree "$PLUGIN_DIR"' echo 'alias hehe="echo hehe"' > "$PLUGIN_DIR"/aliases.zsh +echo 'export PS1="prompt>"' > "$PLUGIN_DIR"/silly.zsh-theme { pg init diff --git a/tests/theme.t b/tests/theme.t new file mode 100644 index 0000000..f8f7ac3 --- /dev/null +++ b/tests/theme.t @@ -0,0 +1,7 @@ +Load the theme explicitly. + + $ antigen-theme $PLUGIN_DIR silly + Cloning into '*'... (glob) + done. + $ echo "$PS1" + prompt> -- 2.0.0