The existence of special characters (particularly !) can be a pain; you may often need to type commands that have exclamation points in them, and occasionally need commands with carets (^). These get the C shell confused unless you "quote" them properly. If you use these special characters often, you can choose different ones by setting the histchars variable. histchars is a two-character string; the first character replaces the exclamation point (the "history" character), and the second character replaces the caret (the "modification" character (Section 30.5)). For example:
% set histchars='@#' % ls file* file1 file2 file3 % @@ Repeat previous command (was !!) ls file* file1 file2 file3 % #file#data# Edit previous command (was ^file^data^) ls data* data4 data5
zsh's histchars is like the csh and tcsh version, but it has three characters. The third is the comment character -- by default, #.
An obvious point: you can set histchars to any characters you like (provided they are different!), but it's a good idea to choose characters that you aren't likely to use often on command lines. Two good choices might be # (hash mark) and , (comma).[96]
[96]In the C shell and tcsh, # is a comment character (Section 35.1) only in noninteractive shells. Using it as a history character doesn't conflict because history isn't enabled in noninteractive shells.
-- ML
Copyright © 2003 O'Reilly & Associates. All rights reserved.