My most favorite all time keyboard shortcuts for the bash shell are Ctrl + E (move to the end) and Ctrl + A (move to the beginning). Hahah, I use them so much that I almost used them while creating this post! Anyways, below are some more shortcuts that I found online that could help me out, and maybe you too.
- Ctrl + A = Go to the beginning of the line you are currently typing on
- Ctrl + E = Go to the end of the line you are currently typing on
- Ctrl + L = Clears the Screen, similar to the clear command
- Ctrl + U = Clears the line before the cursor position. If you are at the end of the line, clears the entire line.
- Ctrl + H = Same as backspace
- Ctrl + R = Search through previously used commands
- Ctrl + C = Kill whatever you are running
- Ctrl + D = Exit the current shell
- Ctrl + Z = Puts whatever you are running into a suspended background process. fg restores it.
- Ctrl + W = Delete the word before the cursor
- Ctrl + K = Clear the line after the cursor
- Ctrl + T = Swap the last two characters before the cursor
- Esc + T = Swap the last two words before the cursor
- Alt + F = Move cursor forward one word on the current line
- Alt + B = Move cursor backward one word on the current line
- Tab = Auto-complete files and folder names
One new command I just learned about is editing a command using the $EDITOR program. By typing Ctrl + x Ctrl + e the $EDITOR program opens up and after you type your commands and quit, your commands are copied to your shell and executed. Some more obscure keyboard shortcuts are things like macro recording. I had no idea that bash could do this!! Okay, so far, I have no solid ideas on where I would use this, unless… maybe I could see I needed to repeat some commands for various directories… but I think I would just use a script for that? I dont know… if you have any ideas please make a comment.
- Ctrl + x ( To start a macro
- Ctrl + x ) To end the macro recording
- Ctrl + x e To replay the macro
and I saw my letters show up.