docs: describe how to set up completion for each shell
Setting up completion is particularly non-obvious for Zsh, so let's
provide the exact command(s) for each supported shell.
Closes
@@ -138,12 +138,6 @@ Now run this (regardless of platform):
cargo install --git https://github.com/martinvonz/jj.git
```
-To set up command-line completion, source the output of
-`jj debug completion --bash/--zsh/--fish`. For example, if you use Bash:
-```shell script
-source <(jj debug completion) # --bash is the default
-```
-
You may also want to configure your name and email so commits are made in your
name. Create a file at `<config dir>/jj/config.toml` (where `<config dir>` is
`${XDG_CONFIG_HOME}` or `~/.config/` on Linux, `~/Library/Application Support/`
@@ -156,6 +150,31 @@ name = "Martin von Zweigbergk"
email = "martinvonz@google.com"
```
+### Command-line completion
+
+To set up command-line completion, source the output of
+`jj debug completion --bash/--zsh/--fish`. Exactly how to source it depends on
+your shell.
+
+#### Bash
+```shell script
+source <(jj debug completion) # --bash is the default
+```
+
+#### Zsh
+```shell script
+autoload -U compinit
+compinit
+source <(jj debug completion --zsh | sed '$d') # remove the last line
+compdef _jj jj
+```
+
+#### Fish
+```shell script
+jj debug completion --fish | source
+```
+
+
### Nix OS
If you're on Nix OS you can use the flake for this repository.
