_zsh_autosuggest_suggestion:local:1: not valid in this context:
nikoren opened this issue · 13 comments
Hi,
Anytime i type "--"
I get following message: ```_zsh_autosuggest_suggestion:local:1: not valid in this context:
xxx-mac% ansible -_zsh_autosuggest_suggestion:local:1: not valid in this context: --
-_zsh_autosuggest_suggestion:local:1: not valid in this context: --
_zsh_autosuggest_suggestion:local:1: not valid in this context: --
_zsh_autosuggest_suggestion:local:1: not valid in this context: ---
-_zsh_autosuggest_suggestion:local:1: not valid in this context: ---
_zsh_autosuggest_suggestion:local:1: not valid in this context: --
_zsh_autosuggest_suggestion:local:1: not valid in this context: --v
v_zsh_autosuggest_suggestion:local:1: not valid in this context: --ve
e_zsh_autosuggest_suggestion:local:1: not valid in this context: --ve
_zsh_autosuggest_suggestion:local:1: not valid in this context: --v
I am getting a similar error.... after upgrading and moving my autosuggestions from ~/.zsh
to a oh-my-zsh plugin ~/.oh-my-zsh
git co -_zsh_autosuggest_suggestion:local:1: not valid in this context: -b/plugins/zsh-autosuggestions
b_zsh_autosuggest_suggestion:local:1: not valid in this context: -b
_zsh_autosuggest_suggestion:local:1: not valid in this context: -b
f_zsh_autosuggest_suggestion:local:1: not valid in this context: -b
s_zsh_autosuggest_suggestion:local:1: not valid in this context: -b
f_zsh_autosuggest_suggestion:local:1: not valid in this context: -b
a_zsh_autosuggest_suggestion:local:1: not valid in this context: -b
s_zsh_autosuggest_suggestion:local:1: not valid in this context: -b
d_zsh_autosuggest_suggestion:local:1: not valid in this context: -b
f_zsh_autosuggest_suggestion:local:1: not valid in this context: -b
a_zsh_autosuggest_suggestion:local:1: not valid in this context: -b
s_zsh_autosuggest_suggestion:local:1: not valid in this context: -b
d_zsh_autosuggest_suggestion:local:1: not valid in this context: -b
f_zsh_autosuggest_suggestion:local:1: not valid in this context: -b
a_zsh_autosuggest_suggestion:local:1: not valid in this context: -b
s_zsh_autosuggest_suggestion:local:1: not valid in this context: -b
d_zsh_autosuggest_suggestion:local:1: not valid in this context: -b
f
It won't go away... makes terminal completely unusable...
st _zsh_autosuggest_suggestion:local:1: not valid in this context: ~
~_zsh_autosuggest_suggestion:local:1: not valid in this context: ~a
a_zsh_autosuggest_suggestion:local:1: not valid in this context: ~as
s_zsh_autosuggest_suggestion:local:1: not valid in this context: ~asd
d_zsh_autosuggest_suggestion:local:1: not valid in this context: ~asdf
f_zsh_autosuggest_suggestion:local:1: not valid in this context: ~asdfa
a_zsh_autosuggest_suggestion:local:1: not valid in this context: ~asdfad
d_zsh_autosuggest_suggestion:local:1: not valid in this context: ~asdfadf
f_zsh_autosuggest_suggestion:local:1: not valid in this context: ~asdfadfa
a_zsh_autosuggest_suggestion:local:1: not valid in this context: ~asdfadfas
s_zsh_autosuggest_suggestion:local:1: not valid in this context: ~asdfadfasd
d_zsh_autosuggest_suggestion:local:1: not valid in this context: ~asdfadfasdf
f
Thanks for reporting this. For now, you can see if using v0.2.13
will solve this problem.
In the meantime, it would be helpful for me to be able to recreate this problem. Would either of you be willing to determine a minimal .zshrc configuration that creates this problem?
Bug confirmed here. Also,
- It's not just
--
, it's any non-word character (~
,/
,1
) as argument. For example, if I typecd ~
, I see:cd _zsh_autosuggest_suggestion:local:1: not valid in this context: ~
- With digits though, the error message varies. For example,
cd 1
displayscd _zsh_autosuggest_suggestion:local:1: not an identifier: 1
- With digits though, the error message varies. For example,
- Reverting to
v0.2.13
solves the problem.
Zsh 5.2 on Linux with oh-my-zsh with plugins (python pip virtualenvwrapper npm httpie git sudo docker colored-man-pages history-substring-search zsh-navigation-tools zsh-autosuggestions zsh-syntax-highlighting)
, which I'll reduce to a minimal .zshrc
this evening at home if no one provided one before.
Yup version 0.2.13 solves the issue for me...
Workaround steps:
cd ~/.oh-my-zsh/custom/plugins/zsh-autosuggestions
git co "v0.2.13"
# restart terminal
I'm trying to reproduce, but not having any success.
My ~/.zshrc:
% cat ~/.zshrc
export ZSH=/Users/ericfreese/.oh-my-zsh
ZSH_THEME="robbyrussell"
plugins=(python pip virtualenvwrapper npm httpie git sudo docker colored-man-pages history-substring-search zsh-navigation-tools zsh-autosuggestions zsh-syntax-highlighting)
source $ZSH/oh-my-zsh.sh
Zsh version:
% zsh --version
zsh 5.2 (x86_64-apple-darwin14.5.0)
Oh My Zsh version:
% git -C $ZSH rev-parse --short HEAD
bd6dbd1
zsh-autosuggestions version:
% git -C $ZSH_CUSTOM/plugins/zsh-autosuggestions/ rev-parse --short HEAD
9d100f4
And the plugin seems to work as expected... I think I'll need more info here before I can do much more than make shots in the dark. Looking forward to your minimal config @ronjouch!
I was able to repo with very minimal ~/.zshrc
cat ~/.zshrc
export ZSH=$HOME/.oh-my-zsh
plugins=(zsh-autosuggestions)
source $ZSH/oh-my-zsh.sh
Zsh version:
zsh --version
zsh 5.0.8 (x86_64-apple-darwin15.0)
Oh My Zsh version:
git -C $ZSH rev-parse --short HEAD
534bf2c
zsh-autosuggestions version:
git -C $ZSH_CUSTOM/plugins/zsh-autosuggestions/ rev-parse --short HEAD
9d100f4
The problem was introduce here: ddb7284
The issue doesn't exist on 2a5791
This line throws the error.
local prefix=$(_zsh_autosuggest_escape_command_prefix "$1")
This is how the error is being created:
test() {
echo " ~"
}
local prefix=$(test)
# no quotes ^
# you want to wrap prefix with quotes like this:
local prefix="$(test)"
Wrapping the right side with quotes should fix this.
local prefix="$(_zsh_autosuggest_escape_command_prefix "$1")"
Another thing to note, the new match is missing #<>~^
"${1//(#m)[\\()\[\]|*?]/\\$MATCH}" #new
"${1//(#m)[\][()|\\*?#<>~^]/\\$MATCH}" #old
And the plugin seems to work as expected... I think I'll need more info here before I can do much more than make shots in the dark. Looking forward to your minimal config @ronjouch!
@ericfreese cannot reproduce at home either, even though it's the same {zsh, oh-my-zsh,tmux} versions and the same .zshrc
as my work machine :-/ . Will try to narrow down tomorrow at work if the information provided above by @arianf didn't help.
This is how the error is being created:
Interestingly, this works just fine in my terminal:
% /bin/zsh --version
zsh 5.0.8 (x86_64-apple-darwin15.0)
% /bin/zsh -f
%% test() { echo " ~" }
%% abc=$(test)
%% echo $abc
~
@arianf What is the output of setopt
for you? Mine (in the example above) is:
% setopt
interactive
monitor
norcs
shinstdin
zle
Wrapping the right side with quotes should fix this.
This was going to be my shot-in-the-dark fix. I'll go ahead and make this change, but I'm still curious why it works for me but not for others.
Another thing to note, the new match is missing #<>~^
I removed these because they didn't actually appear necessary when I was testing. I had originally just copied this line from zsh-history-substring-search, but thought I'd trim it down to only what was needed. We can add those characters back in as we find the need for them.
Ok, this appears to be a zsh version thing:
% /bin/zsh --version
zsh 5.0.8 (x86_64-apple-darwin15.0)
% /bin/zsh -f
%% source ~/Code/zsh-autosuggestions/zsh-autosuggestions.zsh
%% echo _zsh_autosuggest_suggestion:local:1: not valid in this context: ~
~
On the last line, I typed "echo " and got the error when I hit the "" key.
And @arianf's suggestion fixes it. Gonna go ahead and add that and push a new release.
Thanks all! 👍