Viewing Session History in the zsh Shell

The Z-shell also lets you easily reuse commands from your session history, which is the list of commands you’ve used during a session or in previous sessions (Code Listing 3.11). The history functions are handy for reviewing your Unix session, reusing previous commands (instead of retyping), and modifying (rather than completely redoing) long or complex commands.

Code Listing 3.11. In this example, we typed the first command, and then pressed the to reuse the previous command. !40 recycled the 40th command from the listing.
[ejr@hobbes clean]$ ls
background.htm  info.htm      logo.gif
[ejr@hobbes clean]$ ls
background.htm  info.htm      logo.gif
[ejr@hobbes clean]$ history 1 free 2 id deb 3 id ejr 4 uname -a 5 ls ...

Get Unix Third Edition: Visual Quickstart Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.