In ZSH when I type history I'm only displayed the last 16 or so commands. I would like history to display all the existing commands in the history file.

When I look in my .zsh_history (my history file) I see all the 500 previous commands that should be there.

I looked in the man page, but I don't see anything that controls how many of the history items are listed. I also looked in my, env but don't see anything that could be controlling this.

Any help would be appreciated! thanks.

4 Answers 4


history 1 (or history 1 -1) will display all entries from 1 (first entry) to -1 (last entry). You can also use history 1 100 to display the first 100 entries or history -100 -1 to display the last 100 etc.

For more information see the section on fc in man zshbuiltins. (history is equivalent to fc -l).

  • 15
    alias history="history 1" in ~/.zshrc made my history behave as expected. Oct 11, 2019 at 18:30
  • This is the right answer. I don't know why zsh history doesn't behave like this by default, but when I accidentally deleted this fix in my .aliases file (and I should have my dotfiles in a private repo), it took me a while to find this fix again. Nov 1, 2019 at 0:19

The accepted answer is simply correct, but I would like to quote some official documentation about this, in case it helps someone. (And this is too long for comment.) First look at history:

Same as fc -l.

Simple enough. Now look at fc:

fc -l [ -LI ] [ -nrdfEiD ] [ -t <timefmt> ] [ -m <match> ]
      [ <old>=<new> ... ] [ <first> [ <last> ] ]

The first two forms of this command select a range of events from first to last from the history list. The arguments first and last may be specified as a number or as a string. A negative number is used as an offset to the current history event number. A string specifies the most recent event beginning with the given string.

So history 1 means fc -l 1, which means starting from the first entry. Similarly if you want “last n” history (history n in Bash) you need history -n. As for default value:

If first is not specified, it will be set to -1 (the most recent event), or to -16 if the -l flag is given.


The response from Lost Odinson fixed it for me. Just set alias history="history 1" in ~/.zshrc. It saves the extra typing needed.


I found myself stubmbling upon this page while looking for a solution to find the last N commands when using ZSH on macOS and simply wanted to share my result.

tl;dr for ZSH users who want to see the last n commands. Add this to your .zsrhc:

function historyr() {
  history -$1 -1

Usage: $ history 100 # View the last 100 commands executed.

  • As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
    – Community Bot
    Feb 26, 2022 at 4:22
  • Answer updated so it is clear how it is a bit of a supplemental answer for other users who may reach this page similar to myself.
    – Olshansky
    Feb 28, 2022 at 18:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .