2.2. Time-saving Tips

2.2.1. Tab Completion

The tab completion feature in bash permits typing a partial command name or path, then pressing the TAB key to auto-complete the sequence. When multiple completions are possible, pressing the TAB key again lists them all.

Try This

Try these shortcuts on Odin. Your experience navigating throughout the system and working with commands will be significantly less frustrating if you take the time to learn and practice these shortcuts.

2.2.2. Modifier Keys

Before we can make sense of the shortcuts in the next section, it is important that you take time to familiarize yourself with the modifier key notation shown in Table 2.1.

Table 2.1 Modifier Keys

Key

Description

Example

C

CTRL (control)

C-c

M

META (meta): usually ALT, OPT or ESC.

M-x

S

SHIFT (shift).

S-x

Modifier keys are capitalized, followed by - and the key to be pressed. For example, some typical situations involving modifier keys are listed below. Don't worry about what actions they perform, if any, just yet; instead, focus on learning the notation:

  • C-s means CTRL + s where s is the key to be pressed with CTRL held down.

  • S-, means SHIFT + , where , is the key to be pressed with SHIFT held down.

  • C-< means CTRL + < where < is the key to be pressed with CTRL held down; however, you actually need to press C-S-, in order to produce < since < is typed using S-,.

Modifier keys are also used by other programs, such as the Emacs text editor, so you will be able to get some additional practice when you work through the The Emacs Text Editor chapter and the rest of the book. Some of this material is intentionally repeated in the Control and Meta section to provide more context when using modifier keys in Emacs.

2.2.3. Shell Navigation Shortcuts

The shortcuts in Table 2.2 are used to move the cursor around the shell prompt in your terminal.

Table 2.2 Shell Navigation Shortcuts

Shortcut

Description

C-a

Move the cursor to the beginning of the line.

C-e

Move the cursor to the end of the line.

C-f

Move the cursor forward (right) one character.

M-f

Move the cursor forward (right) one word.

C-b

Move the cursor backward (left) one character.

M-b

Move the cursor backward (left) one word.

Try This

These are useful to learn and practice. Try them on Odin. Your experience navigating throughout the system and working with commands will be significantly less frustrating if you take the time to learn and practice these shortcuts.

2.2.4. Command History Shortcuts

The history feature of bash maintains a history of the commands that you type when using it. One way to access the history is by using the history command or some of the various keyboard shortcuts listed in the table below [BASHSEARCH].

Shortcut

Description

C-p

Backward one line through the command history.

C-n

Forward one line through the command history.

C-r

Reverse incremental search through command history.

C-s

Forward incremental search through command history.

C-< (C-S-,[1])

When in incremental search, move to beginning of command history.

C-> (C-S-.[2])

When in incremental search, move to end of command history.

Try This

Try these shortcuts on Odin. Your experience navigating throughout the system and working with commands will be significantly less frustrating if you take the time to learn and practice these shortcuts.