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

v1.9.3 #159

Merged
merged 15 commits into from
Oct 27, 2023
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 1.9.2
current_version = 1.9.3
parse = v?(?P<major>\d+)\.(?P<minor>\d+)\.(?P<revision>\d+)
serialize = {major}.{minor}.{revision}

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# antidote

[![MIT License](https://img.shields.io/badge/license-MIT-007EC7.svg)](/LICENSE)
![version](https://img.shields.io/badge/version-v1.9.2-df5e88)
![version](https://img.shields.io/badge/version-v1.9.3-df5e88)

<a title="GetAntidote"
href="https://getantidote.github.io"
Expand Down Expand Up @@ -57,7 +57,7 @@ You can install the latest release of antidote by cloning it with `git`:

```zsh
# first, run this from an interactive zsh terminal session:
git clone --depth=1 https://github.com/mattmc3/antidote.git ${ZDOTDIR:-~}/.antidote
git clone --depth=1 https://github.com/mattmc3/antidote.git ${ZDOTDIR:-$HOME}/.antidote
```

### Install with a package manager
Expand Down
4 changes: 3 additions & 1 deletion antidote
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
#
function antidote {
0=${(%):-%x}
(( $+functions[antidote-main] )) || source ${0:A:h}/antidote.zsh
if ! typeset -f antidote-main > /dev/null; then
source ${0:A:h}/antidote.zsh
fi
antidote-main "$@"
}
antidote "$@"
2 changes: 1 addition & 1 deletion functions/__antidote_bulk_clone
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
emulate -L zsh; setopt local_options $_adote_funcopts

# get a list of clonable repos from a bundle file
awk '
$__adote_awkcmd '
BEGIN { RS="[\r\n]" }

# initialize vars
Expand Down
2 changes: 1 addition & 1 deletion functions/__antidote_filter_defers
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
### Filter all but the first defer block.
#function __antidote_filter_defers {
emulate -L zsh; setopt local_options $_adote_funcopts
awk '
$__adote_awkcmd '
# filter all but the first time we source zsh-defer (a 4 line if statement)
BEGIN { skip=0; found=0 }
skip>0 { skip-- }
Expand Down
2 changes: 1 addition & 1 deletion functions/__antidote_parse_bundles
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
### Parse antidote's bundle DSL.
#function __antidote_parse_bundles {
emulate -L zsh; setopt local_options $_adote_funcopts
awk '
$__adote_awkcmd '
BEGIN { RS="[\r\n]" }

# skip comments and empty lines
Expand Down
11 changes: 9 additions & 2 deletions functions/__antidote_setup
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@
fpath=( "${0:A:h}" $fpath )
local fn
for fn in ${0:A:h}/*; do
[[ $fn:t != '__antidote_setup' ]] || continue
(( $+functions[${fn:t}] )) && unfunction ${fn:t}
[[ ${fn:t} != '__antidote_setup' ]] || continue
if typeset -f ${fn:t} > /dev/null; then
unfunction ${fn:t}
fi

# autoload extensionless function files
[[ -z "${fn:e}" ]] && autoload -Uz "${fn}"
done
Expand All @@ -29,4 +32,8 @@
if zstyle -t ':antidote:tests' set-warn-options; then
typeset -gHa _adote_funcopts=( $_adote_funcopts warn_create_global warn_nested_var )
fi

gawk --version &>/dev/null && typeset -gH __adote_awkcmd=gawk || typeset -gH __adote_awkcmd=awk
typeset -gHi __adote_ksh_arrays
typeset -gHi __adote_sh_glob
#}
2 changes: 1 addition & 1 deletion functions/__antidote_version
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#function __antidote_version {
emulate -L zsh; setopt local_options $_adote_funcopts
0=${(%):-%x}
local ver='1.9.2'
local ver='1.9.3'
local gitsha=$(git -C "${0:A:h:h}" rev-parse --short HEAD 2>/dev/null)
[[ -z "$gitsha" ]] || ver="$ver ($gitsha)"
print "antidote version $ver"
Expand Down
2 changes: 1 addition & 1 deletion functions/_antidote
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
function _antidote_subcommands {
local usage=$(
antidote --help |
awk '
$__adote_awkcmd '
BEGIN{OFS=":"; p=0}
/^commands:$/ {p=1; next}
!p{next}
Expand Down
4 changes: 3 additions & 1 deletion functions/antidote
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#
#function antidote {
0=${(%):-%x}
(( $+functions[antidote-main] )) || source ${0:A:h:h}/antidote.zsh
if ! typeset -f antidote-main > /dev/null; then
source ${0:A:h:h}/antidote.zsh
fi
antidote-main "$@"
#}
8 changes: 4 additions & 4 deletions functions/antidote-install
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,20 @@
done

if [[ $# -eq 0 ]]; then
print >&2 "antidote: error: required argument 'bundle' not provided, try --help"
print -ru2 "antidote: error: required argument 'bundle' not provided, try --help"
return 1
fi

local bundle=$1
local bundlefile=$2
if [[ -z "$bundlefile" ]]; then
zstyle -s ':antidote:bundle' file 'bundlefile' ||
bundlefile=${ZDOTDIR:-~}/.zsh_plugins.txt
bundlefile=${ZDOTDIR:-$HOME}/.zsh_plugins.txt
fi

local bundledir=$(__antidote_bundle_dir $bundle)
if [[ -d "$bundledir" ]]; then
print >&2 "antidote: error: $bundle already installed: $bundledir"
print -ru2 "antidote: error: $bundle already installed: $bundledir"
return 1
fi

Expand All @@ -57,7 +57,7 @@
(( $#annotations )) && bundlestr+=" $annotations"
antidote-bundle "$bundlestr" >/dev/null
if [[ $? -ne 0 ]]; then
print >&2 "antidote: unable to install bundle '$bundle'."
print -ru2 "antidote: unable to install bundle '$bundle'."
else
print "Adding bundle to '$bundlefile':"
print $bundlestr | tee -a $bundlefile
Expand Down
2 changes: 1 addition & 1 deletion functions/antidote-list
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
fi

if [[ $# -ne 0 ]]; then
print >&2 "antidote: error: unexpected $1, try --help"
print -ru2 "antidote: error: unexpected $1, try --help"
return 1
fi

Expand Down
16 changes: 13 additions & 3 deletions functions/antidote-main
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,17 @@
#function antidote-main {
0=${(%):-%x}

[[ -o KSH_ARRAYS ]] && __adote_ksh_arrays=1 && unsetopt KSH_ARRAYS
[[ -o SH_GLOB ]] && __adote_sh_glob=1 && unsetopt SH_GLOB

local o_help o_version
zparseopts ${_adote_zparopt_flags} -- \
h=o_help -help=h \
v=o_version -version=v ||
return 1

local ret=0

if (( ${#o_version} )); then
__antidote_version

Expand All @@ -22,7 +27,7 @@

elif [[ ${#} -eq 0 ]]; then
antidote-help
return 2
ret=2

elif [[ "${1}" = help ]]; then
local manpage=${2:-antidote}
Expand All @@ -31,9 +36,14 @@
elif (( $+functions[antidote-${1}] )); then
local cmd=${1}; shift
antidote-${cmd} "$@"
return $?
ret=$?

else
print >&2 "antidote: command not found '${1}'" && return 1
print -ru2 "antidote: command not found '${1}'"
ret=1
fi

(( __adote_ksh_arrays )) && __adote_ksh_arrays=0 && setopt KSH_ARRAYS
(( __adote_sh_glob )) && __adote_sh_glob=0 && setopt SH_GLOB
return $ret
#}
4 changes: 2 additions & 2 deletions functions/antidote-path
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
fi

if [[ $# -eq 0 ]]; then
print >&2 "antidote: error: required argument 'bundle' not provided, try --help"
print -ru2 "antidote: error: required argument 'bundle' not provided, try --help"
return 1
fi

local bundle="$1"
local bundledir=$(__antidote_bundle_dir $bundle)
if [[ ! -d $bundledir ]]; then
print >&2 "antidote: error: $bundle does not exist in cloned paths"
print -ru2 "antidote: error: $bundle does not exist in cloned paths"
return 1
else
print "$bundledir"
Expand Down
10 changes: 5 additions & 5 deletions functions/antidote-purge
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
fi

if [[ $# -eq 0 ]] && ! (( $#o_all )); then
print >&2 "antidote: error: required argument 'bundle' not provided, try --help"
print -ru2 "antidote: error: required argument 'bundle' not provided, try --help"
return 1
fi

local bundlefile
zstyle -s ':antidote:bundle' file 'bundlefile' ||
bundlefile=${ZDOTDIR:-~}/.zsh_plugins.txt
bundlefile=${ZDOTDIR:-$HOME}/.zsh_plugins.txt

if (( $#o_all )); then
# last chance to save the user from themselves
Expand Down Expand Up @@ -57,13 +57,13 @@
local bundle=$1
# make sure the user isn't trying to do something out-of-bounds
if [[ -e "$bundle" ]]; then
print >&2 "antidote: error: '$bundle' is not a repo and cannot be removed by antidote."
print -ru2 "antidote: error: '$bundle' is not a repo and cannot be removed by antidote."
return 2
fi

local bundledir=$(__antidote_bundle_dir $bundle)
if [[ ! -d "$bundledir" ]]; then
print >&2 "antidote: error: $bundle does not exist at the expected location: $bundledir"
print -ru2 "antidote: error: $bundle does not exist at the expected location: $bundledir"
return 1
fi

Expand All @@ -74,7 +74,7 @@
# attempt to comment out the bundle from .zsh_plugins.txt
if [[ -e "$bundlefile" ]]; then
local tmpfile="${bundlefile}.antidote.tmp"
awk -v pat="$bundle" '$0~"^[[:blank:]]*"pat{print "# " $0;next}1' <$bundlefile >|$tmpfile
$__adote_awkcmd -v pat="$bundle" '$0~"^[[:blank:]]*"pat{print "# " $0;next}1' <$bundlefile >|$tmpfile
mv -f "$tmpfile" "$bundlefile" || rm -f "$tmpfile"
print "Bundle '$bundle' was commented out in '$bundlefile'."
fi
Expand Down
6 changes: 3 additions & 3 deletions functions/antidote-script
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@

local supported_kind_vals=(autoload clone defer fpath path zsh)
if (( $#o_kind )) && ! (( $supported_kind_vals[(Ie)$o_kind[-1]] )); then
print >&2 "antidote: error: unexpected kind value: '$o_kind[-1]'" && return 1
print -ru2 "antidote: error: unexpected kind value: '$o_kind[-1]'" && return 1
fi

local bundle=$1
if [[ -z "$bundle" ]]; then
print >&2 "antidote: error: bundle argument expected" && return 1
print -ru2 "antidote: error: bundle argument expected" && return 1
fi
local bundle_name=$(__antidote_bundle_name $bundle)

Expand All @@ -68,7 +68,7 @@
bundle_type="$(__antidote_bundle_type $bundle)"
if [[ "$bundle_type" == (repo|url|sshurl) ]] && [[ ! -e "$bundle_path" ]]; then
local giturl=$(__antidote_tourl $bundle)
print >&2 "# antidote cloning $bundle_name..."
print -ru2 "# antidote cloning $bundle_name..."
git clone --quiet --depth 1 --recurse-submodules --shallow-submodules $o_branch $giturl $bundle_path
[[ $? -eq 0 ]] || return 1
fi
Expand Down
6 changes: 3 additions & 3 deletions man/antidote-bundle.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ header: Antidote Manual
**antidote-bundle** assembles your Zsh plugins. Bundles can be git repos, or local files or dirctories. If a plugin is a repo, it will be cloned if necessary. The zsh code necessary to load (source) the plugin is then printed.

| antidote bundle gituser/gitrepo
| antidote bundle ${ZDOTDIR:-}/.zplugins/myplugin
| antidote bundle ${ZDOTDIR:-~}/.zlibs/myfile.zsh
| antidote bundle $ZSH_CUSTOM/plugins/myplugin
| antidote bundle ${ZDOTDIR:-\$HOME}/.zlibs/myfile.zsh

Bundles also support annotations. Annotations allow you have finer grained control over your plugins. Annotations are used in the form \'keyword:value\'.

Expand Down Expand Up @@ -94,7 +94,7 @@ Using the **conditional:** annotation...

| # define a conditional function prior to loading antidote
| function is_macos {
| [[ $OSTYPE == darwin* ]] && return 0 || return 1
| [[ $OSTYPE == darwin* ]] || return 1
| }
|
| # conditionally load a plugin using the function you made
Expand Down
2 changes: 1 addition & 1 deletion man/antidote-install.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ header: Antidote Manual
: Bundle to be installed.

[\<bundlefile\>]
: Bundle file to write to if not using the default. Defaults to **${ZDOTDIR:-~}/.zsh_plugins.txt** or zstyle setting.
: Bundle file to write to if not using the default. Defaults to **${ZDOTDIR:-\$HOME}/.zsh_plugins.txt** or zstyle setting.

# EXAMPLES

Expand Down
12 changes: 6 additions & 6 deletions man/antidote-load.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,23 @@ header: Antidote Manual

**antidote-load** will turn the bundle file into a static load file and then source it.

The default bundle file is **${ZDOTDIR:-~}/.zsh_plugins.txt**. This can be overridden with the following **zstyle**:
The default bundle file is **${ZDOTDIR:-\$HOME}/.zsh_plugins.txt**. This can be overridden with the following **zstyle**:

| bundlefile=~/.zplugins
| zstyle ':antidote:bundle' file $bundlefile
| zstyle \':antidote:bundle\' file $bundlefile

The default static file is **${ZDOTDIR:-~}/.zsh_plugins.zsh**. This can be overridden with the following **zstyle**:
The default static file is **${ZDOTDIR:-\$HOME}/.zsh_plugins.zsh**. This can be overridden with the following **zstyle**:

| staticfile=~/.zplugins.zsh
| zstyle ':antidote:static' file $staticfile
| zstyle \':antidote:static\' file $staticfile

# OPTIONS

-h, \--help
: Show the help documentation.

[\<bundlefile\>]
: The plugins file to source if not using the default. Defaults to **${ZDOTDIR:-~}/.zsh_plugins.txt** or zstyle setting.
: The plugins file to source if not using the default. Defaults to **${ZDOTDIR:-\$HOME}/.zsh_plugins.txt** or zstyle setting.

[\<staticfile\>]
: The static plugins file to generate if not using the default. Defaults to **${ZDOTDIR:-~}/.zsh_plugins.zsh** or zstyle setting.
: The static plugins file to generate if not using the default. Defaults to **${ZDOTDIR:-\$HOME}/.zsh_plugins.zsh** or zstyle setting.
10 changes: 5 additions & 5 deletions man/antidote.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,22 +66,22 @@ It is written natively in Zsh, is well tested, and picks up where Antigen and An

Create a _.zsh_plugins.txt_ file with a list of the plugins you want:

| # ${ZDOTDIR:-~}/.zsh_plugins.txt
| # ${ZDOTDIR:-\$HOME}/.zsh_plugins.txt
| zsh-users/zsh-syntax-highlighting
| zsh-users/zsh-history-substring-search
| zsh-users/zsh-autosuggestions

Now, simply load your newly created static plugins file in your _.zshrc_.

| # ${ZDOTDIR:-~}/.zshrc
| # ${ZDOTDIR:-\$HOME}/.zshrc
| source /path/to/antidote/antidote.zsh
| antidote load

## A More Advanced Config

Your _.zsh_plugins.txt_ file supports annotations. Annotations tell antidote how to do things like load plugins from alternate paths. This lets you use plugins from popular frameworks like Oh-My-Zsh:

| # ${ZDOTDIR:-~}/.zsh_plugins.txt
| # ${ZDOTDIR:-\$HOME}/.zsh_plugins.txt
| ohmyzsh/ohmyzsh path:lib
| ohmyzsh/ohmyzsh path:plugins/git
| ohmyzsh/ohmyzsh path:plugins/magic-enter
Expand Down Expand Up @@ -114,11 +114,11 @@ Instead of calling **antidote bundle** over and over, you might prefer to load b

To install antidote you can clone it with git:

| git clone --depth=1 https://github.com/mattmc3/antidote.git ${ZDOTDIR:-~}/.antidote
| git clone --depth=1 https://github.com/mattmc3/antidote.git ${ZDOTDIR:-\$HOME}/.antidote

Then, simply add the following snippet to your .zshrc:

| source ${ZDOTDIR:-~}/.antidote/antidote.zsh
| source ${ZDOTDIR:-\$HOME}/.antidote/antidote.zsh
| antidote load

# SEE ALSO
Expand Down
Loading