With theTerminal in macOS , you’re able to salvage lot of time and eccentric less by using the command account functions built into the Terminal scale . The shell keeps a criminal record of the control you ladder , and you’re able to access this chronicle with a few mere keystrokes to run command again or edit them so you do n’t have to retype them .

you’re able to check into to see what statement are in your story at any metre by running thehistorycommand .   When you typehistoryand press Return ,   Terminal displays a listing of the control in the history list . For example :

1 lambert

2 cd ..

3 liter

4 cd kirk

Each line includes the bit of the command ( from the first to the last ) and the program line itself . Terminal includes all bid , whether or not they were successful . This mean that erroneous or misspelled ones will appear in the history .

Limit the history list

There are several way of displaying your   history   leaning . In most cases , you want to see the most - late command . One way to do this is to lam thehistorycommand with an statement that says how many commands you want to expose .

For example , history5tells the shell to display the commands start with the fifth one in the chronicle listing . you could figure any number as an argument for thehistorycommand ; if you come in a telephone number that ’s invalid ( most potential , your list is n’t as long as the bit you entered ) , Terminal will respond withfc : no such event .

Time-saving shortcuts

As discourse in aseparate clause , you’re able to move up or down your history list by compress the arrow key . This is the easiest means to rerun a command you executed lately . But if your statement is further back in the list , there are quicker ways to tell the case which one to run .

Say you have exhibit your prospicient story list , and part of it look like this :

329 locate Walden

330 history

331 L -l

If you desire to re - execute the commandlocate Walden , type!329 . The exclamation pointedness ( ! ) is a cutoff for a command in the account list . If you enter a phone number after it ( with no blank between ) , Terminal runs the command that has that absolute number in the history .

proportional numbers : Another way to specify a previous command is by using arelativenumber , or thenthcommand back from the end of the list . For example , if your history is 200 entries long and you want to enrol the fifth command back from the two-hundredth   entry , enter!-5 .

Characters : you could tell the shell to launch the last command that begins with a specific string of characters . For example , another way to start the samelocate Waldencommand would be to type!loc(with no space after the exclamation degree ) .

embark as few characters as you require after the exclamation point in time . The scale will stop at the first happening of a string that matches these characters . In the illustration just cite , I could have typed!losince there were no other commands that began with those letter . But if I had merely entered!l , the model would have operate command 331 , thels -lcommand , because this would have been the first couple .

For more information about Terminal read :