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.
- 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.
- 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:
- Next, type “i" to insert into the file.
- Add the following line:
- 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.
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