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

antidote version 1.9.7 #191

Merged
merged 28 commits into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
3c463cb
Fix #181: Use regular green
mattmc3 Jul 16, 2024
2ddee05
Build manpages
mattmc3 Jul 16, 2024
620ded1
Fix type-o
mattmc3 Jul 16, 2024
fd90f64
Support zstyle to customize zsh-defer repo
mattmc3 Jul 17, 2024
aa2c3f6
Add test for replacing zsh-defer bundle
mattmc3 Jul 17, 2024
7b9bdd8
Document zstyle customizations
mattmc3 Jul 17, 2024
eba675e
Add new-style test directory
mattmc3 Jul 17, 2024
28c1693
Rename antidote core tests
mattmc3 Jul 17, 2024
cb22fa6
Change altered defer test
mattmc3 Jul 17, 2024
3b40b1a
Remove :use tests for now
mattmc3 Jul 17, 2024
75fd245
Make git mock for remote.origin.url better
mattmc3 Jul 17, 2024
bf98032
Add file to bumpversion
mattmc3 Jul 17, 2024
eddf494
Add legacy antibody test directories
mattmc3 Jul 17, 2024
672e207
Remove unused test functions
mattmc3 Jul 17, 2024
dd19bb1
Fix test data
mattmc3 Jul 18, 2024
ea73a03
Remove legacy test files
mattmc3 Jul 18, 2024
f3a8695
Update test data
mattmc3 Jul 18, 2024
286fc72
Update test functions
mattmc3 Jul 18, 2024
e86ec8d
Update tests
mattmc3 Jul 18, 2024
73be192
Add simple master test that also serves as proper usage docs
mattmc3 Jul 18, 2024
e0ea712
Pretty print bundle output with `$HOME` variable
mattmc3 Jul 18, 2024
773dd7b
Fix fpath rules
mattmc3 Jul 18, 2024
f6117f4
Add fpath rule tests
mattmc3 Jul 18, 2024
3b2de5a
Ensure `rm` and `mv` always use the base command
mattmc3 Jul 18, 2024
6cf8d24
Add rm wrapper `__antidote_del`
mattmc3 Jul 18, 2024
95c75f7
Bump version to 1.9.7
mattmc3 Jul 18, 2024
e305f98
Update readme
mattmc3 Jul 18, 2024
f828798
Only emit $HOME when not in compatibility mode
mattmc3 Jul 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 1.9.6
current_version = 1.9.7
parse = v?(?P<major>\d+)\.(?P<minor>\d+)\.(?P<revision>\d+)
serialize = {major}.{minor}.{revision}

Expand All @@ -9,6 +9,8 @@ serialize = {major}.{minor}.{revision}

[bumpversion:file:tests/test_antidote.md]

[bumpversion:file:tests/test_antidote_core.md]

[bumpversion:file:tests/test_cmd_update.md]

[bumpversion:file:README.md]
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
*.zwc
*.zwc.old
.cache/
!/tests/**/.cache/
.tmp/
.plugins/
.todo/
Expand Down
44 changes: 32 additions & 12 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.6-df5e88)
![version](https://img.shields.io/badge/version-v1.9.7-df5e88)

<a title="GetAntidote"
href="https://getantidote.github.io"
Expand All @@ -14,27 +14,44 @@

> [Get the cure][getantidote]</blockquote>

[Antidote][getantidote] is a feature-complete Zsh implementation of the legacy [Antibody][antibody] plugin manager, which in turn was derived from [Antigen][antigen]. Antidote not only aims to provide continuity for those legacy plugin managers, but also to delight new users with high-performance, easy-to-use Zsh plugin management.
[Antidote][getantidote] is a feature-complete Zsh implementation of the legacy
[Antibody][antibody] plugin manager, which in turn was derived from [Antigen][antigen].
Antidote not only aims to provide continuity for those legacy plugin managers, but also
to delight new users with high-performance, easy-to-use Zsh plugin management.

## NOTICE

**The planned upcoming 2.0 release will stop defaulting to compatibility with antibody.** If maintaining compatibility with antibody is important to you, you can ensure that your config remains compatible by add the following `zstyle` to your config **now**, before the 2.0 release goes live:
**The planned upcoming 2.0 release will stop defaulting to compatibility with
antibody.** If maintaining compatibility with antibody is important to you, you can
ensure that your config remains compatible by add the following `zstyle` to your config
**now**, before the 2.0 release goes live:

```zsh
zstyle ':antidote:compatibility-mode' 'antibody'
zstyle ':antidote:compatibility-mode' 'antibody' 'on'
```

Breaking compatibility by default will allow antidote to continue to grow and gain new features, as well as fix some long-standing issues that have always been present in antibody, for example:

- In 2.0, `fpath` can be fully set at the beginning of your bundles in you static file, making setting up completion bundles properly way easier and less frustrating ([#74](https://github.com/mattmc3/antidote/discussions/74), [#144](https://github.com/mattmc3/antidote/issues/144)).
- bundles will no longer default to using fugly directory names ($ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-foo-SLASH-bar), making `zstyle ':antidote:bundle' use-friendly-names on` obsolete.
Breaking compatibility by default will allow antidote to continue to grow and gain new
features, as well as fix some long-standing issues that have always been present in
antibody, for example:

- In 2.0, `fpath` can be fully set at the beginning of your bundles in you static file,
making setting up completion bundles properly way easier and less frustrating
([#74](https://github.com/mattmc3/antidote/discussions/74),
[#144](https://github.com/mattmc3/antidote/issues/144)).
- bundles will no longer default to using fugly directory names
($ANTIDOTE_HOME/https-COLON--SLASH--SLASH-github.com-SLASH-foo-SLASH-bar), making
`zstyle ':antidote:bundle' use-friendly-names on` obsolete.
- probably some other minor deviations as well

Just to be clear, if you don't specifically care about backwards compatibility with antibody, you do not need to change a thing. 2.x will not break your 1.x antidote config. If you do care, be sure to add the compatibility mode `zstyle` above to your config **now**, before the 2.0 release.
Just to be clear, if you don't specifically care about backwards compatibility with
antibody, you do not need to change a thing. 2.x will not break your 1.x antidote
config. If you do care, be sure to add the compatibility mode `zstyle` above to your
config **now**, before the 2.0 release.

## Usage

Basic usage should look really familiar to you if you have used Antibody or Antigen. Bundles (aka: Zsh plugins) are stored in a file typically called `.zsh_plugins.txt`.
Basic usage should look really familiar to you if you have used Antibody or Antigen.
Bundles (aka: Zsh plugins) are stored in a file typically called `.zsh_plugins.txt`.

```zsh
# .zsh_plugins.txt
Expand Down Expand Up @@ -63,7 +80,10 @@ The full documentation can be found at [https://getantidote.github.io][getantido

## Help getting started

If you want to see a full-featured example Zsh configuration using antidote, you can have a look at this [example zdotdir](https://github.com/getantidote/zdotdir) project. Feel free to incorporate code or plugins from it into your own dotfiles, or you can fork it to get started building your own Zsh config from scratch driven by antidote.
If you want to see a full-featured example Zsh configuration using antidote, you can
have a look at this [example zdotdir](https://github.com/getantidote/zdotdir) project.
Feel free to incorporate code or plugins from it into your own dotfiles, or you can fork
it to get started building your own Zsh config from scratch driven by antidote.

## Installation

Expand Down Expand Up @@ -130,7 +150,7 @@ antidote install https://bitbucket.org/bb_user/bb_repo

## Credits

A big thank you to [Carlos](https://twitter.com/caarlos0) for all his work on
A big thank you to [Carlos](https://github.com/caarlos0) for all his work on
[antibody] over the years.

[antigen]: https://github.com/zsh-users/antigen
Expand Down
9 changes: 7 additions & 2 deletions functions/__antidote_bulk_clone
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@
#function __antidote_bulk_clone {
emulate -L zsh; setopt local_options $_adote_funcopts

# Allow the user to define zsh-defer repo in case they want to fork it.
local zsh_defer_bundle
zstyle -s ':antidote:defer' bundle 'zsh_defer_bundle' \
|| zsh_defer_bundle='romkatv/zsh-defer'

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

# initialize vars
Expand All @@ -15,7 +20,7 @@
/^ *(#.+)?$/ { next }

# clone zsh-defer
/kind:defer/ { print "antidote-script --kind clone romkatv/zsh-defer &" }
/kind:defer/ { print "antidote-script --kind clone " ZSH_DEFER_BUNDLE " &" }

# handle user/repo and URL forms
$1~/^[^\/]+\/[^\/]+$/ { bundle=$1 }
Expand Down
32 changes: 32 additions & 0 deletions functions/__antidote_del
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/zsh
# Call me paranoid, but I want to be really certain antidote will never rm something it
# shouldn't. This function wraps rm to double check that any paths being removed are
# valid. If it's not in your $HOME or $TMPDIR, we need to block it.

#function __antidote_del {
emulate -L zsh; setopt local_options

local -a rmflags rmpaths
local p

while (( $# )); do
case "$1" in
--) shift; break ;;
-*) rmflags+=($1) ;;
*) break ;;
esac
shift
done

(( $# > 0 )) || return 1

for p in $@; do
p="${p:a}"
if [[ "$p" != $HOME/* ]] && [[ "$p" != ${TMPDIR:-/tmp}/* ]]; then
print -ru2 -- "antidote: Blocked attempt to rm path: '$p'."
return 1
fi
done

command rm ${rmflags[@]} -- "$@"
#}
2 changes: 1 addition & 1 deletion functions/__antidote_load_prep
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
if [[ ! $staticfile -nt $bundlefile ]] || [[ $force_bundle -eq 1 ]]; then
antidote bundle <"$bundlefile" >|"$staticfile"
if [[ -r "${staticfile}.zwc" ]] && ! zstyle -t ':antidote:static' zcompile; then
command rm -f -- "${staticfile}.zwc"
__antidote_del -f -- "${staticfile}.zwc"
fi
fi

Expand Down
8 changes: 8 additions & 0 deletions functions/__antidote_print_path
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/zsh
### Pretty print a path

if zstyle -t ':antidote:compatibility-mode' 'antibody'; then
echo "$1"
else
echo "$1" | sed -e "s|^$HOME/|\$HOME/|"
fi
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.6'
local ver='1.9.7'
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
8 changes: 4 additions & 4 deletions functions/antidote-purge
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
}
[[ ${REPLY:u} == "Y" ]] || return 1
# remove antidote home and static cache file
command rm -rf -- "$antidote_home"
__antidote_del -rf -- "$antidote_home"

if [[ -e "${bundlefile:r}.zsh" ]]; then
zstyle -s ':antidote:purge:all' answer 'REPLY' || {
Expand All @@ -47,7 +47,7 @@
}
if [[ ${REPLY:u} == "Y" ]]; then
local dtstmp=$(date -u '+%Y%m%d_%H%M%S')
mv -f "${bundlefile:r}.zsh" "${bundlefile:r}.${dtstmp}.bak"
command mv -f "${bundlefile:r}.zsh" "${bundlefile:r}.${dtstmp}.bak"
print "'"${bundlefile:r}.zsh"' backed up to '${bundlefile:t:r}.${dtstmp}.bak'"
fi
fi
Expand All @@ -68,14 +68,14 @@
fi

# remove
command rm -rf "$bundledir"
__antidote_del -rf "$bundledir"
print "Removed '$bundle'."

# attempt to comment out the bundle from .zsh_plugins.txt
if [[ -e "$bundlefile" ]]; then
local tmpfile="${bundlefile}.antidote.tmp"
$__adote_awkcmd -v pat="$bundle" '$0~"^[[:blank:]]*"pat{print "# " $0;next}1' <$bundlefile >|$tmpfile
mv -f "$tmpfile" "$bundlefile" || rm -f "$tmpfile"
command mv -f "$tmpfile" "$bundlefile" || __antidote_del -f "$tmpfile"
print "Bundle '$bundle' was commented out in '$bundlefile'."
fi
fi
Expand Down
50 changes: 36 additions & 14 deletions functions/antidote-script
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@
print -ru2 "antidote: error: unexpected kind value: '$o_kind[-1]'" && return 1
fi

# If no fpath_rule is set, use the zstyle
if ! (( $#o_fpath_rule )); then
local zstyle_fpath_rule
zstyle -s ':antidote:fpath' rule 'zstyle_fpath_rule'
[[ -z "$zstyle_fpath_rule" ]] || o_fpath_rule=($zstyle_fpath_rule)
fi

local supported_fpath_rules=(append prepend)
if ! (( $supported_fpath_rules[(Ie)$o_fpath_rule[-1]] )); then
print -ru2 "antidote: error: unexpected fpath rule: '$o_fpath_rule[-1]'" && return 1
Expand Down Expand Up @@ -107,63 +114,78 @@

# handle defers
local source_cmd="source"
local zsh_defer_bundle
zstyle -s ':antidote:defer' bundle 'zsh_defer_bundle' \
|| zsh_defer_bundle='romkatv/zsh-defer'
if [[ "$o_kind[-1]" == "defer" ]]; then
source_cmd="${zsh_defer} source"
script+=(
'if ! (( $+functions[zsh-defer] )); then'
"$(antidote-script 'romkatv/zsh-defer' | __antidote_indent)"
"$(antidote-script $zsh_defer_bundle | __antidote_indent)"
'fi'
)
fi

# Let's make the path a little nicer to deal with
local print_bundle_path="$(__antidote_print_path "$bundle_path")"

# handle autoloading before sourcing
if (( $#o_autoload )); then
if [[ "$o_fpath_rule[-1]" == prepend ]]; then
script+=("fpath=( ${bundle_path}/${o_autoload[-1]} \$fpath )")
script+=("fpath=( ${print_bundle_path}/${o_autoload[-1]} \$fpath )")
script+=("builtin autoload -Uz \$fpath[1]/*(N.:t)")
else
script+=("fpath+=( ${bundle_path}/${o_autoload[-1]} )")
script+=("fpath+=( ${print_bundle_path}/${o_autoload[-1]} )")
script+=("builtin autoload -Uz \$fpath[-1]/*(N.:t)")
fi
script+=( "builtin autoload -Uz \$fpath[-1]/*(N.:t)" )
fi

# generate load script
bundle_type="$(__antidote_bundle_type $bundle_path)"
local fpath_script
if [[ "$o_fpath_rule[-1]" == prepend ]]; then
fpath_script="fpath=( $bundle_path \$fpath )"
fpath_script="fpath=( $print_bundle_path \$fpath )"
else
fpath_script="fpath+=( $bundle_path )"
fpath_script="fpath+=( $print_bundle_path )"
fi

if [[ "$o_kind[-1]" == fpath ]]; then
# fpath
script+="$fpath_script"
elif [[ "$o_kind[-1]" == path ]]; then
# path
script+="export PATH=\"$bundle_path:\$PATH\""
script+="export PATH=\"$print_bundle_path:\$PATH\""
elif [[ "$o_kind[-1]" == autoload ]]; then
# autoload
script+=(
"$fpath_script"
"builtin autoload -Uz \$fpath[-1]/*(N.:t)"
)
script+=("$fpath_script")
if [[ "$o_fpath_rule[-1]" == prepend ]]; then
script+=("builtin autoload -Uz \$fpath[1]/*(N.:t)")
else
script+=("builtin autoload -Uz \$fpath[-1]/*(N.:t)")
fi
else
if zstyle -t ":antidote:bundle:$bundle" zcompile; then
__antidote_bundle_zcompile $bundle_path
fi
if [[ $bundle_type == file ]]; then
script+="$source_cmd $bundle_path"
script+="$source_cmd $print_bundle_path"
else
# directory/default
local initfile initfiles
initfiles=(${(@f)$(__antidote_initfiles $bundle_path)})
# if no init file was found, assume the default
if [[ $#initfiles -eq 0 ]]; then
initfiles=($bundle_path/${bundle_path:t}.plugin.zsh)
if (( $#o_path )); then
initfiles=($bundle_path/${bundle_path:t}.plugin.zsh)
else
initfiles=($bundle_path/${bundle_name:t}.plugin.zsh)
fi
fi
script+="$fpath_script"
local print_initfile
for initfile in $initfiles; do
script+="$source_cmd $initfile"
print_initfile="$(__antidote_print_path "$initfile")"
script+="$source_cmd $print_initfile"
done
fi
fi
Expand Down
14 changes: 8 additions & 6 deletions functions/antidote-update
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,12 @@
fi

# colors
local bold green normal
local green normal
if [[ $TERM = *256color* || $TERM = *rxvt* ]]; then
if (( $+commands[tput] )); then
bold=$(tput bold)
green=$(tput setaf 2)
normal=$(tput sgr0)
else
bold=$'\E\[1m'
green=$'\E[32m'
normal=$'\E[0m'
fi
Expand All @@ -39,7 +37,11 @@
local bundledir url repo

# remove zcompiled files
rm -rf -- $(antidote-home)/**/*.zwc(N)
__antidote_del -rf -- $(antidote-home)/**/*.zwc(N)

# remove check file
local loadable_check_path="$(antidote-home)/.antidote.load"
[[ -r "$loadable_check_path" ]] && __antidote_del -- "$loadable_check_path"

# update all bundles
for bundledir in $(antidote-list --dirs); do
Expand All @@ -51,7 +53,7 @@
git -C "$1" pull --quiet --ff --rebase --autostash
local newsha=$(git -C "$1" rev-parse --short HEAD)
if [[ $oldsha != $newsha ]]; then
print "${bold}${green}antidote: updated: $2 ${oldsha} -> ${newsha}${normal}"
print "${green}antidote: updated: $2 ${oldsha} -> ${newsha}${normal}"
git -C "$1" --no-pager log --oneline --ancestry-path ${oldsha}..${newsha} 2>/dev/null
fi

Expand All @@ -64,7 +66,7 @@
print "Waiting for bundle updates to complete..."
print ""
wait
print "${bold}${green}Bundle updates complete.${normal}"
print "${green}Bundle updates complete.${normal}"
print ""
fi

Expand Down
2 changes: 1 addition & 1 deletion makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@ bump-min:
bump-rev:
./tools/bumpver revision

##? bumpber bump the revision version (0.0.X)
##? bumpver bump the revision version (0.0.X)
bumpver:
./tools/bumpver revision
Loading
Loading