Oh-my-zsh hash (pound) symbol bad pattern or match not found
Asked Answered
M

3

7

I'm quite sure is something dealing with my Oh-my-zsh configuration, but I can't figure out what it is.

When I use a "#" symbol in my git command (but on everything else too, like 'ls #2' for instance) I get 'bad pattern' error or 'no match found'

I guess is about counting something, but I can't find where to configure it.

I.E.

➜  demo git:(adlist) git push origin adlist#3 
zsh: no matches found: adlist#3

or

➜  demo git:(adlist) git push origin #3-adlist
zsh: bad pattern: #3-adlist
Mattison answered 6/9, 2012 at 15:49 Comment(0)
B
12

Use single quotes:

git push origin 'adlist#3'
git push origin #3-adlist

In zsh # is used for pattern removal. See: http://zsh.sourceforge.net/Guide/zshguide05.html under the heading Standard forms: pattern removal

Blinny answered 9/12, 2012 at 1:20 Comment(8)
Is it possible to disable pattern removal? This is driving me nutsGuimond
The linked article doesn't really explain what use of # (without quoting) actually causes zsh to try to do. Can anyone put it into concise english?Relegate
Pattern removal. Try: param=foobar; echo ${param#foo}Blinny
@SWrobel you can disable it by aliasing git with noglob git: alias git='noglob git'Blinny
@Guimond also you can use set -kReturnable
@Returnable Do you know how to undo set -k ?Silin
@YonggooNoh set +kReturnable
The explanation in the accepted answer is wrong. Pattern removal applies to parameter substitutions. But the question has no parameter substitution. # also has 2 different special meanings in globbing. See the man page zshexpn under "Glob operators" and "Globbing flags".Tocantins
O
12

You can unsetopt EXTENDED_GLOB, and this should stop # being interpreted as a part of a pattern.

If you really want to keep most of the features of EXTENDED_GLOB, but want to disable # being used for patterns, then you can disable -p '#' (you have to single quote the # argument, so that it doesn't get expanded like a pattern). This certainly works in my zsh installation, version 5.7.1, even though it is not documented in zshbuiltins(1).

Obsolete answered 6/8, 2019 at 17:5 Comment(0)
R
2

Open your zshrc file:

vi ~/.zshrc

Add into end of file:

unsetopt INTERACTIVE_COMMENTS
unsetopt BAD_PATTERN

Effect your file:

source ~/.zshrc

Restart your terminal and enjoy it.

Rosinarosinante answered 16/3, 2022 at 21:57 Comment(1)
answers should have more reasoning as to what something is doing and why you are suggesting somethingKaty

© 2022 - 2024 — McMap. All rights reserved.