These shortcuts are used on your unix command line prompt. They are done using the CONTROL (or CTRL) key on your keyboard. This is known historically as the “GNU readline library” or “GNU readline shortcuts”
Even though these shortcuts were implemented for Bash, they also work for ZShell.
All keyboards have a version of this key, typically in the lower-left position of the keyboard.
Below, you use the readline shortcut associated with CTRL by typing the CTRL key and the key indicated at the same time.
Alt or Meta Key
All unix prompts also have an ALT key, also known as a meta key. However, on your version of your shell, you may have to enable it or map it to one of the special keys on your keyboard.
For Mac OS using Terminal, the default META key is the CONTROL (CTRL) key. You switch this setting to use the Option key instead from the Terminal preferences. Click Profiles > choose the profile you want (you must do it for each profile here) > click Keyboard > Enable “Use Option as Meta Key”
- Open Terminal preferences, click Profiles
2. Select a profile from the left, click Keyboard
3. Enable “Use Option as Meta key”
Now whenever you see Unix documentation that refers to an ALT key, you will use the Option key on your keyboard. If you leave this unchecked, you will use the CTRL key.
Be sure to set the editor for your shell.
The Readline Shortcuts
|CTRL-a||move the cursor to the beginning of line|
|CTRL-e||move cursor to end of line|
|ALT-b||move the cursor back one word|
|ALT-F||move cursor forward one word|
|CTRL-p||go back to the last shell command you executed|
|CTRL-f||go to the next shell command (assuming you used CTRL-p to see a pervious one)|
|CTRL-k||CTRL-k is unix for kill, which means delete all of the text after the cursor. Adds to the shell clipboard, which is different than your operating system clipboard|
|CTRL-u||delete (or “kill”) all of the text before the cursor. like with CTRL-K, this adds it to the unix clipboard.|
|CTRL-y||“yank” (CTRL-y) is similar to what you know as “Paste” on your operating system. It will paste the clipboard (the unix clipboard, not the OS clipboard) to where the cursor currently is.|
|CTRL-r||This powerful feature lets you search the history of commands you have used on this shell prompt. Using an ‘i search,’ any suggestion for a previous command based on the commands you used in this same shell prompt will appear.|