Incognito Mode. We all use it from time to time, but, if you’re a heavy terminal user, you might use your terminal as often and in as many diverse ways as your browsers.
…so I thought, why not make an incognito mode for Zsh?
With this script, typing
anonsh will recognfigure an open zsh instance in several ways:
HISTFILEwill be unset so you still have a command history, but new entries won’t get copied from RAM to disk and will get erased when you exit the shell.
- If you’re using the
zsh_hardstatus_precmdfunction from my custom prompt, it will be redefined to show
anonshinstead of the command name or working directory.
- If the
%1~token for displaying the current path is found in your
PS4prompt variables (or the
$base_promptfrom my custom
.zshrc), then it will be replaced with a literal
clearcan’t leave anything problematic behind.
clearwill be redefined so that it also uses every method I could find to ask your terminal to clear its scrollback buffer, as well as asking GNU screen to empty its own scrollback buffer if
$TERMis set to
- Zsh will be configured to call
clearbefore exiting to clear any scrollback that might otherwise hang around if you are using
termcapinfo xterm* ti@:te@in your
Incognito Mode for Zsh by Stephan Sokolow is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.