I'm a relatively new user of zsh and don't know too much about shells (unfortunately). Nonetheless, I would like to define an alias in my .bashrc containing a hash. However, zsh doesn't seem to like it. My command would be basically used to replace a string in a LaTeX file with sed, run LaTeX over it and then undo the replacement thus something like
alias tex-build='
sed -i \
's~\\newcommand{\\command}\[1\]{{here_is_the_command_stuff #1}}~\\newcommand{\\command}\[1\]{}~' \
/path/to/mytexfile.tex &&
latex ... &&
sed -i \
's~\\newcommand{\\command}\[1\]{}~\\newcommand{\\command}\[1\]{{here_is_the_command_stuff #1}}~' \
/path/to/mytexfile.tex
'
Could anyone help me to find a way to get this alias running with the hash for the LaTeX command? Thanks in advance!
.bashrc
. what happens if you put the alias into the zsh configuration file.zshrc
in your home directory?alias tex-build='quoted level-1 'quoted level-2' /path/to/mytexfile.tex && quoted level-1 'quoted level-2' /path/to/mytexfile.tex'
. Most shells will not allow nesting of simple single quotes like that: you'll have to either escape the inner single quotes, or use double quotes as your outer quotes, since you'll really want single quotes protecting your LaTeX command strings as they have lots of characters that have a special meaning for the shell.tex-build() {...}
or shell script, so that you don't have to worry about nested quoting.'a'b'c'
as nested quotes. Why would a shell ever consider the second'
as anything but the closing quote for'a'
? Some shells support'a''b''c'
(like rc, es, akanga, zsh -o rcquotes). Some shells support'a\'b\'c'
(like fish), but in any case, you need special syntax to tell it's not a closing quote you want.sed -i 'stuff' file; latex [stuff]; sed -i 'stuff' file
, would it not be simpler to not alter the file, and simplysed 'stuff' file | latex
?