Skip to content

Commit d52a11e

Browse files
committed
Updates to completion & edits for widgets and line movement
1 parent fe0b8c9 commit d52a11e

File tree

7 files changed

+39
-9
lines changed

7 files changed

+39
-9
lines changed

Diff for: β€Ždocs/helpers/bindkey.md

+3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
The `bindkey` key mappings can be very confusing to decipher.
44
It can use multiple different notations but it's smart to use the same key notation throughout your configuration.
55

6+
You can print all of your current key bindings in the current keymap with `bindkey`.
7+
To print the full `bindkey` command to add to your `.zshrc` file use `bindkey -L`.
8+
69
In general you'll bind a widget so a key sequence or a key with modifier.
710
This can be declared in (caret notation)[https://en.wikipedia.org/wiki/Caret_notation] using `^`, using (escape sequences)[https://en.wikipedia.org/wiki/Escape_sequence] using `\`, in octal (`\NNN`), hex (`\xNN`), or unicode (`\uNNNN`).
811
None of these are particularly great for people to read.

Diff for: β€Ždocs/helpers/completions.md

+29-3
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,45 @@
11
# [WIP] Completions
22

3-
https://github.com/zsh-users/zsh-completions
3+
zsh has very comprehensive completions which is one of the main reasons to switch to zsh for your interactive shell.
4+
Under the covers it works similarly to other shell completion engines (completions are read from files and functions on disc) but there are a few features that make it better.
5+
6+
> Some of the completion features have been ported to other shells and some have been stolen from other shells.
7+
> Many of the sections below are optional to enhance your shell experience.
8+
9+
One nice difference is the way completions are displayed and how tab works when at a completion menu.
10+
Here is a comparison with how `bash` and `zsh` differ.
11+
12+
![](../../img/bash-completion.gif)
13+
14+
There are lots of commands that have built in tab completion for zsh.
15+
If a command you use doesn't support tab completion by default have a look at [zsh-users/zsh-completions](https://github.com/zsh-users/zsh-completions).
16+
You can install it with the various zsh plugin managers or download the repo and add the src directory to your `$fpath`.
417

518
## Autosuggestions
619

7-
https://github.com/zsh-users/zsh-autosuggestions
20+
Autosuggestions are like a preemptive tab complete for your .zhistory file.
21+
The autosuggestion plugin will look at your current command, what commands you typically type, and suggest possibilities for you to use and save key strokes.
22+
23+
Installation instructions can be found in the [zsh-autosuggestions](https://github.com/zsh-users/zsh-autosuggestions) repo.
24+
25+
![](../../img/autosuggestions.gif)
826

927
## Highlighting
1028

11-
https://github.com/zsh-users/zsh-syntax-highlighting
29+
Syntax highlighting works similarly to an IDE but at your terminal.
30+
It can highlight everything from brackets to cursor position.
31+
32+
Under the covers it works like all the other things in zsh with zle widgets.
33+
Have a look at the [zsh-syntax-highlighting](https://github.com/zsh-users/zsh-syntax-highlighting) repo for installation instructions
34+
35+
![](../../img/highlighting.gif)
1236

1337
## zstyle
1438

1539
List your current styles by invoking `zstyle` by itself.
1640

41+
The rest of this section will have to come at a later date.
42+
1743
---
1844

1945
[home](../../README.md)

Diff for: β€Ždocs/helpers/widgets.md

+4-5
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,15 @@ You can list all available widgets with
1515
zle -al
1616
```
1717

18-
If you want to list your current keybindings and widgets use.
19-
20-
```bash
21-
bindkey
22-
```
18+
If you want to list your current keybindings and widgets use the `bindkey` command by itself.
19+
To see a list of bindings and a command you can run to set the key binding in your `.zshrc` file use `bindkey -L`
2320

2421
The widgets with `.` at the begining of the name are read-only system widgets that cannot be changed.
2522

2623
An example of binding a built in widget to a keyboard shortcut is
2724

25+
> When you bind a key to a widget the privious key binding, if there is one, will be overridden.
26+
2827
```bash
2928
bindkey '^a' begining-of-line
3029
```

Diff for: β€Ždocs/usage/line_movement.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ For reference:
3131
* `^[` = Alt
3232
* `\e` or `\E` = Escape
3333

34-
If you want to figure out how a key sequence should be represented check out `xxd`.
34+
If you want to figure out how a key sequence should be represented you can try `xxd` or `echo " $keypress"`.
3535
The key letter you press is not case sensitive.
3636
So `^a` is the same as `^A`.
3737

@@ -48,6 +48,8 @@ Let's set the emacs begining and end of line keyboard shortcuts and reverse sear
4848
bindkey '^r' history-incremental-search-backward
4949
bindkey '^a' beginning-of-line
5050
bindkey '^e' end-of-line
51+
# Also fix annoying vi backspace
52+
bindkey '^?' backward-delete-char
5153
```
5254

5355
Now I have four ways to get to the begining and end of a command line.

Diff for: β€Žimg/autosuggestions.gif

179 KB
Loading

Diff for: β€Žimg/bash-completion.gif

527 KB
Loading

Diff for: β€Žimg/highlighting.gif

55.2 KB
Loading

0 commit comments

Comments
Β (0)