mattmc3 / antidote

https://getantidote.github.io - the cure to slow zsh plugin management
MIT License
855 stars 21 forks source link

antidote prints to the console instead of applying it #164

Closed himekifee closed 9 months ago

himekifee commented 10 months ago

Hi. I have a minimum .zshrc file like the following

# Clone antidote if necessary.
[[ -e ${ZDOTDIR:-~}/.antidote ]] ||
  git clone https://github.com/mattmc3/antidote.git ${ZDOTDIR:-~}/.antidote

# Source antidote.
source ${ZDOTDIR:-~}/.antidote/antidote.zsh

When I run antidote bundle zimfw/bira, it prints the following to the console instead of running the two commands

XX% antidote bundle zimfw/bira
fpath+=( /home/grider/.cache/antidote/https-COLON--SLASH--SLASH-github.com-SLASH-zimfw-SLASH-bira )
source /home/grider/.cache/antidote/https-COLON--SLASH--SLASH-github.com-SLASH-zimfw-SLASH-bira/bira.zsh-theme

If run after set -x, it looks like the following

XX% set -x
XX% antidote bundle zimfw/bira
+/bin/zsh:5> antidote bundle zimfw/bira
+antidote:11> 0=/home/grider/.antidote/functions/antidote 
+antidote:12> typeset -f antidote-main
+antidote:15> antidote-main bundle zimfw/bira
+antidote-main:9> 0=/home/grider/.antidote/functions/antidote-main 
+antidote-main:11> [[ -o KSH_ARRAYS ]]
+antidote-main:12> [[ -o SH_GLOB ]]
+antidote-main:14> local o_help o_version
+antidote-main:15> zparseopts -D -M -F -- 'h=o_help' '-help=h' 'v=o_version' '-version=v'
+antidote-main:20> local ret=0
+antidote-main:22> ((  0  ))
+antidote-main:25> ((  0  ))
+antidote-main:28> [[ 2 -eq 0 ]]
+antidote-main:32> [[ bundle = help ]]
+antidote-main:36> ((  1  ))
+antidote-main:37> local cmd=bundle
+antidote-main:37> shift
+antidote-main:38> antidote-bundle zimfw/bira
+antidote-bundle:11> emulate -L zsh
+antidote-bundle:11> setopt local_options extended_glob no_monitor pipefail
+antidote-bundle:13> local o_help
+antidote-bundle:14> zparseopts -D -M -F -- 'h=o_help' '-help=h'
+antidote-bundle:16> ((  0  ))
+antidote-bundle:23> local -a bundles=( )
+antidote-bundle:24> ((  1 > 0  ))
+antidote-bundle:25> bundles=( zimfw/bira ) 
+antidote-bundle:32> ((  1  ))
+antidote-bundle:35> ((  1 > 1  ))
+antidote-bundle:40> __antidote_filter_defers
+__antidote_filter_defers:5> emulate -L zsh
+__antidote_filter_defers:5> setopt local_options extended_glob no_monitor pipefail
+antidote-bundle:40> source /proc/self/fd/14
+__antidote_filter_defers:6> gawk $'\n    # filter all but the first time we source zsh-defer (a 4 line if statement)\n    BEGIN   { skip=0; found=0 }\n    skip>0  { skip-- }\n    /^if.+functions\\[zsh\\-defer\\]/ { if(!found) found=1; else skip=4 }\n    skip==0 { print }\n  '
+antidote-bundle:40> __antidote_parse_bundles
+antidote-bundle:40> printf '%s\n' zimfw/bira
+__antidote_parse_bundles:5> emulate -L zsh
+__antidote_parse_bundles:5> setopt local_options extended_glob no_monitor pipefail
+__antidote_parse_bundles:6> gawk $'\n    BEGIN { RS="[\\r\\n]" }\n\n    # skip comments and empty lines\n    /^ *$/ || /^ *#/ {next}\n\n    # strip trailing comments\n    { sub(/[ \\t]#.*$/,"",$0) }\n\n    # escape leading $ variables\n    { sub(/^\\$/,"\\\\$",$0) }\n\n    # handle extension functionality (eg :use ohmyzsh)\n    $1~/^:/ {\n      sub(/^:/,"",$1)\n      printf "antidote-script-" $1\n      for (i=2; i<=NF; i++) {\n        printf " %s",$i\n      }\n      printf "\\n"\n      next\n    }\n\n    # move flags to front and call antidote-script\n    {\n      sub(/ #.*$/,"",$0)\n      printf "antidote-script"\n      for (i=2; i<=NF; i++) {\n        sub(/^/,"--",$i)\n        sub(/:/," ",$i)\n        printf " %s",$i\n      }\n      printf " %s\\n",$1\n    }\n  '
+/proc/self/fd/14:1> antidote-script zimfw/bira
+antidote-script:17> emulate -L zsh
+antidote-script:17> setopt local_options extended_glob no_monitor pipefail
+antidote-script:18> local MATCH MBEGIN MEND
+antidote-script:18> local -a match mbegin mend
+antidote-script:19> local REPLY=''
+antidote-script:21> local o_help o_kind o_path o_branch o_cond o_autoload o_pre o_post
+antidote-script:22> zparseopts -D -M -F -- 'h=o_help' '-help=h' 'a:=o_autoload' '-autoload:=a' 'b:=o_branch' '-branch:=b' 'k:=o_kind' '-kind:=k' 'p:=o_path' '-path:=p' '-pre:=o_pre' '-post:=o_post' 'c:=o_cond' '-conditional:=c'
+antidote-script:34> ((  0  ))
+antidote-script:34> o_kind=( --kind zsh ) 
+antidote-script:37> local re='^[=:]?(.+)$'
+antidote-script:38> [[ $o_kind[-1] -regex-match $re ]]
+antidote-script:38> o_kind[-1]=zsh 
+antidote-script:39> [[ $o_autoload[-1] -regex-match $re ]]
+antidote-script:40> [[ $o_path[-1] -regex-match $re ]]
+antidote-script:41> [[ $o_cond[-1] -regex-match $re ]]
+antidote-script:42> [[ $o_branch[-1] -regex-match $re ]]
+antidote-script:43> [[ $o_pre[-1] -regex-match $re ]]
+antidote-script:44> [[ $o_post[-1] -regex-match $re ]]
+antidote-script:46> local supported_kind_vals=( autoload clone defer fpath path zsh )
+antidote-script:47> ((  2  ))
+antidote-script:47> ((  6  ))
+antidote-script:51> local bundle=zimfw/bira
+antidote-script:52> [[ -z zimfw/bira ]]
+antidote-script:55> __antidote_bundle_name zimfw/bira
+__antidote_bundle_name:5> emulate -L zsh
+__antidote_bundle_name:5> setopt local_options extended_glob no_monitor pipefail
+__antidote_bundle_name:6> local MATCH MBEGIN MEND
+__antidote_bundle_name:6> local -a match mbegin mend
+__antidote_bundle_name:7> local bundle=zimfw/bira
+__antidote_bundle_name:8> __antidote_bundle_type zimfw/bira
+__antidote_bundle_type:15> emulate -L zsh
+__antidote_bundle_type:15> setopt local_options extended_glob no_monitor pipefail
+__antidote_bundle_type:16> local bundle=zimfw/bira
+__antidote_bundle_type:20> [[ zimfw/bira == \~/* ]]
+__antidote_bundle_type:22> [[ zimfw/bira == \$* ]]
+__antidote_bundle_type:27> local result
+__antidote_bundle_type:28> [[ -e zimfw/bira ]]
+__antidote_bundle_type:30> [[ -z zimfw/bira ]]
+__antidote_bundle_type:33> case zimfw/bira ((/|~|\$)*)
+__antidote_bundle_type:33> case zimfw/bira (*://*)
+__antidote_bundle_type:33> case zimfw/bira (*@*:*/*)
+__antidote_bundle_type:33> case zimfw/bira (*(:|@)*)
+__antidote_bundle_type:33> case zimfw/bira (*/*/*)
+__antidote_bundle_type:33> case zimfw/bira (*/)
+__antidote_bundle_type:33> case zimfw/bira (*/*)
+__antidote_bundle_type:40> result=repo 
+__antidote_bundle_type:45> typeset -g REPLY=repo
+__antidote_bundle_type:46> print repo
+__antidote_bundle_name:8> local bundle_type=repo
+__antidote_bundle_name:9> [[ repo == (url|sshurl) ]]
+__antidote_bundle_name:15> print zimfw/bira
+__antidote_bundle_name:15> sed -e 's|^\~/|/home/grider/|' -e 's|^/home/grider|$HOME|'
+antidote-script:55> local bundle_name=zimfw/bira
+antidote-script:58> [[ zimfw/bira == \~/* ]]
+antidote-script:63> local bundle_path
+antidote-script:64> [[ -e zimfw/bira ]]
+antidote-script:64> bundle_path=+antidote-script:64> __antidote_bundle_dir zimfw/bira
+__antidote_bundle_dir:5> emulate -L zsh
+__antidote_bundle_dir:5> setopt local_options extended_glob no_monitor pipefail
+__antidote_bundle_dir:13> local MATCH MBEGIN MEND
+__antidote_bundle_dir:13> local -a match mbegin mend
+__antidote_bundle_dir:15> local bundle=zimfw/bira
+__antidote_bundle_dir:16> __antidote_bundle_type zimfw/bira
+__antidote_bundle_type:15> emulate -L zsh
+__antidote_bundle_type:15> setopt local_options extended_glob no_monitor pipefail
+__antidote_bundle_type:16> local bundle=zimfw/bira
+__antidote_bundle_type:20> [[ zimfw/bira == \~/* ]]
+__antidote_bundle_type:22> [[ zimfw/bira == \$* ]]
+__antidote_bundle_type:27> local result
+__antidote_bundle_type:28> [[ -e zimfw/bira ]]
+__antidote_bundle_type:30> [[ -z zimfw/bira ]]
+__antidote_bundle_type:33> case zimfw/bira ((/|~|\$)*)
+__antidote_bundle_type:33> case zimfw/bira (*://*)
+__antidote_bundle_type:33> case zimfw/bira (*@*:*/*)
+__antidote_bundle_type:33> case zimfw/bira (*(:|@)*)
+__antidote_bundle_type:33> case zimfw/bira (*/*/*)
+__antidote_bundle_type:33> case zimfw/bira (*/)
+__antidote_bundle_type:33> case zimfw/bira (*/*)
+__antidote_bundle_type:40> result=repo 
+__antidote_bundle_type:45> typeset -g REPLY=repo
+__antidote_bundle_type:46> print repo
+__antidote_bundle_dir:16> local bundle_type=repo
+__antidote_bundle_dir:19> [[ repo == (repo|url|sshurl) ]]
+__antidote_bundle_dir:19> [[ ! -e '' ]]
+__antidote_bundle_dir:20> zstyle -t :antidote:bundle use-friendly-names
+__antidote_bundle_dir:34> __antidote_tourl zimfw/bira
+__antidote_tourl:5> emulate -L zsh
+__antidote_tourl:5> setopt local_options extended_glob no_monitor pipefail
+__antidote_tourl:7> local bundle=zimfw/bira
+__antidote_tourl:8> local url=zimfw/bira
+__antidote_tourl:9> [[ zimfw/bira != *://* && zimfw/bira != git@*:*/* ]]
+__antidote_tourl:10> url=https://github.com/zimfw/bira 
+__antidote_tourl:12> print https://github.com/zimfw/bira
+__antidote_bundle_dir:34> local url=https://github.com/zimfw/bira
+__antidote_bundle_dir:35> url=https://github.com/zimfw/bira 
+__antidote_bundle_dir:36> url=https://github.com/zimfw/bira 
+__antidote_bundle_dir:37> url=https-COLON-//github.com/zimfw/bira 
+__antidote_bundle_dir:38> url=https-COLON--SLASH--SLASH-github.com-SLASH-zimfw-SLASH-bira 
+__antidote_bundle_dir:39> antidote-home
+antidote-home:10> emulate -L zsh
+antidote-home:10> setopt local_options extended_glob no_monitor pipefail
+antidote-home:12> typeset -g REPLY=''
+antidote-home:13> local o_help
+antidote-home:14> zparseopts -D -M -F -- 'h=o_help' '-help=h'
+antidote-home:16> ((  0  ))
+antidote-home:21> local result
+antidote-home:22> [[ -n '' ]]
+antidote-home:25> result=+antidote-home:25> __antidote_get_cachedir antidote
+__antidote_get_cachedir:5> emulate -L zsh
+__antidote_get_cachedir:5> setopt local_options extended_glob no_monitor pipefail
+__antidote_get_cachedir:7> local result
+__antidote_get_cachedir:8> [[ linux-gnu == darwin* ]]
+__antidote_get_cachedir:10> [[ linux-gnu == (cygwin|msys)* ]]
+__antidote_get_cachedir:15> [[ -n '' ]]
+__antidote_get_cachedir:18> result=/home/grider/.cache 
+__antidote_get_cachedir:21> [[ -n antidote ]]
+__antidote_get_cachedir:22> [[ /home/grider/.cache == *\\* ]]
+__antidote_get_cachedir:25> result+=/antidote 
+__antidote_get_cachedir:28> print -r -- /home/grider/.cache/antidote
+antidote-home:25> result=/home/grider/.cache/antidote 
+antidote-home:27> print /home/grider/.cache/antidote
+antidote-home:28> typeset -g REPLY=/home/grider/.cache/antidote
+__antidote_bundle_dir:39> print /home/grider/.cache/antidote/https-COLON--SLASH--SLASH-github.com-SLASH-zimfw-SLASH-bira
+antidote-script:64> bundle_path=/home/grider/.cache/antidote/https-COLON--SLASH--SLASH-github.com-SLASH-zimfw-SLASH-bira 
+antidote-script:67> local bundle_type
+antidote-script:68> bundle_type=+antidote-script:68> __antidote_bundle_type zimfw/bira
+__antidote_bundle_type:15> emulate -L zsh
+__antidote_bundle_type:15> setopt local_options extended_glob no_monitor pipefail
+__antidote_bundle_type:16> local bundle=zimfw/bira
+__antidote_bundle_type:20> [[ zimfw/bira == \~/* ]]
+__antidote_bundle_type:22> [[ zimfw/bira == \$* ]]
+__antidote_bundle_type:27> local result
+__antidote_bundle_type:28> [[ -e zimfw/bira ]]
+__antidote_bundle_type:30> [[ -z zimfw/bira ]]
+__antidote_bundle_type:33> case zimfw/bira ((/|~|\$)*)
+__antidote_bundle_type:33> case zimfw/bira (*://*)
+__antidote_bundle_type:33> case zimfw/bira (*@*:*/*)
+__antidote_bundle_type:33> case zimfw/bira (*(:|@)*)
+__antidote_bundle_type:33> case zimfw/bira (*/*/*)
+__antidote_bundle_type:33> case zimfw/bira (*/)
+__antidote_bundle_type:33> case zimfw/bira (*/*)
+__antidote_bundle_type:40> result=repo 
+__antidote_bundle_type:45> typeset -g REPLY=repo
+__antidote_bundle_type:46> print repo
+antidote-script:68> bundle_type=repo 
+antidote-script:69> [[ repo == (repo|url|sshurl) ]]
+antidote-script:69> [[ ! -e /home/grider/.cache/antidote/https-COLON--SLASH--SLASH-github.com-SLASH-zimfw-SLASH-bira ]]
+antidote-script:77> [[ zsh != clone ]]
+antidote-script:80> [[ -n '' ]]
+antidote-script:83> local dopts zsh_defer=zsh-defer
+antidote-script:84> zstyle -s :antidote:plugin:zimfw/bira defer-options dopts
+antidote-script:85> [[ -n '' ]]
+antidote-script:88> local -a script=( )
+antidote-script:91> ((  0  ))
+antidote-script:94> local source_cmd=source
+antidote-script:95> [[ zsh == defer ]]
+antidote-script:105> ((  0  ))
+antidote-script:113> bundle_type=+antidote-script:113> __antidote_bundle_type /home/grider/.cache/antidote/https-COLON--SLASH--SLASH-github.com-SLASH-zimfw-SLASH-bira
+__antidote_bundle_type:15> emulate -L zsh
+__antidote_bundle_type:15> setopt local_options extended_glob no_monitor pipefail
+__antidote_bundle_type:16> local bundle=/home/grider/.cache/antidote/https-COLON--SLASH--SLASH-github.com-SLASH-zimfw-SLASH-bira
+__antidote_bundle_type:20> [[ /home/grider/.cache/antidote/https-COLON--SLASH--SLASH-github.com-SLASH-zimfw-SLASH-bira == \~/* ]]
+__antidote_bundle_type:22> [[ /home/grider/.cache/antidote/https-COLON--SLASH--SLASH-github.com-SLASH-zimfw-SLASH-bira == \$* ]]
+__antidote_bundle_type:27> local result
+__antidote_bundle_type:28> [[ -e /home/grider/.cache/antidote/https-COLON--SLASH--SLASH-github.com-SLASH-zimfw-SLASH-bira ]]
+__antidote_bundle_type:29> [[ -f /home/grider/.cache/antidote/https-COLON--SLASH--SLASH-github.com-SLASH-zimfw-SLASH-bira ]]
+__antidote_bundle_type:29> result=dir 
+__antidote_bundle_type:45> typeset -g REPLY=dir
+__antidote_bundle_type:46> print dir
+antidote-script:113> bundle_type=dir 
+antidote-script:114> [[ zsh == fpath ]]
+antidote-script:117> [[ zsh == path ]]
+antidote-script:120> [[ zsh == autoload ]]
+antidote-script:126> [[ dir == file ]]
+antidote-script:131> local initfile initfiles
+antidote-script:132> initfiles=+antidote-script:132> __antidote_initfiles /home/grider/.cache/antidote/https-COLON--SLASH--SLASH-github.com-SLASH-zimfw-SLASH-bira
+__antidote_initfiles:5> emulate -L zsh
+__antidote_initfiles:5> setopt local_options extended_glob no_monitor pipefail
+__antidote_initfiles:6> typeset -ga reply=( )
+__antidote_initfiles:7> local dir=/home/grider/.cache/antidote/https-COLON--SLASH--SLASH-github.com-SLASH-zimfw-SLASH-bira
+__antidote_initfiles:8> local initfiles=( )
+__antidote_initfiles:9> [[ 0 -gt 0 ]]
+__antidote_initfiles:9> initfiles=( ) 
+__antidote_initfiles:10> [[ 0 -gt 0 ]]
+__antidote_initfiles:10> initfiles=( ) 
+__antidote_initfiles:11> [[ 0 -gt 0 ]]
+__antidote_initfiles:11> initfiles=( ) 
+__antidote_initfiles:12> [[ 0 -gt 0 ]]
+__antidote_initfiles:12> initfiles=( /home/grider/.cache/antidote/https-COLON--SLASH--SLASH-github.com-SLASH-zimfw-SLASH-bira/bira.zsh-theme ) 
+__antidote_initfiles:14> typeset -ga reply=( /home/grider/.cache/antidote/https-COLON--SLASH--SLASH-github.com-SLASH-zimfw-SLASH-bira/bira.zsh-theme )
+__antidote_initfiles:15> printf '%s\n' /home/grider/.cache/antidote/https-COLON--SLASH--SLASH-github.com-SLASH-zimfw-SLASH-bira/bira.zsh-theme
+__antidote_initfiles:16> ((  1  ))
+antidote-script:132> initfiles=( /home/grider/.cache/antidote/https-COLON--SLASH--SLASH-github.com-SLASH-zimfw-SLASH-bira/bira.zsh-theme ) 
+antidote-script:134> [[ 1 -eq 0 ]]
+antidote-script:137> script+='fpath+=( /home/grider/.cache/antidote/https-COLON--SLASH--SLASH-github.com-SLASH-zimfw-SLASH-bira )' 
+antidote-script:138> initfile=/home/grider/.cache/antidote/https-COLON--SLASH--SLASH-github.com-SLASH-zimfw-SLASH-bira/bira.zsh-theme
+antidote-script:139> script+='source /home/grider/.cache/antidote/https-COLON--SLASH--SLASH-github.com-SLASH-zimfw-SLASH-bira/bira.zsh-theme' 
+antidote-script:144> ((  0  ))
+antidote-script:156> [[ -n '' ]]
+antidote-script:161> printf '%s\n' 'fpath+=( /home/grider/.cache/antidote/https-COLON--SLASH--SLASH-github.com-SLASH-zimfw-SLASH-bira )' 'source /home/grider/.cache/antidote/https-COLON--SLASH--SLASH-github.com-SLASH-zimfw-SLASH-bira/bira.zsh-theme'
fpath+=( /home/grider/.cache/antidote/https-COLON--SLASH--SLASH-github.com-SLASH-zimfw-SLASH-bira )
source /home/grider/.cache/antidote/https-COLON--SLASH--SLASH-github.com-SLASH-zimfw-SLASH-bira/bira.zsh-theme
+antidote-main:39> ret=0 
+antidote-main:46> ((  __adote_ksh_arrays  ))
+antidote-main:47> ((  __adote_sh_glob  ))
+antidote-main:48> return 0
XX% 

Run with clean env does not work either

XX% env -i zsh
XX% env                                                                                         
HOME=/home/grider
LOGNAME=grider
SHLVL=1
PWD=/home/grider
OLDPWD=/home/grider
MANPATH=/home/grider/.antidote/man:
_=/bin/env
                 antidote bundle zimfw/bira                                                                  
fpath+=( /home/grider/.cache/antidote/https-COLON--SLASH--SLASH-github.com-SLASH-zimfw-SLASH-bira )
source /home/grider/.cache/antidote/https-COLON--SLASH--SLASH-github.com-SLASH-zimfw-SLASH-bira/bira.zsh-theme
XX%  

It does work if I run source /home/grider/.cache/antidote/https-COLON--SLASH--SLASH-github.com-SLASH-zimfw-SLASH-bira/bira.zsh-theme manually though. Is there anything I'm missing? Transit from antigen so not quite understood the concept of antodote. Thanks.

mattmc3 commented 9 months ago

I looks like you're trying to use antidote in dynamic mode instead of static mode. For dynamic mode, you need to initialize antidote with source <(antidote init).

# Clone antidote if necessary.
[[ -e ${ZDOTDIR:-~}/.antidote ]] ||
  git clone https://github.com/mattmc3/antidote.git ${ZDOTDIR:-~}/.antidote

# Source antidote.
source ${ZDOTDIR:-~}/.antidote/antidote.zsh

# Initialize dynamic mode
source <(antidote init)

# Bundle plugins individually
antidote bundle zimfw/bira

Dynamic mode means you don't have to have a ${ZDOTDIR:-~}/.zsh_plugins.txt file, but it also means you don't get the benefits of static loading your plugins. See https://getantidote.github.io for more details.