Becoming Productive In Bash Using The Keyboard Shortcuts
By Sudheer S
Moving around
You can use the arrow keys on keyboard to move around in the command line. Bash also provides convenient keyboard shortcuts to navigate effectively. Try them out and see for yourself.
To become a Bash pro user you have to get yourself familiar with the keyboard shortcuts. Once you do, you’ll find yourself productive.
Shortcut | Description |
---|---|
CTRL+b | move backward one character |
CTRL+f | move forward one character |
ESC+b | move one word backward |
ESC+f | move one word forward |
CTRL+a | move to beginning of line |
CTRL+e | move to end of line |
CTRL+p | move to previous line |
CTRL+n | move to next line |
ESC+< | move to first line of history list |
ESC+> | move to last line of history list |
Moving around words using ESC+f
and ESC+b
are my favourites in this list. Jumping to first and last lines of the
history list is also useful.
Deleting And Undeleting
Bash provides convenient keyboard shortcuts for deleting and retrieving the last deleted item.
Shortcut | Description |
---|---|
CTRL+d | delete one character forward |
ESC+d | delete one word forward |
CTRL+k | delete forward to end of line |
CTRL+u | delete the line from the beginning to point |
CTRL+y | retrieve last item deleted |
Searching
CTRL+r
search backward
When you hit CTRL+r the prompt change to
(reverse-i-search)`':
Type the first few characters of the command you have entered before, Bash completes the command line for you.
Changing Case
Shortcut | Description |
---|---|
ESC+c | Capitalize word after point |
ESC+u | Change word after point to all capital letters |
ESC+l | Change word after point to all lowercase letters |
This is especially useful, when your caps lock is accidentally turned on and, you type something without realizing it.
Without the shortcut to change case, you would turn caps lock off, delete the characters you accidentally typed in
uppercase and then type them again. Now you are empowered with ESC+l
.
Miscellaneous
Shortcut | Description |
---|---|
CTRL+l | clear screen |
CTRL+d | logout or close the terminal window |
CTRL+c | cancel the currently running program or command |
Spend some time with these keyboard shortcuts. Become a productive Bash user.