-
Notifications
You must be signed in to change notification settings - Fork 34
Closed
Description
i made a command that excepts antigen commands and runs the antidote equivalent command most plugins don't have antidote install commands but do have antigen commands this script just runs the equivalent command
save it as antigen and make it runnable and add it to the PATH
#!/bin/zsh
# Global style tracker
[[ -d ${ZDOTDIR:-$HOME}/.antidote ]] ||
git clone https://github.com/mattmc3/antidote ${ZDOTDIR:-$HOME}/.antidote
source ~/.antidote/antidote.zsh
ANTIGEN_STYLE="omz"
function antigen_main() {
if [[ $1 == use ]]; then
shift
case "$1" in
omz) ANTIGEN_STYLE="omz" ;;
prezto) ANTIGEN_STYLE="prezto" ;;
*) ANTIGEN_STYLE="" ;;
esac
echo "[antigen compat] set ANTIGEN_STYLE=$ANTIGEN_STYLE"
return
fi
if [[ $1 == bundle ]]; then
shift
local url="" loc="" branch="" kind=""
while [[ $# -gt 0 ]]; do
case $1 in
--url=*) url="${1#--url=}" ;;
--loc=*) loc="${1#--loc=}" ;;
--branch=*) branch="${1#--branch=}" ;;
--defer) kind="kind:defer" ;;
--clone) kind="kind:clone" ;;
--path) kind="kind:path" ;;
--fpath) kind="kind:fpath" ;;
--no-local-clone) ;; # no-op for antidote
--*) echo "Unsupported option: $1" >&2 ;;
*)
if [[ -z $url ]]; then
if [[ "$1" == *"/"* ]]; then
url="$1"
else
if [[ $ANTIGEN_STYLE == "omz" ]]; then
url="ohmyzsh/ohmyzsh"
loc="plugins/$1"
elif [[ $ANTIGEN_STYLE == "prezto" ]]; then
url="sorin-ionescu/prezto"
loc="modules/$1"
else
url="$1"
fi
fi
elif [[ -z $loc ]]; then
loc="$1"
fi
;;
esac
shift
done
if [[ -z $url ]]; then
echo "[antigen compat] Error: missing URL or plugin name" >&2
return 1
fi
local args=("$url")
[[ -n $loc ]] && args+=("path:$loc")
[[ -n $branch ]] && args+=("branch:$branch")
[[ -n $kind ]] && args+=("$kind")
local joined="${(j: :)args}"
echo "[antigen compat] antidote install \"$joined\""
# Uncomment to run:
antidote install "$joined"
return
fi
if [[ $1 == snapshot ]]; then
local snapshot_dir="$HOME/.zsh_snapshots"
local timestamp=$(date +%Y%m%d_%H%M%S)
local snapshot_file="$snapshot_dir/zsh_snapshot_$timestamp.zip"
echo "[antigen compat] Creating snapshot..."
mkdir -p "$snapshot_dir"
local base_files=("$HOME/.zshrc" "$HOME/.zsh_plugins.txt")
local files=()
# Check base files
for f in "${base_files[@]}"; do
if [[ -f "$f" ]]; then
files+=("$f")
else
echo "[antigen compat] Warning: base file missing: $f" >&2
fi
done
# Extract sourced files from .zshrc
local sourced_files=($(grep -E '^\s*(source|\.)\s+' "$HOME/.zshrc" 2>/dev/null | awk '{print $2}'))
for f in "${sourced_files[@]}"; do
[[ "$f" == *'$'* ]] && echo "[antigen compat] Skipping variable path: $f" >&2 && continue
[[ "$f" == ~* ]] && f="${HOME}${f#~}"
[[ "$f" != /* ]] && f="$HOME/$f"
if [[ -f "$f" ]]; then
[[ ! " ${files[*]} " =~ " $f " ]] && files+=("$f")
else
echo "[antigen compat] Warning: sourced file missing: $f" >&2
fi
done
# Process .zsh_snapshot_files
local snapshot_list="$HOME/.zsh_snapshot_files"
if [[ -f "$snapshot_list" ]]; then
while IFS= read -r line || [[ -n $line ]]; do
line="${line%%#*}"
line="${line%%*( )}"
line="${line##*( )}"
[[ -z $line ]] && continue
[[ "$line" == *'$'* ]] && echo "[antigen compat] Skipping variable path: $line" >&2 && continue
[[ "$line" == ~* ]] && line="${HOME}${line#~}"
[[ "$line" != /* ]] && line="$HOME/$line"
if [[ -f "$line" ]]; then
[[ ! " ${files[*]} " =~ " $line " ]] && files+=("$line")
else
echo "[antigen compat] Warning: snapshot file missing: $line" >&2
fi
done < "$snapshot_list"
files+=("$snapshot_list")
fi
# Create the zip archive
zip -j "$snapshot_file" "${files[@]}" >/dev/null
if [[ $? -eq 0 ]]; then
echo "[antigen compat] Snapshot saved to $snapshot_file"
else
echo "[antigen compat] Error creating snapshot" >&2
fi
return
fi
if [[ $1 == apply ]]; then
echo "[antigen compat] Running antidote load"
antidote load < ~/.zsh_plugins.txt
return
fi
if [[ $1 == help || -z $1 ]]; then
cat <<EOF
[antigen compat] Supported commands:
antigen use omz|prezto
Set plugin style for short bundle names.
Example: antigen use omz
antigen bundle [options] <name or repo>
Add a plugin or library (respects ANTIGEN_STYLE).
Options:
--url=URL GitHub repo URL (e.g. user/repo)
--loc=DIR Path inside repo to load (e.g. plugins/foo)
--branch=BRANCH Branch to use
--defer Mark for deferred loading (antidote defer)
--fpath Mark as fpath plugin
--path Mark as static path
--clone Mark for early cloning
--no-local-clone (ignored)
antigen apply
Load plugins from ~/.zsh_plugins.txt using antidote.
antigen snapshot
Create a snapshot of current Zsh setup.
Includes:
- ~/.zshrc
- ~/.zsh_plugins.txt
- Files sourced in ~/.zshrc
- Files listed in ~/.zsh_snapshot_files
Notes:
- Ignores paths containing variables (e.g. \$HOME, \$ZSH)
- Warns on missing files but continues
antigen help
Show this help message.
EOF
return
fi
echo "[antigen compat] unknown antigen command: $1" >&2
}
antigen_main "$@"Metadata
Metadata
Assignees
Labels
No labels