Skip to content

Commit 354cff9

Browse files
authored
fix(docs): Improve ZMK setup instructions (zmkfirmware#3209)
* fix(docs): Improve link and code highlight contrast Reset the theme's primary colors to the defaults, since the color of links was a bit too low contrast in the dark theme. The default primary color is a very similar but slightly lighter shade of blue. The background color of highlighted lines in code blocks is also fairly low contrast, but it needs to be in order to keep the text readable. To add contrast here, we now add a colored block to the left side of a highlighted line. * fix(docs): Improve ZMK setup instructions This makes several improvements to the instructions for installing and using ZMK CLI: - Windows Terminal is also named "Terminal", so reworded the terminal instructions to not separate Windows from other OSes. - Specified that Windows Terminal should always be used on Windows, as on older installations of Windows, the default terminal when opening PowerShell may be the legacy console host, which may not support some of the VT sequences used by ZMK CLI. - Switched from pipx to uv. This eliminates the need for instructions on installing Python, as uv will automatically install a supported version of Python if needed. - Updated the instructions for running "zmk init", as ZMK CLI version 0.4.0 switched from immediately asking for a repo URL to prompting the user to select between creating a new repo or cloning an existing one first. - Since for a new user, having a keymap compile successfully on the first attempt after modifying it may be the exception rather than the norm, added a note about error messages in GitHub actions with a link to the troubleshooting page. Also added instructions for updating ZMK CLI to the latest version on the ZMK CLI page.
1 parent ab46f48 commit 354cff9

3 files changed

Lines changed: 106 additions & 93 deletions

File tree

docs/docs/user-setup.mdx

Lines changed: 81 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,19 @@ import Tabs from "@theme/Tabs";
77
import TabItem from "@theme/TabItem";
88

99
export const OsTabs = (props) => (
10-
<Tabs
10+
<Tabs
1111
groupId="operating-system"
1212
queryString
1313
defaultValue="linux"
1414
values={[
1515
{ label: "Linux", value: "linux" },
1616
{ label: "Windows", value: "win" },
17-
{ label: "Mac OS", value: "mac" }
17+
{ label: "macOS", value: "mac" },
1818
]}
1919
>
2020
{/* eslint-disable-next-line */}
2121
{props.children}
2222
</Tabs>
23-
2423
);
2524

2625
Unlike other keyboard firmwares, ZMK Firmware has been built from the ground up to allow users to manage
@@ -54,10 +53,9 @@ Following the steps in this guide, you will:
5453

5554
You will need to install a few tools before you can get started.
5655

57-
Many instructions in this guide use commands that need to be run in a terminal application.
56+
Many instructions in this guide use commands that need to be run in a terminal application. On most operating systems, the program is simply named "Terminal".
5857

59-
- On Windows, use [Windows Terminal](https://apps.microsoft.com/detail/9n0dx20hk701) or PowerShell.
60-
- On other operating systems, the terminal program is usually just named "Terminal".
58+
On Windows, get [Windows Terminal](https://apps.microsoft.com/detail/9n0dx20hk701) from the Microsoft Store if it isn't already installed.
6159

6260
### Install Git
6361

@@ -67,7 +65,7 @@ Open a terminal and run the following command. If Git is already installed, it w
6765
git --version
6866
```
6967

70-
If it gives an error instead, install Git from https://git-scm.com/install/. Close and re-open your terminal and run the `git --version` command again to check if it installed correctly.
68+
If it prints an error instead, install Git from https://git-scm.com/install/. Close and reopen your terminal and run the `git --version` command again to check if it installed correctly.
7169

7270
:::note
7371
This guide will have you run several more `git` commands later. If you aren't familiar with Git, check out [Learn The Basics Of Git In Under 10 Minutes](https://www.freecodecamp.org/news/learn-the-basics-of-git-in-under-10-minutes-da548267cc91/) to help you get started.
@@ -91,132 +89,131 @@ gh auth login
9189

9290
Create a [personal access token](https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/creating-a-personal-access-token) and make sure to create it with the "workflow" scope option selected.
9391

94-
When running `git` commands later in this guide, Git will ask for your username and password. Enter your GitHub username, but **do not enter your password**. Instead, paste your access token for the password. You won't be able to see the token again after you create it, so keep the page open until you've done this and/or copy it to a secure location. If you lose the token, simply create another one.
92+
When running `git` commands later in this guide, Git will ask for your username and password. Enter your GitHub username, but **do not enter your password**. Instead, paste your access token where it asks for the password. You won't be able to see the token again after you create it, so keep the page open until you've done this and/or copy it to a secure location. If you lose the token, simply create another one.
93+
94+
### Install uv
95+
96+
[uv](https://github.com/astral-sh/uv) is a Python package manager which can install ZMK CLI and a supported version of Python if necessary. The instructions for installing uv differ depending on your operating system. Select the tab for your OS below.
9597

96-
### Install Python and pipx
98+
If installation fails, see [https://docs.astral.sh/uv/getting-started/installation/](https://docs.astral.sh/uv/getting-started/installation/) for more detailed instructions and alternative installation methods.
9799

98-
ZMK CLI requires Python version 3.10 or above.
100+
<details>
101+
<summary>Other package managers</summary>
99102

100-
There are several ways you can install ZMK CLI, but for simplicity, this guide will use [pipx](https://pipx.pypa.io/stable/). (If you are already familiar with another Python package manager such as [uv](https://github.com/astral-sh/uv), you can install the `zmk` package with it instead, but that will not be covered in this guide.)
103+
ZMK CLI can also be installed with other Python package managers such as [pipx](https://pipx.pypa.io/stable/). If you have a different package manager you prefer, install the ["zmk" package](https://pypi.org/project/zmk/) and skip to [Config Repo Setup](#config-repo-setup).
101104

102-
The instructions for installing Python and pipx differ depending on your operating system.
105+
</details>
103106

104107
<OsTabs>
105108
<TabItem value="linux">
106109

107-
Python comes preinstalled on most Linux distributions, but pipx needs to be installed separately. In case Python isn't already installed, this guide will have you install both. Pick the commands relevant to the distribution you are using:
108-
109-
#### Ubuntu 23.04 or above
110+
Open a terminal and run the following command:
110111

111112
```sh
112-
sudo apt update
113-
sudo apt install python3 pipx
114-
pipx ensurepath
113+
curl -LsSf https://astral.sh/uv/install.sh | sh
115114
```
116115

117-
#### Ubuntu 22.04
116+
If you get an error like "curl: command not found", try using wget:
118117

119118
```sh
120-
sudo apt update
121-
sudo apt install python3
122-
python3 -m pip install --user pipx
123-
python3 -m pipx ensurepath
119+
wget -qO- https://astral.sh/uv/install.sh | sh
124120
```
125121

126-
#### Ubuntu 20.04
127-
128-
Ubuntu 20.04 comes with an older version of Python. You can install Python 3.10 from the deadsnakes PPA with the following commands:
122+
If that doesn't work either, install [curl](https://curl.se/) and try again. For example, on Ubuntu and other Debian-based Linux distributions, run:
129123

130124
```sh
131-
sudo add-apt-repository ppa:deadsnakes/ppa
132-
sudo apt install python3.10
133-
python3.10 -m pip install --user pipx
134-
python3.10 -m pipx ensurepath
125+
sudo apt update
126+
sudo apt install curl
127+
curl -LsSf https://astral.sh/uv/install.sh | sh
135128
```
136129

137-
You will then need to replace `python3` with `python3.10` in the rest of the installation instructions.
138-
139-
#### Fedora 35 or above
130+
If the install script prints the following, close and reopen your terminal.
140131

141-
```sh
142-
sudo dnf install python3 pipx
143-
pipx ensurepath
144132
```
133+
To add $HOME/.local/bin to your PATH, either restart your shell or run:
145134
146-
If you have an older version of Fedora, you will need to update your operating system to a newer version or [build Python from source](https://docs.python.org/3/using/unix.html#building-python).
135+
source $HOME/.local/bin/env (sh, bash, zsh)
136+
source $HOME/.local/bin/env.fish (fish)
137+
```
147138

148-
#### Other distributions
139+
</TabItem>
140+
<TabItem value="win">
149141

150-
Install Python 3 and pipx using your distribution's package manager. If there is no package for pipx, install it with `pip` after installing Python:
142+
Open a terminal and run the following command:
151143

152144
```sh
153-
python3 -m pip install --user pipx
154-
python3 -m pipx ensurepath
145+
winget install --id astral-sh.uv -e --source winget
155146
```
156147

157-
Check the version of Python you installed:
148+
If this prints the text that is highlighted below, close and reopen your terminal.
158149

159-
```sh
160-
python3 --version
161150
```
162-
163-
If this prints a version less than 3.10, you will need to update your operating system to a newer version or [build Python from source](https://docs.python.org/3/using/unix.html#building-python).
151+
// highlight-next-line
152+
Path environment variable modified; restart your shell to use the new value.
153+
Command line alias added: "uvx"
154+
Command line alias added: "uv"
155+
Command line alias added: "uvm"
156+
Successfully installed
157+
```
164158

165159
</TabItem>
160+
<TabItem value="mac">
166161

167-
<TabItem value="win">
168-
169-
Open https://www.python.org/downloads/ and select "Download Python install manager". Run the installer, then open a terminal and run the following command to install the latest version of Python 3:
162+
Open a terminal and run the following command:
170163

171164
```sh
172-
py install 3
165+
curl -LsSf https://astral.sh/uv/install.sh | sh
173166
```
174167

175-
Next, install pipx:
168+
If the install script prints the following, close and reopen your terminal.
176169

177-
```sh
178-
py -m pip install --user pipx
179-
py -m pipx ensurepath
170+
```
171+
To add $HOME/.local/bin to your PATH, either restart your shell or run:
172+
173+
source $HOME/.local/bin/env (sh, bash, zsh)
174+
source $HOME/.local/bin/env.fish (fish)
180175
```
181176

182177
</TabItem>
178+
</OsTabs>
183179

184-
<TabItem value="mac">
180+
### Install ZMK CLI
185181

186-
First, install Homebrew from https://brew.sh/. Next, open a terminal and run:
182+
Finally, we'll install ZMK CLI. Open a terminal and run:
187183

188184
```sh
189-
brew install pipx
190-
pipx ensurepath
185+
uv tool install zmk
191186
```
192187

193-
This should automatically install Python 3 if it is missing.
188+
<details>
189+
<summary>I get an "executable already exists" error</summary>
194190

195-
</TabItem>
196-
</OsTabs>
191+
Earlier versions of this guide used pipx. If you get an error like this...
197192

198-
### Verify pipx Install
193+
```
194+
error: Executable already exists: zmk.exe (use `--force` to overwrite)
195+
```
199196

200-
Close and re-open your terminal, then run:
197+
...run the following commands to remove the pipx version and reinstall it with uv:
201198

202199
```sh
203-
pipx --version
200+
python3 -m pipx uninstall zmk
201+
uv tool install zmk
204202
```
205203

206-
It should print a version number. If not, go back to the previous step and make sure you installed pipx correctly. You can also try logging out of your computer and logging back in to make sure any environment variables changes made during installation take effect.
207-
208-
### Install ZMK CLI
204+
</details>
209205

210-
Finally, we'll install ZMK CLI. Open a terminal and run:
206+
This will likely print a message like ``warning: `/home/username/.local/bin` is not on your PATH``. To fix that, run:
211207

212208
```sh
213-
pipx install zmk
214-
zmk --version
209+
uv tool update-shell
215210
```
216211

217-
It should print a version number if everything installed correctly.
212+
Close and reopen your terminal to apply the changes, then run the following command. It should print a version number if everything installed correctly.
218213

219-
On Linux, you may get an error saying you need to install another package such as `python3.10-venv`. If so, follow the instructions in the error message, then try the above commands again.
214+
```sh
215+
zmk --version
216+
```
220217

221218
## Config Repo Setup
222219

@@ -237,22 +234,22 @@ Then, [skip to the next step](#add-a-keyboard).
237234

238235
</details>
239236

240-
Open a terminal and use the `cd` command to move to a folder where you'd like to place the ZMK files (it will create a `zmk-config` subfolder in this location), then run `zmk init`. For example:
237+
Open a terminal and use the `cd` command to move to a folder where you'd like to place the ZMK files (it will create a new folder in this location), then run `zmk init`. For example:
241238

242239
```sh
243240
cd ~/Documents
244241
zmk init
245242
```
246243

247-
Follow the instructions it gives you. If you already have a ZMK config repo on GitHub, you can enter its URL when prompted, for example:
244+
Follow the instructions it gives you. If you already have a ZMK config repo on GitHub, select "Clone an existing repo" and enter its URL when prompted, for example:
248245

249246
```
250247
Repository URL: https://github.com/myusername/zmk-config
251248
```
252249

253-
Otherwise, leave this first prompt blank and press <kbd>Enter</kbd>, and it will walk you through creating a new repo.
250+
Otherwise, select "Create a new ZMK config repo", and follow the instructions to create a new repo.
254251

255-
Once you finish following all the instructions, you will have a copy of the repo stored on your computer. All `zmk` commands will run on this repo (unless the working directory is inside a different repo). If you ever forget where the repo is located, you can run `zmk cd` to find it.
252+
After this finishes, you will have a copy of the repo stored on your computer. All `zmk` commands will run on this repo (unless the working directory is inside a different repo). If you ever forget where the repo is located, you can run `zmk cd` to find it.
256253

257254
### Add a Keyboard
258255

@@ -328,7 +325,7 @@ The text after `-m` is the "commit message", which gives a name to the commit. T
328325

329326
:::warning
330327

331-
If the `git push` command asks you for a username and password, enter your GitHub username, but **do not enter your password**. Instead, paste your access token for the password. (Go back to the [GitHub account setup instructions](#set-up-a-github-account) if you need to create a token.)
328+
If the `git push` command asks you for a username and password, enter your GitHub username, but **do not enter your password**. Instead, paste your access token where it asks for the password. (Go back to the [GitHub account setup instructions](#set-up-a-github-account) if you need to create a token.)
332329

333330
:::
334331

@@ -346,11 +343,17 @@ Or, you can manually open your GitHub repository in your browser and click the "
346343

347344
![](./assets/user-setup/github-actions-link.png)
348345

349-
Once you have loaded the Actions tab, select the top build from the list. Once you load it, the right side panel will include
346+
Once you have loaded the Actions tab, select the top build from the list. If the build was successful, the right side panel will include
350347
a link to download the `firmware` upload:
351348

352349
![](./assets/user-setup/firmware-archive.png)
353350

351+
:::info[Fixing build errors]
352+
353+
If you see a red X instead of a link to download the firmware, the build failed, likely due to an error in your repo. See the [troubleshooting page](./troubleshooting/building-issues.md) for help fixing the error. After making changes, [commit and push](#commit-and-push-to-github) again and GitHub will start a new build.
354+
355+
:::
356+
354357
Once downloaded, extract the zip and you can verify it should contain one or more `.uf2` or `.hex` files, which contain the firmware you need to write to your keyboard.
355358

356359
### Flash UF2 Files

docs/docs/zmk-cli.mdx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,19 @@ ZMK CLI is a command line tool which helps with setting up a ZMK config repo and
77

88
See the [ZMK installation guide](user-setup.mdx#prerequisites) for instructions on installing ZMK CLI.
99

10-
## Using ZMK CLI
10+
The instructions below contain commands that need to be run in a terminal program. On most operating systems, the program is simply named "Terminal".
11+
12+
On Windows, get [Windows Terminal](https://apps.microsoft.com/detail/9n0dx20hk701) from the Microsoft Store if it isn't already installed.
1113

12-
The instructions below contain commands that need to be run in a terminal program.
14+
## Updating ZMK CLI
1315

14-
- On Windows, use [Windows Terminal](https://apps.microsoft.com/detail/9n0dx20hk701) or PowerShell.
15-
- On other operating systems, the terminal program is usually just named "Terminal".
16+
To update to the latest version of ZMK, run the following command in a terminal:
17+
18+
```sh
19+
uv tool upgrade zmk
20+
```
21+
22+
## Using ZMK CLI
1623

1724
All ZMK CLI commands start with `zmk`. Run `zmk --help` for general usage instructions. For help with a specific subcommand, add `--help` after the subcommand, e.g. `zmk init --help`.
1825

docs/src/css/custom.css

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,11 @@
77

88
/* You can override the default Infima variables here. */
99
:root {
10-
--ifm-color-primary: #026fc5;
11-
--ifm-color-primary-dark: #0264b1;
12-
--ifm-color-primary-darker: #025ea7;
13-
--ifm-color-primary-darkest: #014e8a;
14-
--ifm-color-primary-light: #027ad9;
15-
--ifm-color-primary-lighter: #0280e3;
16-
--ifm-color-primary-lightest: #0690fc;
1710
--ifm-code-font-size: 95%;
1811

1912
--docusaurus-highlighted-code-line-bg: rgb(0 0 0 / 8%);
13+
--docusaurus-highlighted-code-line-border-width: 5px;
14+
--docusaurus-highlighted-code-line-border-color: var(--ifm-color-primary);
2015
}
2116

2217
[data-theme="dark"] {
@@ -38,10 +33,18 @@
3833
background-color: var(--ifm-navbar-link-hover-color);
3934
}
4035

41-
.docusaurus-highlight-code-line {
42-
display: block;
43-
margin: 0 calc(-1 * var(--ifm-pre-padding));
44-
padding: 0 var(--ifm-pre-padding);
36+
.theme-code-block .theme-code-block-highlighted-line {
37+
/* Line numbers have a solid color background which would cover the highlighted line */
38+
--ifm-pre-background: transparent;
39+
40+
/* Add a colored block to the left of any highlighted lines */
41+
border-left: var(--docusaurus-highlighted-code-line-border-width) solid
42+
var(--docusaurus-highlighted-code-line-border-color);
43+
44+
padding-left: calc(
45+
var(--ifm-pre-padding) -
46+
var(--docusaurus-highlighted-code-line-border-width)
47+
);
4548
}
4649

4750
.video-container {

0 commit comments

Comments
 (0)