shio

~/shio.sh/learn/history $ ./read

chapter 08 · learn the terminal

History and shortcuts

history shows what you've typed. Up arrow recalls the last command. Ctrl-A jumps to the start. Small keys, large leverage.

$ history — what you've typed

The shell remembers every command you've run. Type history to see the list, numbered.

try: history

In a real shell, history persists across sessions — what you typed last week is still there. It's a personal log of how you've used your computer.

$ the arrow keys

Press to recall the previous command. Press it again for the one before that. moves forward through history. This is the single biggest time-saver in a shell.

Once a command is on your line, you can edit it before pressing Enter. Mistype something? Up arrow, fix the typo, Enter. Done.

$ line-editing shortcuts

These work in nearly every shell, and they'll save you years over a lifetime of typing:

  • Ctrl-A — jump to the beginning of the line
  • Ctrl-E — jump to the end of the line
  • Ctrl-U — erase everything to the left of the cursor
  • Ctrl-W — erase the word to the left
  • Ctrl-L — clear the screen (same as clear)
  • Ctrl-C — cancel the current command

Try them right here. Type a long-ish command, then Ctrl-A to jump home:

$ tab completion

In a real shell, pressing Tab mid-word tries to complete the file or command name. If there's only one match, it fills it in. If there are several, it shows you the options.

This sandbox doesn't implement Tab yet — but on your real Mac, it's the keystroke you'll lean on most. Type the first few letters of a long filename and let the computer finish it for you.

~/shio.sh/learn/history $ cd ..