Bash
Editing Commands
Alt + f: Forward (right) one wordAlt + b: Back (left) one wordCtrl + u: Cut/delete the Line before the cursor to the clipboardCtrl + k: Cut the Line after the cursor to the clipboardCtrl + w: Cut the Word before the cursor to the clipboardAlt + d: Delete the Word after the cursorAlt + Del: Delete the Word before the cursor.Ctrl + y: Paste the last thing that was cut
History Commands
Ctrl + r: searches the command history as you typeCtrl + p: Previous command in the search result ofCtrl + rCtrl + n: Next command in the search result ofCt rl + rAlt + .or!$: Reuse the last argument of previous command!*: All arguments of previous command!!: Repeat previous command!blah: Run last/most recent command that starts withblah!blah:p: Print last command starting withblah^blah: Deleteblahfrom previous command^blah^foo: Replaceblahwithfooin previous commandTo retain history across sessions, you need to add the
PROMPT_COMMAND='history -a ~/.bash_history'to your.bash_profilethen close and reopen all bash sessionsecho "PROMPT_COMMAND='history -a ~/.bash_history'" >> ~/.bash_profile
Last updated
Was this helpful?