Easy: Set Mac Terminal Command History (Set How Many Lines Remembered)

Easy: Set Mac Terminal Command History (Set How Many Lines Remembered)

By default, Mac OS Terminal bash profiles remembers 500 lines of command history in shell. While 500 lines is a lot, some prefer to remember more lines of history to repeat commands. Follow the steps below to increase the HISTFILESIZE setting inside your Terminal bash profile.


  1. Confirm the current Terminal command history length by typing:


A number will be displayed which will be the number of lines of commands your current bash shell is remembering.


Mac terminal history command lines remembered default 500


  1. Next, we’ll create a .bash_profile file and customize the number of lines of command history to 1000. Use any number you wish. Type:
vi ~/.bash_profile


  1. Next, type “i" to insert into the file.
  1. Add the following line:


  1. Finally, type Shift + Z + Z (that’s shift key and Z key twice) to save and write out the .bash profile file. You will need to restart Terminal for the changes to take affect.
Mac terminal histfilsize value

You can issue the echo $HISTFILESIZE command to see the updated lines of command history saved now.


Other Useful Mac OS Terminal History Commands

List Terminal History



Clear Terminal History

history -c
history -w


* Please use the comment form below. Comments are moderated.*

Related Posts



No comments made yet. Be the first to submit a comment
Saturday, 02 March 2024