diff --git a/README.md b/README.md index 44b508a..768da38 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ working across different projects via [VisualMode](https://www.visualmode.dev/). For a steady stream of TILs, [sign up for my newsletter](https://visualmode.kit.com/newsletter). -_1769 TILs and counting..._ +_1770 TILs and counting..._ See some of the other learning resources I work on: @@ -2090,6 +2090,7 @@ If you've learned something here, support my efforts writing daily TILs by - [Add To The Path Via Path Array](zsh/add-to-the-path-via-path-array.md) - [Create And Jump Into A Directory](zsh/create-and-jump-into-a-directory.md) - [Link A Scalar To An Array](zsh/link-a-scalar-to-an-array.md) +- [List Available Zle Keybindings](zsh/list-available-zle-keybindings.md) - [Use A Space To Exclude Command From History](zsh/use-a-space-to-exclude-command-from-history.md) ## Usage diff --git a/zsh/list-available-zle-keybindings.md b/zsh/list-available-zle-keybindings.md new file mode 100644 index 0000000..a5eb164 --- /dev/null +++ b/zsh/list-available-zle-keybindings.md @@ -0,0 +1,44 @@ +# List Available Zle Keybindings + +Unlike `bash` which uses `readline`, `zsh` has its own implementation of a line +editing library -- `zle`. A lot of the core bindings between the two are the +same, e.g. `Ctrl-a` and `Ctrl-e` to go the beginning and end of the command line +prompt, respectively. + +All available `zle` keybindings can be listed out by running `bindkey` without +any arguments. + +The best way to check out an unaltered version of this list is by starting a +fresh `zsh` process with no RCS files loaded in. The `-f` flag does that. Note +though that when `zsh` is starting fresh, it has to decide whether to start in +_Emacs_ mode or _Vi_ mode. If it sees that your default editor is something like +`vi`, `vim` or `nvim`, then it will start you in _Vi_ mode. + +Starting in _Vi_ mode can be confusing because none of the standard _Emacs_ +keybindings like `Ctrl-a` and `Ctrl-e` are available in that context. So first +ensure you're in _Emacs_ mode by running: + +```sh +❯ zsh -f +lastword% bindkey -e +``` + +Now you can list out all the keybindings: + +```sh +lastword% bindkey +"^@" set-mark-command +"^A" beginning-of-line +"^B" backward-char +"^D" delete-char-or-list +"^E" end-of-line +"^F" forward-char +"^G" send-break +"^H" backward-delete-char +"^I" expand-or-complete +"^J" accept-line +"^K" kill-line +... +``` + +See `man zshzle` for more details on `zle` and `bindkey`.