$HISTCHARS  –  Definition of History Expansion and Comment Parsing (Deprecated)

$HISTCHARS defines how the Zsh shell handles history expansion and how it parses line comments. This variable is deprecated, the lowercase $histchars should be used instead.

The value contains three ASCII characters:

  1. Character for a history expansion. Default: !.
  2. Character for a quick history substitution. Default: ^.
  3. Character to start a line comment. Default: #.

Examples

Change line comment character for a script
1
2
3
4
5
#!/usr/bin/env zsh
# Tell Zsh that underscore _ now start a line comment
HISTCHARS[3]='_'
_ new line comment
echo hello world
Output:
1
hello world
BashSupport Pro is a Zsh IDE with support for $HISTCHARStry it now!
© 2020–2024 Joachim Ansorg
Imprint
Privacy Policy
Legal