From 2cbeb1a314ffa8bcc8c7b9c5812bbbb58196982d Mon Sep 17 00:00:00 2001 From: Marco D'Agostini Date: Fri, 3 Apr 2020 12:31:22 -0500 Subject: [PATCH] Organized for general use --- bash-zsh_TerminalShorcuts.md | 67 +++++++++++++++++++++--------------- 1 file changed, 39 insertions(+), 28 deletions(-) diff --git a/bash-zsh_TerminalShorcuts.md b/bash-zsh_TerminalShorcuts.md index 33d4fb5..4129b0b 100644 --- a/bash-zsh_TerminalShorcuts.md +++ b/bash-zsh_TerminalShorcuts.md @@ -1,3 +1,41 @@ +# Shortcuts + +*For Ubuntu's default keybinding settings (i.e Emacs keybindings)* + +## Insert previous arguments + - Alt+.: insert last argument from last command. + - Alt+number+.: insert #nth last argument from last command. + - Alt+- , number , Alt+., **zsh:** Alt+-+#+.: insert #nth first argument from last command. + +*In Linux you can repeat commands to go back in history* + +## Cut/Paste commands +*(relative to cursor's position)* + - Ctrl+w: cuts last word + - Alt+d: cuts next word + - Ctrl+k: cuts everything after + - Ctrl+u, **zsh:** Alt+w: cuts everything before + - **zsh:** Ctrl+u: cuts the entire command *(In bash you can combine Ctrl+u , Ctrl+k)* + - Ctrl+y: paste characters previously cut with any **Cut command**. *In bash you can chain **cut commands**, and Ctrl+y will paste them all.* + + +## Move cursor + - Ctrl+left: move to last word + - Ctrl+right: move to next word + - home or Ctrl+a: move to start of command + - end or Ctrl+e: move to end of command + + +## Other + - Ctrl+_: undo last edit *(very useful when exceeding Ctrl+w)* + +# To see all shortcuts available + - **bash:** `bind -lp` + - **zsh:** `bindkey -L` + +# Other examples + +## Common usecases Let's consider the last command to be: mv foo bar @@ -6,34 +44,7 @@ Let's consider the last command to be: Alt+0+.: first argument of last command = `mv` -## Some useful shortcuts: - - - **Select previous arguments** - - Alt+.: insert last argument from last command. - - Alt+number+.: insert #nth last argument from last command. - - Alt+- , number , Alt+., **zsh:** Alt+-+#+.: insert #nth first argument from last command. - - *In Linux you can repeat commands to go back in history* - - - - **Cut commands** (relative to cursor's position) - - Ctrl+w: cuts last word - - Alt+d: cuts next word - - Ctrl+k: cuts everything after - - Ctrl+u, **zsh:** Alt+w: cuts everything before - - **zsh:** Ctrl+u: cuts the entire command *(In bash you can combine Ctrl+u , Ctrl+k)* - - Ctrl+y: paste characters previously cut with any **Cut command**. *In bash you can chain **cut commands**, and Ctrl+y will paste them all.* - - Ctrl+_: undo last edit *(very useful when exceeding Ctrl+w)* - - Ctrl+left: move to last word - - Ctrl+right: move to next word - - home or Ctrl+a: move to start of command - - end or Ctrl+e: move to end of command - -### To see all shortcuts available -- **bash:** `bind -lp` -- **zsh:** `bindkey -L` - -## Unfortunately there are some limitations +# Limitations "words" only includes `a-zA-Z` characters, so any symbol character will stop word-shortcuts. So if last argument was a url and you want to erase it with Ctrl+w it will be a pain.