I want to add zsh-autosuggestions
plugin to ~/.zshrc
by script.
original text:
plugins=(git)
or
plugins=(git
some1
some2)
target :
plugins=(git
zsh-autosuggestions)
This doesn't work.
sed -i 's/^plugins=\(([^\)]*)\)/plugins=\(\1\nzsh-autosuggestions\n\)/' ~/.zshrc
I am confused, I think this
([^\)]*)
is group 1, but why it not workbut remove first group's
()
sed -i 's/^plugins=\([^\)]*\)/plugins=\(\1\nzsh-autosuggestions\n\)/' ~/.zshrc
turn out to
plugins=((git zsh-autosuggestions ) )
I have escaped the
()
by\
, why it became group 1?
N;N;
and=
means? In python or javascript, once()
aprear(witout escape) would be considered as a group. Seems it is not so in sed. – Mithril Jan 06 '18 at 09:23